All Projects → tree-sitter → ruby-tree-sitter

tree-sitter / ruby-tree-sitter

Licence: MIT license
Ruby bindings to tree-sitter

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to ruby-tree-sitter

tree-sitter.el
An Emacs dynamic module exposing tree-sitter.
Stars: ✭ 59 (+22.92%)
Mutual labels:  tree-sitter, binding
rust-tree-sitter
Rust bindings to Tree-sitter
Stars: ✭ 29 (-39.58%)
Mutual labels:  tree-sitter, binding
haskell-tree-sitter
Haskell bindings for tree-sitter
Stars: ✭ 123 (+156.25%)
Mutual labels:  tree-sitter, binding
go-tree-sitter
Golang bindings for tree-sitter https://github.com/tree-sitter/tree-sitter
Stars: ✭ 137 (+185.42%)
Mutual labels:  tree-sitter, binding
SwiftTreeSitter
Swift wrappers for the tree-sitter incremental parsing system
Stars: ✭ 116 (+141.67%)
Mutual labels:  tree-sitter
tree-sitter-html
HTML grammar for Tree-sitter
Stars: ✭ 56 (+16.67%)
Mutual labels:  tree-sitter
tree-sitter-typescript
TypeScript grammar for tree-sitter
Stars: ✭ 154 (+220.83%)
Mutual labels:  tree-sitter
skinner
Skin export / import tools for Autodesk Maya
Stars: ✭ 68 (+41.67%)
Mutual labels:  binding
Binder
🦁"Hello World" <-> [🏷, 🏷, 🏷, 🏷]
Stars: ✭ 37 (-22.92%)
Mutual labels:  binding
raylib-zig
Manually tweaked, auto generated raylib bindings for zig. https://github.com/raysan5/raylib
Stars: ✭ 122 (+154.17%)
Mutual labels:  binding
Forbind
Functional chaining and promises in Swift
Stars: ✭ 44 (-8.33%)
Mutual labels:  binding
zee
A modern text editor for the terminal written in Rust
Stars: ✭ 1,120 (+2233.33%)
Mutual labels:  tree-sitter
tree-sitter-toml
TOML grammar for tree-sitter
Stars: ✭ 23 (-52.08%)
Mutual labels:  tree-sitter
tree-sitter-elisp
tree-sitter grammar for emacs lisp
Stars: ✭ 20 (-58.33%)
Mutual labels:  tree-sitter
tree-sitter-tlaplus
A tree-sitter grammar for TLA+
Stars: ✭ 31 (-35.42%)
Mutual labels:  tree-sitter
playground
Treesitter playground integrated into Neovim
Stars: ✭ 467 (+872.92%)
Mutual labels:  tree-sitter
janetrs
Rust high level bindings for Janet
Stars: ✭ 36 (-25%)
Mutual labels:  binding
tree-hugger
A light-weight, extendable, high level, universal code parser built on top of tree-sitter
Stars: ✭ 96 (+100%)
Mutual labels:  tree-sitter
tree-sitter-legesher-python
✨ Legesher's Python grammar for Tree-Sitter 🌳
Stars: ✭ 40 (-16.67%)
Mutual labels:  tree-sitter
imgui-java
JNI based binding for Dear ImGui
Stars: ✭ 270 (+462.5%)
Mutual labels:  binding

TreeSitter

This gem wraps around tree-sitter.

Installation

Add this line to your application's Gemfile:

gem 'tree-sitter'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tree-sitter

Usage

Tree-sitter performs two different operations: compiling grammars and parsing text with those grammars.

This gem is only concerned with parsing a blob of text, given the appropriate grammars. Compiling grammars from JSON is trivial and can just be kept as an executable generated from C.

Running the parser

The libruntime static library needs to make use of the C code generated by the libcompile executable. Once you've got those, you'll need to provide an absolute path to the directory containing the C files that the library can incorporate. For example:

# if you've installed this gem
$ TREE_SITTER_PARSER_DIR=/somewhere/code bundle install
# if you're using this gem locally
$ TREE_SITTER_PARSER_DIR=/somewhere/code bundle exec rake compile

This directory is appended with the glob suffix **/*.{c,cc}, so it can contain as many nested parser files as necessary.

Then, you can start making use of the parser:

# first argument is the string to parse
# second argument is a set of options; currently, only one is available, `language:`,
# which identifies the text's language
document = TreeSitter::Document.new('a + b * 5', language: 'tree_sitter_arithmetic')

# you can change any of these values whenever you want, just remember to call `parse`
# provide the function name
document.input_string = '12 * 12'
document.language = "tree_sitter_python"
document.parse

Development

After checking out the repo, run script/bootstrap to install dependencies. Then, run script/test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].