Class CalcCompiler
- java.lang.Object
-
- org.antlr.v4.runtime.tree.AbstractParseTreeVisitor<T>
-
- org.gorpipe.gor.GorScriptBaseVisitor<TypedCalcLambda>
-
- gorsat.parser.CalcCompiler
-
- All Implemented Interfaces:
org.antlr.v4.runtime.tree.ParseTreeVisitor<TypedCalcLambda>,GorScriptVisitor<TypedCalcLambda>
public class CalcCompiler extends GorScriptBaseVisitor<TypedCalcLambda>
CalcCompiler implements an Antlr parse tree visitor, starting on an expression node. It builds up a TypedCalcLambda along the way, collapsing constant expressions into constants, otherwise a lambda taking a ColumnValueProvider as an argument. To use the CalcCompiler, construct a parse tree with GorScriptParser - this is also done by SyntaxChecker. Then call setColumnNamesAndTypes to inform the compiler of available variables before passing the compiler to the accept method of the parse tree node.
-
-
Constructor Summary
Constructors Constructor Description CalcCompiler()CalcCompiler(gorsat.parser.ParseArith owner)
-
Method Summary
-
Methods inherited from class org.gorpipe.gor.GorScriptBaseVisitor
visitArgument, visitCalc_command, visitCalc_expression_list, visitColumn_list, visitColumn_name, visitColumn_number, visitColumn_range, visitColumn_ref, visitColumn_rename_rule, visitColumn_selection, visitColumn_wildcard, visitCreate_statement, visitDef_macro, visitFactor, visitFunction_expr, visitFunction_name, visitGeneric_command, visitGor_expression, visitGornor_expression, visitHide_command, visitInput_source, visitMacro_name, visitMacro_value, visitNested_query, visitNor_expression, visitOption, visitOption_value, visitOptional_power_factor, visitOptions_and_args, visitPgor_expression, visitPipe_command, visitPredicate, visitPredicate_factor, visitQuery_expression, visitRename_command, visitReplace_command, visitScript, visitSelect_command, visitString_literal_list, visitValue, visitVirtual_relation, visitVirtual_relation_name, visitWhere_command, visitXfactor
-
Methods inherited from class org.antlr.v4.runtime.tree.AbstractParseTreeVisitor
aggregateResult, defaultResult, shouldVisitNextChild, visit, visitChildren, visitErrorNode, visitTerminal
-
-
-
-
Method Detail
-
setColumnNamesAndTypes
public void setColumnNamesAndTypes(java.lang.String[] colNames, java.lang.String[] colTypes)
-
addSpecialVars
public void addSpecialVars()
-
visitCalc_expression
public TypedCalcLambda visitCalc_expression(GorScriptParser.Calc_expressionContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.calc_expression().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitCalc_expressionin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitCalc_expressionin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitExpression
public TypedCalcLambda visitExpression(GorScriptParser.ExpressionContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.expression().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitExpressionin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitExpressionin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitTerm
public TypedCalcLambda visitTerm(GorScriptParser.TermContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.term().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitTermin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitTermin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitSigned_factor
public TypedCalcLambda visitSigned_factor(GorScriptParser.Signed_factorContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.signed_factor().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitSigned_factorin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitSigned_factorin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitFunction_call
public TypedCalcLambda visitFunction_call(GorScriptParser.Function_callContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.function_call().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitFunction_callin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitFunction_callin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitParen_expr
public TypedCalcLambda visitParen_expr(GorScriptParser.Paren_exprContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.paren_expr().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitParen_exprin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitParen_exprin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitParen_rel_expr
public TypedCalcLambda visitParen_rel_expr(GorScriptParser.Paren_rel_exprContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.paren_rel_expr().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitParen_rel_exprin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitParen_rel_exprin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitNot_rel_expr
public TypedCalcLambda visitNot_rel_expr(GorScriptParser.Not_rel_exprContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.not_rel_expr().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitNot_rel_exprin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitNot_rel_exprin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitIn_expression
public TypedCalcLambda visitIn_expression(GorScriptParser.In_expressionContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.in_expression().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitIn_expressionin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitIn_expressionin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitIndag_expression
public TypedCalcLambda visitIndag_expression(GorScriptParser.Indag_expressionContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.indag_expression().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitIndag_expressionin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitIndag_expressionin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitRel_term
public TypedCalcLambda visitRel_term(GorScriptParser.Rel_termContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.rel_term().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitRel_termin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitRel_termin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitRel_expr
public TypedCalcLambda visitRel_expr(GorScriptParser.Rel_exprContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.rel_expr().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitRel_exprin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitRel_exprin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitCompare_expressions
public TypedCalcLambda visitCompare_expressions(GorScriptParser.Compare_expressionsContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.compare_expressions().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitCompare_expressionsin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitCompare_expressionsin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitIf_expr
public TypedCalcLambda visitIf_expr(GorScriptParser.If_exprContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.if_expr().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitIf_exprin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitIf_exprin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitPower_factor
public TypedCalcLambda visitPower_factor(GorScriptParser.Power_factorContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.power_factor().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitPower_factorin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitPower_factorin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitString_literal
public TypedCalcLambda visitString_literal(GorScriptParser.String_literalContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.string_literal().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitString_literalin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitString_literalin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitNumber
public TypedCalcLambda visitNumber(GorScriptParser.NumberContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.number().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitNumberin interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitNumberin classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitVariable
public TypedCalcLambda visitVariable(GorScriptParser.VariableContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.variable().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitVariablein interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitVariablein classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
visitFilename
public TypedCalcLambda visitFilename(GorScriptParser.FilenameContext ctx)
Description copied from class:GorScriptBaseVisitorVisit a parse tree produced byGorScriptParser.filename().The default implementation returns the result of calling
AbstractParseTreeVisitor.visitChildren(org.antlr.v4.runtime.tree.RuleNode)onctx.- Specified by:
visitFilenamein interfaceGorScriptVisitor<TypedCalcLambda>- Overrides:
visitFilenamein classGorScriptBaseVisitor<TypedCalcLambda>- Parameters:
ctx- the parse tree- Returns:
- the visitor result
-
-