[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Tree-sitter introduction documentation
From: |
Gregory Heytings |
Subject: |
Re: Tree-sitter introduction documentation |
Date: |
Fri, 30 Dec 2022 01:01:22 +0000 |
As I said before, it seems that it is possible to evaluate the grammar
files that use the DSL using something like quickjs as well, which is
easier to build
You asked for it, so here it is:
global = {}
module = {}
process = { env: { TREE_SITTER_GRAMMAR_PATH: './grammar.js' } }
function require(s) { std.loadScript(s); return module.exports; }
std.loadScript('/path/to/the/script/dsl.js')
Put these five lines in a file, say "gen.js", cd in the directory of a
tree-sitter-<lang> repository, and type
qjs --std /path/to/the/script/gen.js > src/grammar.json
For simple grammars (bash, c, cmake, csharp, css, dockerfile, go, go-mod,
java, js, json, python, rust, yaml), this will work out of the box. For
more complex ones (c++, toml, tsx, typescript), you'll need to edit the
grammar.js file. That is left as an exercise for the reader.
Disclaimer: this is NOT what I recommend anyone to do! TRT is to install
and use Node.js, at least if you want to spare yourself headaches.
- Re: Tree-sitter introduction documentation, (continued)
- Re: Tree-sitter introduction documentation, Eli Zaretskii, 2022/12/29
- Re: Tree-sitter introduction documentation, Stefan Monnier, 2022/12/29
- Re: Tree-sitter introduction documentation, Eli Zaretskii, 2022/12/29
- Re: Tree-sitter introduction documentation, Philip Kaludercic, 2022/12/29
- Re: Tree-sitter introduction documentation, Eli Zaretskii, 2022/12/29
- Re: Tree-sitter introduction documentation, Philip Kaludercic, 2022/12/29
- Re: Tree-sitter introduction documentation, Stefan Monnier, 2022/12/29
- Re: Tree-sitter introduction documentation, Gregory Heytings, 2022/12/29
- Re: Tree-sitter introduction documentation, Philip Kaludercic, 2022/12/29
- Re: Tree-sitter introduction documentation, Gregory Heytings, 2022/12/29
- Re: Tree-sitter introduction documentation,
Gregory Heytings <=
- Re: Tree-sitter introduction documentation, Philip Kaludercic, 2022/12/30
- Re: Tree-sitter introduction documentation, Gregory Heytings, 2022/12/30
- Re: Tree-sitter introduction documentation, Philip Kaludercic, 2022/12/30
- Re: Tree-sitter introduction documentation, Gregory Heytings, 2022/12/30
- Re: Tree-sitter introduction documentation, Gregory Heytings, 2022/12/28
- Re: Tree-sitter introduction documentation, Stefan Monnier, 2022/12/28
- Re: Tree-sitter introduction documentation, Dmitry Gutov, 2022/12/27
- Re: Tree-sitter introduction documentation, Richard Stallman, 2022/12/31
- Re: Tree-sitter introduction documentation, tomas, 2022/12/27
- Re: Tree-sitter introduction documentation, Stefan Monnier, 2022/12/27