Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/michaelhatherly/treesitter.jl
Julia bindings for tree-sitter.
https://github.com/michaelhatherly/treesitter.jl
julia-language tree-sitter
Last synced: about 1 month ago
JSON representation
Julia bindings for tree-sitter.
- Host: GitHub
- URL: https://github.com/michaelhatherly/treesitter.jl
- Owner: MichaelHatherly
- License: mit
- Created: 2020-07-15T08:01:29.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-02T13:13:37.000Z (7 months ago)
- Last Synced: 2024-10-11T14:41:41.202Z (about 1 month ago)
- Topics: julia-language, tree-sitter
- Language: Julia
- Homepage:
- Size: 80.1 KB
- Stars: 18
- Watchers: 5
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TreeSitter
*Julia bindings for [tree-sitter](https://github.com/tree-sitter/tree-sitter) —
"An incremental parsing system for programming tools."*[![Build Status](https://travis-ci.org/MichaelHatherly/TreeSitter.jl.svg?branch=1.4)](https://travis-ci.org/MichaelHatherly/TreeSitter.jl)
[![Codecov](https://codecov.io/gh/MichaelHatherly/TreeSitter.jl/branch/1.4/graph/badge.svg)](https://codecov.io/gh/MichaelHatherly/TreeSitter.jl)## Installation
This package is not registered yet and so can be installed using:
```
pkg> add https://github.com/MichaelHatherly/TreeSitter.jl
```## Usage
```
julia> using TreeSitterjulia> c = Parser(:c)
Parser(Language(:c))julia> ast = parse(c, "int x;")
(translation_unit (declaration type: (primitive_type) declarator: (identifier)))julia> json = Parser(:json)
Parser(Language(:json))julia> ast = parse(json, "{1: [2]}")
(document (object (pair key: (number) value: (array (number)))))julia> traverse(ast) do node, enter
if enter
@show node
end
end
node = (document (object (pair key: (number) value: (array (number)))))
node = (object (pair key: (number) value: (array (number))))
node = ("{")
node = (pair key: (number) value: (array (number)))
node = (number)
node = (":")
node = (array (number))
node = ("[")
node = (number)
node = ("]")
node = ("}")julia> julia = Parser(:julia)
Parser(Language(:julia))julia> ast = parse(julia, "f(x)")
(source_file (call_expression (identifier) (argument_list (identifier))))julia> traverse(ast, named_children) do node, enter
if !enter
@show node
end
end
node = (identifier)
node = (identifier)
node = (argument_list (identifier))
node = (call_expression (identifier) (argument_list (identifier)))
node = (source_file (call_expression (identifier) (argument_list (identifier))))
```## Languages
- `:bash`
- `:c`
- `:cpp`
- `:go`
- `:html`
- `:java`
- `:javascript`
- `:json`
- `:julia`
- `:php`
- `:python`
- `:ruby`
- `:rust`
- `:typescript`Additional languages can be added by writing new `jll` packages to wrap the
upstream parsers: see [Yggdrasil](https://github.com/JuliaPackaging/Yggdrasil)
for details.