Generate OCaml parsers based on tree-sitter grammars, for semgrep.
Installing ocaml-tree-sitter
alone isn't of great use at the
moment. It is useful as part of the flow for generating OCaml parsers
from tree-sitter grammars, which is done from the lang/
folder.
See the Contributing instructions below.
- Install opam.
- Install ocaml dev tools for your favorite
editor:
typically
opam install merlin
+ some plugin for your editor. - Install
pre-commit
withpip3 install pre-commit
and runpre-commit install
to set up the pre-commit hook. This will re-indent code in a consistent fashion each time you callgit commit
. - Check out the extra instructions for MacOS.
For building or rebuilding everything after big changes, use this script:
./scripts/rebuild-everything # needs root access to install libtree-sitter
Say you want to build and test support for kotlin, you would run this:
$ cd lang
$ ./test-lang kotlin
For details, see How to upgrade the grammar for a language.
See How to add support for a new language.
We have limited documentation which is mostly targeted at early contributors. It's growing organically based on demand, so don't hesitate to file an issue explaining what you're trying to do.
ocaml-tree-sitter is free software with contributors from multiple organizations. The project is driven by r2c.
- OCaml code developed specifically for this project is distributed under the terms of the GNU GPL v3.
- The OCaml bindings to tree-sitter's C API were created by Bryan Phelps as part of the reason-tree-sitter project.
- The tree-sitter grammars for major programming languages are external projects. Each comes with its own license.