Пример #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);
            }
        }
Пример #2
0
        /**
         * Overrides default error-reporting function.
         */
        public override void reportError(antlr.RecognitionException ex)
        {
            // if this is a NoViableAltForCharException there
            // is still no column information in antlr, so we
            // use the current column
            OCLSyntaticException error = new OCLSyntaticException(ex.Message,
                                                                  new SourceLocation(getFilename(), ex.getLine(), getColumn()));

            if (this.err != null)
            {
                this.err.WriteLine(error);
            }

            // continue but remember that we had errors
            this.parser.incErrorCount();
        }
Пример #3
0
 public override void reportError(RecognitionException e)
 {
     //Console.ForegroundColor = ConsoleColor.Red;
     err.addError(e.Message, e.getLine(), e.getColumn());
     //Console.ResetColor();
 }
Пример #4
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));
     }
 }