Module ast

Module ast 

Source
Expand description

Typed AST wrappers over CST nodes.

Each struct wraps a SyntaxNode and provides typed accessors. Cast is infallible for correct SyntaxKind - validation happens elsewhere.

§String Lifetime Limitation

SyntaxToken::text() returns &str tied to the token’s lifetime, not to the source &'q str. This is a rowan design: tokens store interned strings, not spans into the original source.

When building data structures that need source-lifetime strings (e.g., SymbolTable<'q>), use token_src instead of token.text().

Structs§

AltExpr
Anchor
AnonymousNode
Anonymous node: string literal ("+") or wildcard (_). Maps from CST Str or Wildcard.
Branch
CapturedExpr
Def
FieldExpr
NamedNode
NegatedField
NodePredicate
QuantifiedExpr
Ref
RegexLiteral
Root
SeqExpr
Type

Enums§

AltKind
Whether an alternation uses tagged or untagged branches.
Expr
Expression: any pattern that can appear in the tree.
PredicateOp
Predicate operator for node text filtering.
PredicateValue
Predicate value: either a string or a regex pattern.
SeqItem
Either an expression or an anchor in a sequence.

Functions§

is_truly_empty_scope
Checks if expression is a truly empty scope (sequence/alternation with no children). Used to distinguish { } @x (empty struct) from {(expr) @_} @x (Node capture).
predicate_op_from_syntax_kind
Convert SyntaxKind to PredicateOp.
token_src
Extracts token text with source lifetime.