Beispiel #1
0
        private FEELRule RetrieveParser(string exprText)
        {
            var inputStream = CharStreams.fromstring(exprText);
            var lexer       = new FEELLexer(inputStream);

            lexer.RemoveErrorListeners();
            lexer.AddErrorListener(new LexerErrors());
            var tokenStream = new CommonTokenStream(lexer);
            var parser      = new FEELRule(tokenStream);

            parser.RemoveErrorListeners();
            parser.AddErrorListener(new ParserErrors());
            parser.BuildParseTree = true;
            return(parser);
        }
Beispiel #2
0
        private void ThrowParserErrors(string exprTxt, string whichFeel, FEELRule parser)
        {
            var parserErrs = parser.ErrorListeners[0] as ParserErrors;

            if (parserErrs.ErrorList.Any())
            {
                var errTxt = "";

                foreach (var item in parserErrs.ErrorList)
                {
                    errTxt += item;
                }

                throw new FEELException($"Problem parsing the input expresion: {exprTxt} : {whichFeel} : {errTxt}");
            }
        }