mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-13 07:57:35 +00:00
06ab29b93c
* Move radare2-shell-parser/tree-sitter into shlr * compile new shell parser by default, available with cfg.newshell variable * Add README for radare2-shell-parser * Improve CI * Add gitattributes file
1.2 KiB
1.2 KiB
radare2-shell-parser
This is the parser for radare2 shell language. See https://tree-sitter.github.io/tree-sitter/creating-parsers for more info on how to create a parser with tree-sitter.
Sources
- grammar.js: defines the basic grammar
- src/scanner.c: external scanner used to scan some tokens that cannot be parsed with the regular js grammar, as that includes only the context-free part of the language.
- src/parser.c: this file is auto-generated by tree-sitter based on grammar.js
- corpus/*: list of test files used to ensure the grammar works well
How to update grammar
When you update something in grammar.js or src/scanner.c you have to re-generate the parser. The process works as follows:
- Do changes as needed to grammar.js and/or src/scanner.c
- Install npm dependencies with:
cd shlr/radare2-shell-parser ; npm install
- Make sure tree-sitter is in PATH:
export PATH=$PATH:./node_modules/.bin
- Re-generate the parser files:
tree-sitter generate
- Check tests still pass:
tree-sitter test
. Usetree-sitter parse ./example-file
if you want to see the syntax tree of a custom input provided in./example-file
- Commit auto-generated files and modified grammar.js and src/scanner.c into git.