Esempio n. 1
0
        void OnParserError(antlr.RecognitionException error)
        {
            var location = new LexicalInfo(error.getFilename(), error.getLine(), error.getColumn());
            var nvae     = error as antlr.NoViableAltException;

            if (null != nvae)
            {
                ParserError(location, nvae);
            }
            else
            {
                GenericParserError(location, error);
            }
        }
Esempio n. 2
0
 public override void reportError(RecognitionException e)
 {
     //Console.ForegroundColor = ConsoleColor.Red;
     err.addError(e.Message, e.getLine(), e.getColumn());
     //Console.ResetColor();
 }
Esempio n. 3
0
		override public void reportError(RecognitionException x, string rulename)
		{
			// Silently ignore errors which are very close to a previous matched one,
			// assuming that they are produced while the parser is trying to recover.
			if (LastErrorLine != -1 && x.getLine() - LastErrorLine < 3) 
			{
				// Update it so we can extend the range as we go
				LastErrorLine = x.getLine();
				return;
			}

			// Override the reported error if there is matching pattern
			if (ErrorPatterns != null)
			{
				foreach (ErrorPattern pattern in ErrorPatterns)
				{
					if (pattern.Matches(rulename, x))
					{
						LastErrorLine = x.getLine();
						x = new RecognitionException(
							pattern.Message,
							x.getFilename(),
							x.getLine(),
							x.getColumn()
						);
						break;
					}
				}
			}

			reportError(x);
		}
 public override void reportError(RecognitionException x)
 {
     LexicalInfo info = new LexicalInfo(x.getFilename(), x.getLine(), x.getColumn());
     NoViableAltException exception = x as NoViableAltException;
     if (exception != null)
     {
         this.ReportError(CompilerErrorFactory.UnexpectedToken(info, x, exception.token.getText()));
     }
     else
     {
         this.ReportError(CompilerErrorFactory.GenericParserError(info, x));
     }
 }