Class ExpressionAstBuilder

java.lang.Object
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor<Expression>
dev.frostlake.parser.FrostlakeBaseVisitor<Expression>
dev.frostlake.executor.expressions.ExpressionAstBuilder
All Implemented Interfaces:
FrostlakeVisitor<Expression>, org.antlr.v4.runtime.tree.ParseTreeVisitor<Expression>

public class ExpressionAstBuilder extends FrostlakeBaseVisitor<Expression>
Builds Expression AST nodes directly from the ANTLR parse tree.

This replaces the round-trip in which an expression sub-tree was flattened back to source text (via getOriginalText) and then re-parsed, once per row, by the hand-rolled ExpressionParser. The grammar already parses every expression into a labeled parse tree; this visitor maps each labeled alternative of the expression rule to the corresponding Expression node. It mirrors SQLCommandVisitor (which builds statement-level objects) but is typed to produce Expression.

A few constructs intentionally fail loudly via notPorted(java.lang.String, org.antlr.v4.runtime.ParserRuleContext) because they are not row expressions that reach this builder — each is handled by another path: window OVER (resolved by the window operator before row evaluation), function named arguments (f(x => 1), used by table functions via TableFunctionOperator), bind variables (:name, substituted by the JDBC / procedural layer), and EXECUTE IMMEDIATE (procedural). There is no longer a legacy-parser fallback, so if one of these ever does reach row evaluation it throws — port it to a real node at that point. Any other unexpected node reaches visitChildren(RuleNode) and also fails loudly.