コード例 #1
0
        public override void ReportError(Antlr4.Runtime.Parser recognizer, RecognitionException e)
        {
            IntervalSet x = recognizer.GetExpectedTokens();

            LASet[e] = Filter(x);
            base.ReportError(recognizer, e);
        }
コード例 #2
0
        protected virtual string ErrorMessageForMissingToken(Antlr4.Runtime.Parser recognizer, IToken t)
        {
            IntervalSet expecting = GetExpectedTokens(recognizer);
            string      msg       = "missing " + GetListOfExpectedTokens(expecting, recognizer.Vocabulary) + " at " + GetTokenErrorDisplay(t);

            return(msg);
        }
コード例 #3
0
 public override void ReportAmbiguity(Antlr4.Runtime.Parser recognizer, DFA dfa, int startIndex, int stopIndex,
                                      bool exact, BitSet ambigAlts,
                                      ATNConfigSet configs)
 {
     //TODO : make sure that 'dfa.ToLexerString()' has meaningful and expected output. Not sure about that...
     Errors?.Add(new SyntaxErrorException(
                     $"Ambiguity error while parsing '{dfa.ToLexerString()}'. (start index: {startIndex}, stop index: {stopIndex})"));
 }
コード例 #4
0
 public override void ReportAttemptingFullContext(Antlr4.Runtime.Parser recognizer,
                                                  DFA dfa,
                                                  int startIndex,
                                                  int stopIndex,
                                                  BitSet conflictingAlts,
                                                  SimulatorState conflictState)
 {
 }
コード例 #5
0
 public override void ReportContextSensitivity(Antlr4.Runtime.Parser recognizer,
                                               DFA dfa,
                                               int startIndex,
                                               int stopIndex,
                                               int prediction,
                                               SimulatorState acceptState)
 {
 }
コード例 #6
0
        // --- Override the five methods below to customize Antlr error messages ---

        protected virtual string ErrorMessageForUnexpectedToken(Antlr4.Runtime.Parser recognizer, IToken t)
        {
            string      tokenName = GetTokenErrorDisplay(t);
            IntervalSet expecting = GetExpectedTokens(recognizer);
            string      msg       = "extraneous input " + tokenName + " expecting " + GetListOfExpectedTokens(expecting, recognizer.Vocabulary);

            return(msg);
        }
コード例 #7
0
 public override void ReportAmbiguity(Antlr4.Runtime.Parser recognizer,
                                      DFA dfa,
                                      int startIndex,
                                      int stopIndex,
                                      bool exact,
                                      BitSet ambigAlts,
                                      ATNConfigSet configs)
 {
 }
コード例 #8
0
        public AntlrPerformanceProfiler(Antlr4.Runtime.Parser parser)
        {
            parserRulesCount     = parser.RuleNames.Length;
            parserRuleNames      = parser.RuleNames;
            parserDecisionsCount = parser.Atn.DecisionToDfa.Length;

            ParsedFilesInfos   = new List <ParsedFileInfo>();
            AggregatedPerfInfo = new ParsedFileInfo("TOTAL", parserRulesCount, parserDecisionsCount);
            RuleStacksCount    = new Dictionary <string, int>();
        }
コード例 #9
0
 /// <summary>
 /// A compiler directive can be embedded anywhere in the Cobol syntax
 /// so we can consider that EOF is always present in the following set
 /// </summary>
 public override void Sync(Antlr4.Runtime.Parser recognizer)
 {
     if (GetExpectedTokens(recognizer).Contains(TokenConstants.Eof))
     {
         return;
     }
     else
     {
         base.Sync(recognizer);
     }
 }
コード例 #10
0
 public override void ReportAttemptingFullContext(
     [NotNull] Antlr4.Runtime.Parser recognizer,
     [NotNull] DFA dfa,
     int startIndex,
     int stopIndex,
     [Nullable] BitSet conflictingAlts,
     [NotNull] SimulatorState conflictState)
 {
     Errors.Add(
         new AttemptingFullContextParseError(recognizer, dfa, startIndex, stopIndex, conflictingAlts, conflictState)
         );
 }
コード例 #11
0
 public override void ReportContextSensitivity(
     [NotNull] Antlr4.Runtime.Parser recognizer,
     [NotNull] DFA dfa,
     int startIndex,
     int stopIndex,
     int prediction,
     [NotNull] SimulatorState acceptState)
 {
     Errors.Add(
         new ContextSensivityParseError(recognizer, dfa, startIndex, stopIndex, prediction, acceptState)
         );
 }
コード例 #12
0
        /// <summary>
        /// This method is called to report a syntax error which requires the
        /// insertion of a missing token into the input stream.
        /// </summary>
        protected override void ReportMissingToken(Antlr4.Runtime.Parser recognizer)
        {
            if (InErrorRecoveryMode(recognizer))
            {
                return;
            }
            BeginErrorCondition(recognizer);
            IToken t   = recognizer.CurrentToken;
            string msg = ErrorMessageForMissingToken(recognizer, t);

            recognizer.NotifyErrorListeners(t, msg, null);
        }
コード例 #13
0
 public override void ReportAmbiguity(
     [NotNull] Antlr4.Runtime.Parser recognizer,
     [NotNull] DFA dfa,
     int startIndex,
     int stopIndex,
     bool exact,
     [Nullable] BitSet ambigAlts,
     [NotNull] ATNConfigSet configs)
 {
     Errors.Add(
         new AmbiguityParseError(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs)
         );
 }
