docs: adhere to 120 new word column limit for docs

This commit is contained in:
Will Lillis 2026-01-12 22:10:09 -05:00
parent 1a88b26a10
commit e64e74d5ed
28 changed files with 143 additions and 115 deletions

View file

@ -1,6 +1,7 @@
# `tree-sitter generate`
The most important command for grammar development is `tree-sitter generate`, which reads the grammar in structured form and outputs C files that can be compiled into a shared or static library (e.g., using the [`build`](./build.md) command).
The most important command for grammar development is `tree-sitter generate`, which reads the grammar in structured form
and outputs C files that can be compiled into a shared or static library (e.g., using the [`build`](./build.md) command).
```bash
tree-sitter generate [OPTIONS] [GRAMMAR_PATH] # Aliases: gen, g
@ -8,7 +9,8 @@ tree-sitter generate [OPTIONS] [GRAMMAR_PATH] # Aliases: gen, g
The optional `GRAMMAR_PATH` argument should point to the structured grammar, in one of two forms:
- `grammar.js` a (ESM or CJS) JavaScript file; if the argument is omitted, it defaults to `./grammar.js`.
- `grammar.json` a structured representation of the grammar that is created as a byproduct of `generate`; this can be used to regenerate a missing `parser.c` without requiring a JavaScript runtime (useful when distributing parsers to consumers).
- `grammar.json` a structured representation of the grammar that is created as a byproduct of `generate`; this can be used
to regenerate a missing `parser.c` without requiring a JavaScript runtime (useful when distributing parsers to consumers).
If there is an ambiguity or *local ambiguity* in your grammar, Tree-sitter will detect it during parser generation, and
it will exit with a `Unresolved conflict` error message. To learn more about conflicts and how to handle them, see
@ -21,7 +23,8 @@ in the user guide.
- `src/tree_sitter/parser.h` provides basic C definitions that are used in the generated `parser.c` file.
- `src/tree_sitter/alloc.h` provides memory allocation macros that can be used in an external scanner.
- `src/tree_sitter/array.h` provides array macros that can be used in an external scanner.
- `src/grammar.json` contains a structured representation of the grammar; can be used to regenerate the parser without having to re-evaluate the `grammar.js`.
- `src/grammar.json` contains a structured representation of the grammar; can be used to regenerate the parser without having
to re-evaluate the `grammar.js`.
- `src/node-types.json` provides type information about individual syntax nodes; see the section on [`Static Node Types`](../using-parsers/6-static-node-types.md).
@ -29,8 +32,8 @@ in the user guide.
### `-l/--log`
Print the log of the parser generation process. This includes information such as what tokens are included in the error recovery state,
what keywords were extracted, what states were split and why, and the entry point state.
Print the log of the parser generation process. This includes information such as what tokens are included in the error
recovery state, what keywords were extracted, what states were split and why, and the entry point state.
### `--abi <VERSION>`
@ -60,7 +63,8 @@ The path to the JavaScript runtime executable to use when generating the parser.
Note that you can also set this with `TREE_SITTER_JS_RUNTIME`. Starting from version 0.26, you can
also pass in `native` to use the experimental native QuickJS runtime that comes bundled with the CLI.
This avoids the dependency on a JavaScript runtime entirely. The native QuickJS runtime is compatible
with ESM as well as with CommonJS in strict mode. If your grammar depends on `npm` to install dependencies such as base grammars, the native runtime can be used *after* running `npm install`.
with ESM as well as with CommonJS in strict mode. If your grammar depends on `npm` to install dependencies such as base
grammars, the native runtime can be used *after* running `npm install`.
### `--disable-optimization`