rizin/shlr/rizin-shell-parser
2021-03-31 16:10:54 +02:00
..
bindings Update rizin-shell-parser to tree-sitter 0.19.4 (#928) 2021-03-29 19:14:16 +02:00
corpus Fix autocompletion of rz- commands in rizin shell and rename wrong rz_ (#944) 2021-03-31 16:10:54 +02:00
src Update rizin-shell-parser to tree-sitter 0.19.4 (#928) 2021-03-29 19:14:16 +02:00
.gitignore
binding.gyp Update rizin-shell-parser to tree-sitter 0.19.4 (#928) 2021-03-29 19:14:16 +02:00
Cargo.toml Update rizin-shell-parser to tree-sitter 0.19.4 (#928) 2021-03-29 19:14:16 +02:00
grammar.js rizin-shell: do argument validation in the statement handlers 2021-03-09 08:06:32 +01:00
meson.build Update rizin-shell-parser to tree-sitter 0.19.4 (#928) 2021-03-29 19:14:16 +02:00
package-lock.json Update rizin-shell-parser to tree-sitter 0.19.4 (#928) 2021-03-29 19:14:16 +02:00
package.json Update rizin-shell-parser to tree-sitter 0.19.4 (#928) 2021-03-29 19:14:16 +02: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 shlr/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.