override public bool Matches(string rule, RecognitionException ex) { if (rule != Rule) return false; return true; }
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); } }
/** * 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(); }
public virtual void recover(RecognitionException ex, BitSet tokenSet) { consume(); consumeUntil(tokenSet); }
public override void reportError(RecognitionException ex) { throw ex; }
public virtual void reportError(RecognitionException ex, string rulename) { reportError(ex); }
override public void reportError(RecognitionException x) { if (null != Error) Error(x); else base.reportError(x); }
public virtual void reportError(RecognitionException ex, string rulename) { reportError(ex); }
public TokenStreamRecognitionException(RecognitionException re) : base(re.Message) { this.recog = re; }
override public bool Matches(string rule, RecognitionException ex) { if (!base.Matches(rule, ex)) return false; MismatchedTokenException mmt = ex as MismatchedTokenException; if (mmt == null) return false; return Token == mmt.expecting; }
abstract public bool Matches(string rule, RecognitionException ex);
override public bool Matches(string rule, RecognitionException ex) { if (!base.Matches(rule, ex)) return false; NoViableAltException nva = ex as NoViableAltException; if (nva == null) return false; return Token == nva.token.Type; }
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)); } }
/*Parser error-reporting function can be overridden in subclass */ public virtual void reportError(RecognitionException ex) { Console.Error.WriteLine(ex.ToString()); }
public virtual void recover(RecognitionException ex, BitSet tokenSet) { consume(); consumeUntil(tokenSet); }
private void GenericParserError(LexicalInfo data, RecognitionException error) { _context.Errors.Add(CompilerErrorFactory.GenericParserError(data, error)); }
/*Parser error-reporting function can be overridden in subclass */ public virtual void reportError(RecognitionException ex) { Console.Error.WriteLine(ex); }
public override void reportError(RecognitionException e) { //Console.ForegroundColor = ConsoleColor.Red; err.addError(e.Message, e.getLine(), e.getColumn()); //Console.ResetColor(); }
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 ex) { FoundError = true; base.reportError(ex); }