#lox #parser #incremental

tree-sitter-lox

Lox grammar for the tree-sitter parsing library

1 unstable release

0.1.0 Apr 23, 2023
0.0.0 Mar 29, 2022

#282 in Text editors

35 downloads per month
Used in loxcraft

MIT license

165KB
6.5K SLoC

C 6K SLoC JavaScript 151 SLoC // 0.1% comments Scheme 80 SLoC // 0.1% comments Rust 22 SLoC // 0.6% comments

tree-sitter-lox

Crates.io

A Lox grammar for the tree-sitter parsing library.

Local setup

Install tree-sitter-cli:

cargo install tree-sitter-cli

To generate bindings:

tree-sitter generate

To run tests:

tree-sitter test

References


lib.rs:

This crate provides Lox language support for the tree-sitter parsing library.

Typically, you will use the language function to add this language to a tree-sitter Parser, and then use the parser to parse some code:

let code = "";
let mut parser = tree_sitter::Parser::new();
parser.set_language(tree_sitter_lox::language()).expect("error loading Lox grammar");
let tree = parser.parse(code, None).unwrap();

Dependencies

~2.7–4MB
~71K SLoC