README.md
1# radare2-shell-parser
2
3This is the parser for radare2 shell language.
4See https://tree-sitter.github.io/tree-sitter/creating-parsers for more info on
5how to create a parser with tree-sitter.
6
7## Sources
8- grammar.js: defines the basic grammar
9- src/scanner.c: external scanner used to scan some tokens that cannot be parsed
10 with the regular js grammar, as that includes only the context-free part of
11 the language.
12- src/parser.c: this file is auto-generated by tree-sitter based on grammar.js
13- corpus/\*: list of test files used to ensure the grammar works well
14
15## How to update grammar
16When you update something in grammar.js or src/scanner.c you have to re-generate
17the parser. The process works as follows:
18
191. Do changes as needed to grammar.js and/or src/scanner.c
202. Install npm dependencies with: `cd shlr/radare2-shell-parser ; npm install`
213. Make sure tree-sitter is in PATH: `export PATH=$PATH:./node_modules/.bin`
224. Re-generate the parser files: `tree-sitter generate`
235. Check tests still pass: `tree-sitter test`. Use `tree-sitter parse
24 ./example-file` if you want to see the syntax tree of a custom input provided
25 in `./example-file`
266. Commit auto-generated files and modified grammar.js and src/scanner.c into git.
27