Expand description
gdscript-scene — a .tscn/.tres text parser for scene-aware analysis (Phase 4).
Godot’s text scene format is INI-like: bracketed section headers ([node …], [ext_resource …],
…) followed by key = value property lines. This crate parses that structure — node names,
types, parent paths, attached scripts, unique_name_in_owner, and instanced sub-scenes — into a
SceneModel with byte spans, so the type layer (Phase-4 M1+) can resolve $Path /
%Unique / get_node("…") to a node’s real Control/Node subclass instead of bare Node —
intelligence the Godot editor’s own LSP produces only in-editor and never flows into inference.
M0 scope: the pure, wasm-clean parse_scene (&str -> SceneModel) + the model + byte
spans. It records the typing inputs (type=/script=/instance=); it does not resolve
a Ty (M1), recurse into instanced sub-scenes, build the project-wide script↔scene index, or
cache via salsa (M1+). See plans/PHASE-4-M0-PLAYBOOK.md.
Invariant: the parser is strictly additive and never fails — every binary/malformed/
unknown form degrades to an empty-or-partial model + a SceneProblem, never a panic or Err.
The floor is always parity with the engine’s Node-everywhere baseline.
Portability: a core crate — wasm32-clean (no std::fs, no Instant, no threads); .tscn
text is injected via the VFS exactly like .gd.
Structs§
- ExtId
- An
ext_resource/sub_resourceid — the opaque, quoted-string key as written ("1","1_app","StyleBoxFlat_x"). A 3.x bare-int id is normalized to its string form. - ExtResource
- An
[ext_resource …]declaration. - NodeIdx
- Index of a node into
SceneModel::nodes. - Scene
Model - One parsed
.tscn/.tres. Produced bycrate::parse_scene; never anErr— every malformed/binary/unknown form degrades to an empty-or-partial model plus aSceneProblem.PartialEq/Eqso it can be a backdated salsa query result (Arc<SceneModel>) in M1. - Scene
Node - One
[node …]section: its header attributes + the two body properties we read. - SubResource
- A
[sub_resource …]declaration (type only — the value body is skipped).
Enums§
- Node
Path Resolution - The reason a node path did (not) resolve — for the
INVALID_NODE_PATHdecision (M2). - Scene
Kind - Whether the parsed file is a
.tscnscene (gd_scene) or a.tresresource (gd_resource). - Scene
Problem - A non-fatal problem found during parsing. The parser records these and keeps going — the floor
is always parity with the engine’s
Node-everywhere baseline.
Functions§
- parse_
scene - Parse
.tscn/.trestext into aSceneModel. Pure, never panics, never returnsErr.