Skip to main content

Crate gdscript_syntax

Crate gdscript_syntax 

Source
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§

IndentDiagnostic
An indentation diagnostic produced while injecting block-structure markers. Byte-ranged; mapped into a gdscript-base Diagnostic by 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 SyntaxKind and the byte range it covers in the source.
SyntaxError
A byte-ranged syntax diagnostic with an “expected X” style message.

Enums§

SyntaxKind
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/Dedent markers into the lexer token stream.
tokenize
Lex src into a lossless RawToken stream. Never fails: an unlexable byte becomes a SyntaxKind::Error token, 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.
SyntaxNode
A bare (resolver-less) red node — cheap, Send + Sync; text needs a resolver.