Rizin
unix-like reverse engineering framework and cli tools
meson_tree_sitter_generate.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # SPDX-FileCopyrightText: 2021 ret2libc <sirmy15@gmail.com>
4 # SPDX-License-Identifier: LGPL-3.0-only
5 
6 """ Python script to execute tree-sitter generate in the right output folder,
7 necessary because tree-sitter generate does not allow to specify it """
8 
9 import os
10 import subprocess
11 import sys
12 
13 
14 def parse():
15  if len(sys.argv) <= 3:
16  print(
17  "Usage: {} <tree-sitter-path> <output-dir> <grammar.js>".format(sys.argv[0])
18  )
19  sys.exit(1)
20 
21  tree_sitter_exe = sys.argv[1]
22  output_dir = sys.argv[2]
23  grammar_js = sys.argv[3]
24 
25  return tree_sitter_exe, output_dir, grammar_js
26 
27 
28 def main():
29  tree_sitter_exe, output_dir, grammar_js = parse()
30 
31  grammar_js = os.path.abspath(grammar_js)
32  output_dir = os.path.abspath(output_dir)
33  tree_sitter_exe = os.path.abspath(tree_sitter_exe)
34 
35  subprocess.run(
36  [tree_sitter_exe, "generate", grammar_js], check=True, cwd=output_dir
37  )
38 
39 
40 if __name__ == "__main__":
41  main()
size_t len
Definition: 6502dis.c:15
Definition: regcomp.c:57