public final NamedParameterContext namedParameter() throws RecognitionException { NamedParameterContext _localctx = new NamedParameterContext(_ctx, getState()); enterRule(_localctx, 10, RULE_namedParameter); try { enterOuterAlt(_localctx, 1); { setState(133); ((NamedParameterContext)_localctx).name = nameDefinition(); setState(134); match(COLON); setState(135); ((NamedParameterContext)_localctx).value = expression(); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; }
public final EndpointContext endpoint() throws RecognitionException { EndpointContext _localctx = new EndpointContext(_ctx, getState()); enterRule(_localctx, 92, RULE_endpoint); try { enterOuterAlt(_localctx, 1); { setState(533); additiveExpression(0); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; }
public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { switch (ruleIndex) { case 9: return iterationContext_sempred((IterationContextContext)_localctx, predIndex); case 26: return conditionalOrExpression_sempred((ConditionalOrExpressionContext)_localctx, predIndex); case 27: return conditionalAndExpression_sempred((ConditionalAndExpressionContext)_localctx, predIndex); case 28: return comparisonExpression_sempred((ComparisonExpressionContext)_localctx, predIndex); case 29: return relationalExpression_sempred((RelationalExpressionContext)_localctx, predIndex); case 31: return additiveExpression_sempred((AdditiveExpressionContext)_localctx, predIndex); case 32: return multiplicativeExpression_sempred((MultiplicativeExpressionContext)_localctx, predIndex); case 33: return powerExpression_sempred((PowerExpressionContext)_localctx, predIndex); case 34: return filterPathExpression_sempred((FilterPathExpressionContext)_localctx, predIndex); case 50: return nameRefOtherToken_sempred((NameRefOtherTokenContext)_localctx, predIndex); } return true; } private boolean iterationContext_sempred(IterationContextContext _localctx, int predIndex) {
public final PrimaryContext primary() throws RecognitionException { PrimaryContext _localctx = new PrimaryContext(_ctx, getState()); enterRule(_localctx, 74, RULE_primary); try { setState(452); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,36,_ctx) ) { case 1: _localctx = new PrimaryLiteralContext(_localctx); enterOuterAlt(_localctx, 1); setState(436); literal(); enterOuterAlt(_localctx, 2); setState(437); forExpression(); enterOuterAlt(_localctx, 3); setState(438); quantifiedExpression(); enterOuterAlt(_localctx, 4); setState(439); ifExpression(); enterOuterAlt(_localctx, 5);
private RelationalExpressionContext relationalExpression(int _p) throws RecognitionException { ParserRuleContext _parentctx = _ctx; int _parentState = getState(); RelationalExpressionContext _localctx = new RelationalExpressionContext(_ctx, _parentState); RelationalExpressionContext _prevctx = _localctx; int _startState = 58; enterRecursionRule(_localctx, 58, RULE_relationalExpression, _p); try { int _alt; enterOuterAlt(_localctx, 1); setState(327); additiveExpression(0); setState(350); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,24,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; setState(348); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,23,_ctx) ) { case 1: pushNewRecursionContext(_localctx, _startState, RULE_relationalExpression); setState(329); if (!(precpred(_ctx, 4))) throw new FailedPredicateException(this, "precpred(_ctx, 4)");
private FilterPathExpressionContext filterPathExpression(int _p) throws RecognitionException { ParserRuleContext _parentctx = _ctx; int _parentState = getState(); FilterPathExpressionContext _localctx = new FilterPathExpressionContext(_ctx, _parentState); FilterPathExpressionContext _prevctx = _localctx; int _startState = 68; enterRecursionRule(_localctx, 68, RULE_filterPathExpression, _p); try { int _alt; enterOuterAlt(_localctx, 1); setState(398); unaryExpression(); setState(415); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,31,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; setState(413); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,30,_ctx) ) { case 1: pushNewRecursionContext(_localctx, _startState, RULE_filterPathExpression); setState(400); if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)");
private ConditionalAndExpressionContext conditionalAndExpression(int _p) throws RecognitionException { ParserRuleContext _parentctx = _ctx; int _parentState = getState(); ConditionalAndExpressionContext _localctx = new ConditionalAndExpressionContext(_ctx, _parentState); ConditionalAndExpressionContext _prevctx = _localctx; int _startState = 54; enterRecursionRule(_localctx, 54, RULE_conditionalAndExpression, _p); try { int _alt; enterOuterAlt(_localctx, 1); setState(305); comparisonExpression(0); setState(312); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,21,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; pushNewRecursionContext(_localctx, _startState, RULE_conditionalAndExpression); setState(307); if (!(precpred(_ctx, 1))) throw new FailedPredicateException(this, "precpred(_ctx, 1)"); setState(308); ((CondAndContext)_localctx).op = match(AND); setState(309); ((CondAndContext)_localctx).right = comparisonExpression(0);
public final IterationContextContext iterationContext() throws RecognitionException { IterationContextContext _localctx = new IterationContextContext(_ctx, getState()); enterRule(_localctx, 18, RULE_iterationContext); try { setState(171); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,5,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); setState(160); if (!(helper.isFeatDMN12EnhancedForLoopEnabled())) throw new FailedPredicateException(this, "helper.isFeatDMN12EnhancedForLoopEnabled()"); setState(161); iterationNameDefinition(); setState(162); match(IN); setState(163); expression(); setState(164); match(ELIPSIS); setState(165); expression(); enterOuterAlt(_localctx, 2); setState(167); iterationNameDefinition(); setState(168); match(IN); setState(169);
public final IterationNameDefinitionTokensContext iterationNameDefinitionTokens() throws RecognitionException { IterationNameDefinitionTokensContext _localctx = new IterationNameDefinitionTokensContext(_ctx, getState()); enterRule(_localctx, 48, RULE_iterationNameDefinitionTokens); int _la; try { enterOuterAlt(_localctx, 1); setState(280); match(Identifier); setState(288); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << FOR) | (1L << RETURN) | (1L << IF) | (1L << THEN) | (1L << ELSE) | (1L << SOME) | (1L << EVERY) | (1L << SATISFIES) | (1L << INSTANCE) | (1L << OF) | (1L << FUNCTION) | (1L << EXTERNAL) | (1L << OR) | (1L << AND) | (1L << BETWEEN) | (1L << NULL) | (1L << TRUE) | (1L << FALSE) | (1L << QUOTE) | (1L << IntegerLiteral) | (1L << FloatingPointLiteral) | (1L << DOT) | (1L << ADD) | (1L << SUB) | (1L << MUL) | (1L << DIV) | (1L << NOT) | (1L << Identifier))) != 0)) { setState(286); switch (_input.LA(1)) { case Identifier: setState(281); match(Identifier); setState(282); additionalNameSymbol(); setState(283); match(IntegerLiteral); setState(284); match(FloatingPointLiteral);
public static List<FEELEvent> checkVariableName( String source ) { if( source == null || source.isEmpty() ) { return Collections.singletonList( new SyntaxErrorEvent( FEELEvent.Severity.ERROR, Msg.createMessage( Msg.INVALID_VARIABLE_NAME_EMPTY ), null, 0, 0, null ) ); } ANTLRInputStream input = new ANTLRInputStream(source); FEEL_1_1Lexer lexer = new FEEL_1_1Lexer( input ); CommonTokenStream tokens = new CommonTokenStream( lexer ); FEEL_1_1Parser parser = new FEEL_1_1Parser( tokens ); parser.setHelper( new ParserHelper() ); parser.setErrorHandler( new FEELErrorHandler() ); FEELParserErrorListener errorChecker = new FEELParserErrorListener( null ); parser.removeErrorListeners(); // removes the error listener that prints to the console parser.addErrorListener( errorChecker ); FEEL_1_1Parser.NameDefinitionContext nameDef = parser.nameDefinition(); if( ! errorChecker.hasErrors() && nameDef != null && source.trim().equals( parser.getHelper().getOriginalText( nameDef ) ) ) { return Collections.emptyList(); } return errorChecker.getErrors(); }
public static FEEL_1_1Parser parse(FEELEventListenersManager eventsManager, String source, Map<String, Type> inputVariableTypes, Map<String, Object> inputVariables, Collection<FEELFunction> additionalFunctions, List<FEELProfile> profiles) { ANTLRInputStream input = new ANTLRInputStream(source); FEEL_1_1Lexer lexer = new FEEL_1_1Lexer( input ); CommonTokenStream tokens = new CommonTokenStream( lexer ); FEEL_1_1Parser parser = new FEEL_1_1Parser( tokens ); ParserHelper parserHelper = new ParserHelper(eventsManager); additionalFunctions.forEach(f -> parserHelper.getSymbolTable().getBuiltInScope().define(f.getSymbol())); profiles.stream().filter(FEELv12Profile.class::isInstance).forEach(dc -> { parserHelper.setFeatDMN12EnhancedForLoopEnabled(true); parserHelper.setFeatDMN12weekday(true); }); parser.setHelper(parserHelper); parser.setErrorHandler( new FEELErrorHandler() ); parser.removeErrorListeners(); // removes the error listener that prints to the console parser.addErrorListener( new FEELParserErrorListener( eventsManager ) ); // pre-loads the parser with symbols defineVariables( inputVariableTypes, inputVariables, parser ); return parser; }
public ProcessedExpression( String expression, CompilerContext ctx, ProcessedFEELUnit.DefaultMode defaultBackend, List<FEELProfile> profiles) { super(expression, ctx, profiles); this.defaultBackend = defaultBackend; ParseTree tree = parser.compilation_unit(); ast = tree.accept(new ASTBuilderVisitor(ctx.getInputVariableTypes())); }
public ProcessedUnaryTest( String expressions, CompilerContext ctx) { super(expressions, ctx, Collections.emptyList()); ParseTree tree = parser.unaryTestsRoot(); BaseNode initialAst = tree.accept(new ASTBuilderVisitor(ctx.getInputVariableTypes())); ast = initialAst.accept(new ASTUnaryTestTransform()).node(); }
private BaseNode parse(String input, Map<String, Type> inputTypes) { FEEL_1_1Parser parser = FEELParser.parse(null, input, inputTypes, Collections.emptyMap(), Collections.emptyList(), Collections.emptyList()); ParseTree tree = parser.expression(); ASTBuilderVisitor v = new ASTBuilderVisitor(inputTypes); BaseNode expr = v.visit( tree ); return expr; }
public final ComparisonExpressionContext comparisonExpression() throws RecognitionException { return comparisonExpression(0); }
public final AdditiveExpressionContext additiveExpression() throws RecognitionException { return additiveExpression(0); }
public final NameDefinitionTokensContext nameDefinitionTokens() throws RecognitionException { NameDefinitionTokensContext _localctx = new NameDefinitionTokensContext(_ctx, getState()); enterRule(_localctx, 44, RULE_nameDefinitionTokens); int _la; try { enterOuterAlt(_localctx, 1); setState(265); match(Identifier); setState(274); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << FOR) | (1L << RETURN) | (1L << IN) | (1L << IF) | (1L << THEN) | (1L << ELSE) | (1L << SOME) | (1L << EVERY) | (1L << SATISFIES) | (1L << INSTANCE) | (1L << OF) | (1L << FUNCTION) | (1L << EXTERNAL) | (1L << OR) | (1L << AND) | (1L << BETWEEN) | (1L << NULL) | (1L << TRUE) | (1L << FALSE) | (1L << QUOTE) | (1L << IntegerLiteral) | (1L << FloatingPointLiteral) | (1L << DOT) | (1L << ADD) | (1L << SUB) | (1L << MUL) | (1L << DIV) | (1L << NOT) | (1L << Identifier))) != 0)) { setState(272); switch (_input.LA(1)) { case Identifier: setState(266); match(Identifier); setState(267); additionalNameSymbol(); setState(268); match(IntegerLiteral); setState(269); match(FloatingPointLiteral);
private CompiledFEELExpression parse(String input, Map<String, Type> inputTypes) { FEEL_1_1Parser parser = FEELParser.parse(null, input, inputTypes, Collections.emptyMap(), Collections.emptyList(), Collections.emptyList()); ParseTree tree = parser.compilation_unit(); ASTBuilderVisitor v = new ASTBuilderVisitor(inputTypes); BaseNode node = v.visit(tree); DirectCompilerResult directResult = node.accept(new ASTCompilerVisitor()); Expression expr = directResult.getExpression(); CompiledFEELExpression cu = new CompilerBytecodeLoader().makeFromJPExpression(input, expr, directResult.getFieldDeclarations()); return cu; }
private CompiledFEELUnaryTests parse(String input, Map<String, Type> inputTypes, FEELEventListenersManager mgr, CompiledFEELSupport.SyntaxErrorListener listener) { FEEL_1_1Parser parser = FEELParser.parse(mgr, input, inputTypes, Collections.emptyMap(), Collections.emptyList(), Collections.emptyList()); ParseTree tree = parser.unaryTestsRoot(); DirectCompilerResult directResult; if (listener.isError()) { directResult = CompiledFEELSupport.compiledErrorUnaryTest(listener.event().getMessage()); } else { ASTBuilderVisitor v = new ASTBuilderVisitor(inputTypes); BaseNode node = v.visit(tree); BaseNode transformed = node.accept(new ASTUnaryTestTransform()).node(); directResult = transformed.accept(new ASTCompilerVisitor()); } Expression expr = directResult.getExpression(); CompiledFEELUnaryTests cu = new CompilerBytecodeLoader().makeFromJPUnaryTestsExpression(input, expr, directResult.getFieldDeclarations()); return cu; }
public final Compilation_unitContext compilation_unit() throws RecognitionException { Compilation_unitContext _localctx = new Compilation_unitContext(_ctx, getState()); enterRule(_localctx, 0, RULE_compilation_unit); try { enterOuterAlt(_localctx, 1); { setState(104); expression(); setState(105); match(EOF); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; }