This is an experiment to see if we can create a good parser for nu-lang.
- Ability to serve as a parser for a repl
- Ability to work in editors that support tree-sitter (
hx
,nvim
, others) - Ability to work in rust
- Fast
- Ability to be utilized for syntax highlighting
- ?
How-To - taken from here
cargo install tree-sitter-cli
- make sure nodejs and npm is installed (you may have to do npm install - see docs above)
tree-sitter generate
tree-sitter parse example-file.nu
- main.rs
cargo run --example main
- Add a file to test/corpus/descriptive_test_name.txt
- Use the
custom_command_1.txt
as a guide - run
tree-sitter test -f 'custom command 1'
and evaluate the results - More information can be found here
- A line in the grammar.js that begins with
$._blah
means thatblah
is anonymous and won't show up in the final syntax tree. - Most of the grammar how-to is found here