Skip to main content

Module ast

Module ast 

Source
Expand description

Concrete syntax tree and abstract syntax tree types.

These types define the public AST / CST surface for the parser frontend. Node hierarchies will be expanded over time, but the structural definitions — ConcreteSyntaxTree, Ast, TokenTape, TriviaTable — are settled here.

§Lossless vs lossy

  • ConcreteSyntaxTree is lossless: every delimiter, keyword, and trivia is represented with byte-offset spans. Round-tripping goes through the CST / token tape.

  • Ast is lossy (semantic): whitespace, comments, and exact delimiter positions are not preserved. Pretty-printing from the AST produces equivalent but not byte-identical output.

§Spanned invariant

Every AST node MUST carry a source Span. The Spanned trait formalises this requirement. All new AST node types must implement Spanned. This is enforced by code review, not by a compile-time lint (Rust’s type system cannot express “every variant of an enum has a span field”).

Structs§

Ast
The typed abstract syntax tree.
ConcreteSyntaxTree
The lossless concrete syntax tree produced by a [ParseBackend].
CstNodeId
Opaque identifier for a node in the ConcreteSyntaxTree.
SourceFile
A single parsed source file (the root of the typed AST).
SourceMap
Maps CstNodeIds to their source Spans.

Enums§

AstDecl
A top-level PL/SQL declaration.
AstExpr
A PL/SQL expression node.
AstStatement
A statement inside a routine / anonymous block body.
AstTypeDecl
A type declaration.

Traits§

Spanned
Every AST node must implement this trait.