Project

tree_stand

0.01
Repository is archived
No release in over a year
A high-level Ruby wrapper for the Tree-sitter bindings
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

TreeStand

TreeStand

NOTE: TreeStand has been vendored in ruby-tree-sitter see https://github.com/Faveod/ruby-tree-sitter for latest releases.

TreeStand is a high-level Ruby wrapper for the Tree-sitter bindings. It makes it easier to configure the parsers, and work with the underlying syntax tree.

Installation

Add this line to your application's Gemfile:

gem "ruby_tree_sitter"

See the documentation for supported features.

Usage

Setting Up a Parser

TreeStand does not help with compiling individual parsers. However, once you compile a parser and generate a shared object (.so) or a dynamic library (.dylib) you can tell TreeStand where to find them and pass the parser filename to TreeStand::Parser::new.

TreeStand.configure do
  config.parser_path = "path/to/parser/folder/"
end

sql_parser = TreeStand::Parser.new("sql")
ruby_parser = TreeStand::Parser.new("ruby")

API Conventions

TreeStand aims to provide APIs similar to TreeSitter when possible. For example, the TreeSitter parser exposes a #parse_string(tree, document) method. TreeStand replicates this behaviour closely with it's #parse_string(document, tree: nil) method but augments it to return a TreeStand::Tree instead of the underlying TreeSitter::Tree. Similarly, TreeStand::Tree#root_node returns a TreeStand::Node & TreeSitter::Tree#root_node returns a TreeSitter::Node.

The underlying objects are accessible via a ts_ prefixed attribute, e.g. ts_parser, ts_tree, ts_node, etc.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Faveod/ruby-tree-sitter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

See CONTRIBUTING.md for documentation on how to set up the project for development.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the TreeStand project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.