Expand description
gdscript-syntax — lexer + indentation pre-pass + lossless parser for GDScript.
Phase 1 fills this in: a logos lexer, a hand-written indentation pre-pass
(INDENT/DEDENT/NEWLINE), and a hand-written recursive-descent parser producing a
lossless cstree CST plus a typed AST, behind a Parser trait
(tree-sitter-gdscript is the differential test oracle, never the
grammar-of-record — see ADR-0002).
The crate “knows nothing about salsa or LSP” (rust-analyzer’s syntax layer):
it is pure text → tree. It must build for wasm32 — no std::fs, no clocks, no
threads.
Modules§
- ast
- WS4 — the typed AST.
Structs§
- Indent
Diagnostic - An indentation diagnostic produced while injecting block-structure markers.
Byte-ranged; mapped into a
gdscript-baseDiagnosticby the IDE layer. - Parse
- The result of parsing a source file: a lossless green tree, the interner needed to read token text back, and the diagnostics gathered while parsing.
- RawToken
- A lexed token: its
SyntaxKindand the byte range it covers in the source. - Syntax
Error - A byte-ranged syntax diagnostic with an “expected X” style message.
Enums§
- Syntax
Kind - Every terminal and non-terminal kind in the GDScript syntax tree.
Functions§
- parse
- Parse GDScript source into a lossless
Parse. Never fails. - run_
prepass - Inject
Newline/Indent/Dedentmarkers into the lexer token stream. - tokenize
- Lex
srcinto a losslessRawTokenstream. Never fails: an unlexable byte becomes aSyntaxKind::Errortoken, so the concatenation of token ranges always reproduces the source.
Type Aliases§
- GdNode
- A resolved (interner-carrying) red node — supports
Display/.text()and the byte-exact round-trip. This is the public tree type for callers that need text. - GdToken
- A resolved red token.
- Syntax
Node - A bare (resolver-less) red node — cheap,
Send + Sync; text needs a resolver.