Expand description
The Syntax IR: a language-neutral structural view of one source file.
Structural mode compares code by shape, not just by token content. Each
frontend parses a file with its real parser and maps the resulting tree
onto this IR: a token stream (the same Token representation Fast mode
uses) plus a tree of IrNodes whose Shapes come from a small
cross-language vocabulary. Nodes that have no cross-language equivalent
keep their native grammar kind instead of being forced into the nearest
common shape — a C++ template_declaration stays distinguishable from a
Rust generic function.
Error tolerance follows the frontend contract: a malformed region becomes
an Shape::Error node covering its source range and parsing continues.
Consumers that segment the tree into units must search recursively and
judge each found node by its own subtree, never by the mere presence of an
error ancestor: real parsers wrap large healthy regions in error nodes
whose ranges are the union of individually intact children.
Macros and templates are not expanded in Fast or Structural mode. The IR
records definition sites (Shape::MacroDef) and invocation sites
(Shape::MacroCall) as ordinary nodes so later phases can attach
expansion information without changing this schema.
Byte ranges are the only positions stored on nodes; line/column rendering is a reporting concern served by the token stream. No position feeds any stable identifier.
§Schema versioning
IR_SCHEMA_VERSION is a fingerprint input, and fingerprints built from
different IR schema versions are never considered equal. It stays at 1
until the first release tag: nothing has shipped, so a change that alters a
comparison result — adding or removing a Shape, changing a shape tag,
changing how frontends map native kinds — invalidates the databases holding
the old results rather than being versioned away from them, and re-running
the scan is the whole of the recovery.
Structs§
- Byte
Range - A half-open byte range into the source text.
- IrNode
- One node of the Syntax IR tree.
- Statement
Summary - A statement reduced to its shape and the span of its tokens.
- Syntax
IrFile - The Syntax IR of one source file.
Enums§
- Shape
- The cross-language shape vocabulary.
Constants§
- IR_
SCHEMA_ VERSION - Version of the Syntax IR schema, recorded per file and hashed into every structural fingerprint.
- MAX_
IR_ DEPTH - Maximum number of IR nodes on one root-to-leaf path emitted by the bundled structural frontends.
- SUMMARY_
HEAD_ TOKENS - How many leading tokens a
StatementSummarykeeps.
Traits§
- Structural
Frontend - A Structural-mode parser for one language.