Skip to main content

gdscript_syntax/
lib.rs

1//! `gdscript-syntax` — lexer + indentation pre-pass + lossless parser for GDScript.
2//!
3//! Phase 1 fills this in: a `logos` lexer, a hand-written indentation pre-pass
4//! (INDENT/DEDENT/NEWLINE), and a hand-written recursive-descent parser producing a
5//! lossless [`cstree`] CST plus a typed AST, behind a `Parser` trait
6//! (tree-sitter-gdscript is the differential test oracle, never the
7//! grammar-of-record — see ADR-0002).
8//!
9//! The crate "knows nothing about salsa or LSP" (rust-analyzer's `syntax` layer):
10//! it is pure text → tree. It must build for `wasm32` — no `std::fs`, no clocks, no
11//! threads.
12#![cfg_attr(docsrs, feature(doc_cfg))]
13// `cstree`'s `#[derive(Syntax)]` expands to a `from_raw` that `transmute`s a `u32`
14// discriminant into `SyntaxKind` (an `unsafe` block). That is the only `unsafe` in
15// this crate; everything we hand-write stays safe. This mirrors the workspace lint's
16// allowance for crates that must wire an external `unsafe` API (here, the CST builder).
17#![allow(unsafe_code)]
18
19pub mod ast;
20mod lexer;
21mod parser;
22mod prepass;
23mod syntax_kind;
24
25pub use lexer::{RawToken, tokenize};
26pub use parser::{Parse, SyntaxError, parse};
27pub use prepass::{IndentDiagnostic, run as run_prepass};
28pub use syntax_kind::{GdNode, GdToken, SyntaxKind, SyntaxNode};