Add canonical grammar and CodeMirror playground
This commit is contained in:
@@ -58,7 +58,11 @@ Important files:
|
||||
```text
|
||||
site/decodal-site/src/pages/docs/[...slug].astro
|
||||
site/decodal-site/src/pages/playground.astro
|
||||
site/decodal-site/src/scripts/playground.js
|
||||
site/decodal-site/src/scripts/playground-examples.js
|
||||
site/decodal-site/src/layouts/ManualLayout.astro
|
||||
site/decodal-site/src/lib/codemirror/decodal.js
|
||||
site/decodal-site/src/lib/codemirror/decodal-parser.js
|
||||
site/decodal-site/src/lib/docs.js
|
||||
site/decodal-site/src/lib/highlight.js
|
||||
crates/decodal-wasm/src/lib.rs
|
||||
@@ -81,7 +85,8 @@ site/decodal-site/src/wasm/
|
||||
|
||||
These generated files are committed so the site can be built without requiring every consumer to regenerate the wasm package first.
|
||||
|
||||
The playground editor uses `tokenizeSource` from `decodal-wasm` for token spans and maps those tokens to HTML classes in `src/lib/highlight.js`.
|
||||
The playground editor uses CodeMirror 6 with the generated Lezer parser in `src/lib/codemirror/decodal-parser.js`.
|
||||
The canonical grammar is documented in `doc/manual/souce/language/grammar.md`; regenerate the Lezer parser when that grammar or `editors/lezer-decodal/decodal.grammar` changes.
|
||||
The documentation build still uses the lightweight JavaScript fallback highlighter so Astro can render Markdown without initializing WASM at build time.
|
||||
|
||||
To run the site locally:
|
||||
@@ -156,12 +161,18 @@ The generated parser files under `editors/tree-sitter-decodal/src/` are committe
|
||||
|
||||
When the Decodal syntax changes:
|
||||
|
||||
1. Update `grammar.js`.
|
||||
2. Run `npx tree-sitter generate`.
|
||||
3. Add or update corpus tests in `corpus/`.
|
||||
4. Update highlight queries in `queries/highlights.scm` if token names changed.
|
||||
5. Run `npx tree-sitter test`.
|
||||
6. Run Rust checks from the repository root if the language parser or examples also changed.
|
||||
1. Update the canonical EBNF in `doc/manual/souce/language/grammar.md`.
|
||||
2. Update the Rust parser/tokenizer as needed.
|
||||
3. Update `editors/tree-sitter-decodal/grammar.js` and run `npx tree-sitter generate` / `npx tree-sitter test`.
|
||||
4. Update `editors/lezer-decodal/decodal.grammar` and regenerate the CodeMirror parser:
|
||||
|
||||
```sh
|
||||
cd site/decodal-site
|
||||
npx lezer-generator ../../editors/lezer-decodal/decodal.grammar -o src/lib/codemirror/decodal-parser.js
|
||||
```
|
||||
|
||||
5. Add or update corpus/tests/examples.
|
||||
6. Run Rust and site checks from the repository root.
|
||||
|
||||
## Development shell
|
||||
|
||||
|
||||
Reference in New Issue
Block a user