コード例 #14
0
        // --- Please do not touch the methods below which reproduce exactly the default Antlr runtime behaviour --

        /// <summary>
        /// Single token deletion recovery strategy
        /// </summary>
        protected override IToken SingleTokenDeletion(Antlr4.Runtime.Parser recognizer)
        {
            Token lastConsumedToken = (Token)((ITokenStream)recognizer.InputStream).Lt(-1);
            Token nextToken         = (Token)((ITokenStream)recognizer.InputStream).Lt(1);

            if (ErrorStrategyShouldNotConsumeThisToken(lastConsumedToken, nextToken))
            {
                return(null);
            }
            else
            {
                return(base.SingleTokenDeletion(recognizer));
            }
        }
コード例 #15
0
        /// <summary>
        /// Multiple token deletion resynchronization strategy
        /// </summary>
        protected override void ConsumeUntil(Antlr4.Runtime.Parser recognizer, IntervalSet set)
        {
            Token lastConsumedToken = (Token)((ITokenStream)recognizer.InputStream).Lt(-1);
            Token nextToken         = (Token)((ITokenStream)recognizer.InputStream).Lt(1);
            int   ttype             = nextToken.Type;

            while (ttype != TokenConstants.Eof && !set.Contains(ttype) &&
                   !ErrorStrategyShouldNotConsumeThisToken(lastConsumedToken, nextToken))
            {
                recognizer.Consume();
                lastConsumedToken = nextToken;
                nextToken         = (Token)((ITokenStream)recognizer.InputStream).Lt(1);
                ttype             = nextToken.Type;
            }
        }
コード例 #16
0
        protected override void ConsumeUntil(Antlr4.Runtime.Parser recognizer, IntervalSet set)
        {
            int tokenType = ((ITokenStream)recognizer.InputStream).La(1);
            int indents   = 1;

            while (tokenType != TokenConstants.Eof && indents > 0)
            {
                recognizer.Consume();
                tokenType = ((ITokenStream)recognizer.InputStream).La(1);
                if (tokenType == MalinaLexer.INDENT)
                {
                    indents++;
                }
                if (tokenType == MalinaLexer.DEDENT)
                {
                    indents--;
                }
            }
        }
コード例 #17
0
        public override void Recover(Antlr4.Runtime.Parser recognizer, RecognitionException e)
        {
            int tokenType = ((ITokenStream)recognizer.InputStream).La(1);
            int indents   = 1;

            while (tokenType != TokenConstants.Eof && indents > 0)
            {
                recognizer.Consume();
                tokenType = ((ITokenStream)recognizer.InputStream).La(1);
                if (tokenType == MalinaLexer.INDENT)
                {
                    indents++;
                }
                if (tokenType == MalinaLexer.DEDENT)
                {
                    indents--;
                }
            }
        }
コード例 #18
0
        protected override void ReportFailedPredicate(Antlr4.Runtime.Parser recognizer, FailedPredicateException e)
        {
            switch (e.Predicate)
            {
            case "FeatureControlFlow":
                NotifyErrorListeners(recognizer, "Control flow expressions not supported in this version of the language", e);
                break;

            case "FeatureConditionalExpr":
                NotifyErrorListeners(recognizer, "Conditional expressions not supported in this version of the language", e);
                break;

            case "FeatureMutableVars":
                NotifyErrorListeners(recognizer, "Mutable variables not supported in this version of the language", e);
                break;

            default:
                base.ReportFailedPredicate(recognizer, e);
                break;
            }
        }
コード例 #19
0
 public void Sync(Antlr4.Runtime.Parser recognizer)
 {
     throw new NotImplementedException();
 }
コード例 #20
0
 protected override ParserRuleContext Parse(Antlr4.Runtime.Parser parser)
 {
     return(((ECMAScriptParser)parser).program());
 }
コード例 #21
0
        protected virtual string ErrorMessageForFailedPredicate(FailedPredicateException e, Antlr4.Runtime.Parser recognizer)
        {
            string ruleName = recognizer.RuleNames[recognizer.RuleContext.RuleIndex];
            string msg      = "rule " + ruleName + " " + e.Message;

            return(msg);
        }
コード例 #22
0
ファイル: TSqlAntlrParser.cs プロジェクト: smartfish/PT.PM
 protected override ParserRuleContext Parse(Antlr4.Runtime.Parser parser) => ((TSqlParser)parser).tsql_file();
コード例 #23
0
ファイル: error.cs プロジェクト: bitdotgames/bhl
 public override void Sync(Antlr4.Runtime.Parser recognizer)
 {
 }
コード例 #24
0
 public IToken RecoverInline(Antlr4.Runtime.Parser recognizer)
 {
     throw new NotImplementedException();
 }
コード例 #25
0
ファイル: PlSqlAntlrParser.cs プロジェクト: smartfish/PT.PM
 protected override ParserRuleContext Parse(Antlr4.Runtime.Parser parser) => ((PlSqlParser)parser).sql_script();
コード例 #26
0
ファイル: PlSqlAntlrParser.cs プロジェクト: Yikez978/PT.PM
 protected override ParserRuleContext Parse(Antlr4.Runtime.Parser parser)
 {
     return(((PlSqlParser)parser).compilation_unit());
 }
コード例 #27
0
 public void ReportError(Antlr4.Runtime.Parser recognizer, RecognitionException e)
 {
     throw new NotImplementedException();
 }
コード例 #28
0
 public void ReportMatch(Antlr4.Runtime.Parser recognizer)
 {
     throw new NotImplementedException();
 }
コード例 #29
0
 protected override ParserRuleContext Parse(Antlr4.Runtime.Parser parser) =>
 ((JavaParser)parser).compilationUnit();
コード例 #30
0
 public bool InErrorRecoveryMode(Antlr4.Runtime.Parser recognizer)
 {
     throw new NotImplementedException();
 }