11///|
22/// A compiled expression pattern.
33///
4- /// `ast` is the parsed pattern expression. `expr_metavars` bind whole
5- /// expression AST nodes, `identifier_metavars` bind normalized identifier
6- /// strings, and `constant_metavars` bind literal constants. Pattern metavars
7- /// are represented directly in `ast` as `$(name:pat)` pattern variables and
8- /// bind whole pattern AST nodes.
4+ /// `ast` is the untyped AST node for the parsed pattern expression.
5+ /// `expr_metavars` bind whole expression AST nodes, `identifier_metavars`
6+ /// bind normalized identifier strings encoded as leaf string nodes, and
7+ /// `constant_metavars` bind literal constant nodes. Pattern metavars are
8+ /// represented directly in `ast` as `$(name:pat)` pattern variables and bind
9+ /// whole pattern AST nodes.
910/// `target_metavar` and `source_metavar` are reserved bare-expression
1011/// placeholders injected by the rules package for `__TARGET__` and
1112/// `__SOURCE__`.
1213pub (all) struct CompiledExprPattern {
13- ast : @syntax. Expr
14+ ast : @untyped_ast. Node
1415 expr_metavars : Array [String ]
1516 identifier_metavars : Array [String ]
1617 constant_metavars : Array [String ]
@@ -21,25 +22,20 @@ pub(all) struct CompiledExprPattern {
2122///|
2223/// Values captured while matching a `CompiledExprPattern`.
2324///
24- /// Expression metavars capture whole expressions. Identifier metavars capture
25- /// the normalized name as `Identifier`. Constant metavars capture parser
26- /// constants. Pattern metavars capture whole parser patterns.
27- pub (all) enum BoundValue {
28- Expr (@syntax.Expr )
29- Identifier (String )
30- Constant (@syntax.Constant )
31- Pattern (@syntax.Pattern )
32- }
25+ /// Every binding is stored directly as an untyped AST node. Expression,
26+ /// constant, and pattern metavars capture their matched nodes. Identifier
27+ /// metavars capture their normalized name in a `Leaf(PString(_))` node.
28+ pub type BoundValue = @untyped_ast.Node
3329
3430///|
3531/// Result of a successful expression-pattern match.
3632///
37- /// `root` is the candidate expression originally passed to the matcher.
33+ /// `root` is the candidate expression node originally passed to the matcher.
3834/// `bindings` is the effective binding context after the match. For
3935/// `match_expr_pattern` it contains fresh captures; for
4036/// `match_expr_pattern_with_bindings` it contains a copy of the initial
4137/// bindings plus any new captures.
4238pub (all) struct ExprMatch {
43- root : @syntax. Expr
39+ root : @untyped_ast. Node
4440 bindings : @hashmap.HashMap [String , BoundValue ]
4541}
0 commit comments