Ejemplo n.º 1
0
        public override void Recover(LexerNoViableAltException e)
        {
            //Lexer recover strategy - ignore all till next space, tab or EOL
            var next = _input.La(1);

            while (next != -1 && next != ' ' && next != '\n' && next != '\r' && next != '\t' && next != ',' && next != ')')
            {
                Interpreter.Consume(_input);
                next = _input.La(1);
            }
        }
Ejemplo n.º 2
0
 private static string GetMessage(RecognitionException re)
 {
     return(re switch
     {
         FailedPredicateException fpe => fpe.Message,
         InputMismatchException ime => ime.Message,
         LexerNoViableAltException nve1 =>
         $"No Viable Alternative - '{nve1.OffendingToken.Text}' not recognized.",
         NoViableAltException nve2 =>
         $"No Viable Alternative - '{nve2.OffendingToken.Text}' was unexpected.",
         _ => throw new ArgumentOutOfRangeException(nameof(re))
     });
Ejemplo n.º 3
0
        public override void NotifyListeners(LexerNoViableAltException e)
        {
            Console.WriteLine("测试位置");
            //string text = _input.GetText(Interval.Of(_tokenStartCharIndex, _input.Index));
            ICharStream _input = (ICharStream)InputStream;
            string      text   = _input.GetText(Interval.Of(TokenStartCharIndex, _input.Index));

            Console.WriteLine(text);
            string msg = "无法识别的字符: '" + GetErrorDisplay(text) + "'";
            IAntlrErrorListener <int> listener = ErrorListenerDispatch;

            listener.SyntaxError(ErrorOutput, this, 0, Line, Column, msg, e);
        }
Ejemplo n.º 4
0
 public override void Recover(LexerNoViableAltException e)
 {
     throw e;
 }
Ejemplo n.º 5
0
 public override void Recover(LexerNoViableAltException e)
 {
     Console.WriteLine("调用我了!");
     base.Recover(e);
 }
Ejemplo n.º 6
0
 public override void Recover(LexerNoViableAltException e)
 {
     throw new ParseCanceledException(e);
 }
Ejemplo n.º 7
0
 public override void Recover(LexerNoViableAltException e)
 {
     NotifyListeners(e);
     base.Recover(e);
 }