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