rizin/subprojects/rizin-shell-parser
Anton Kochkov 3278ec77d0
ci: use clang-format from LLVM 16 (#3696)
Co-authored-by: wargio <wargio@libero.it>
2023-08-01 09:11:26 +08:00
..
bindings
corpus Replace rz_core_cmd0 calls in tui/panels.c and port cmd_help commands to RzShell as cmd_math (#3421) 2023-03-30 18:36:48 +08:00
src Replace rz_core_cmd0 calls in tui/panels.c and port cmd_help commands to RzShell as cmd_math (#3421) 2023-03-30 18:36:48 +08:00
.gitignore
binding.gyp
Cargo.toml
grammar.js ci: use clang-format from LLVM 16 (#3696) 2023-08-01 09:11:26 +08:00
meson.build Fix build with use_sys_tree_sitter (#2562) 2022-04-28 01:38:03 +08:00
meson_tree_sitter_generate.py Fix build with use_sys_tree_sitter (#2562) 2022-04-28 01:38:03 +08:00
package-lock.json Update tree-sitter to 0.20.7 2023-01-31 19:06:55 +08:00
package.json Update tree-sitter to 0.20.7 2023-01-31 19:06:55 +08:00
README.md

rizin-shell-parser

This is the parser for rizin 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:

  1. Do changes as needed to grammar.js and/or src/scanner.c
  2. Install npm dependencies with: cd subprojects/rizin-shell-parser ; npm install
  3. Make sure tree-sitter is in PATH: export PATH=$PATH:./node_modules/.bin
  4. Re-generate the parser files: tree-sitter generate
  5. Check tests still pass: tree-sitter test. Use tree-sitter parse ./example-file if you want to see the syntax tree of a custom input provided in ./example-file
  6. Commit auto-generated files and modified grammar.js and src/scanner.c into git.