public override string ToString() { RecognitionException re = (RecognitionException)Cause; int line = 0; int charPos = -1; if (_token != null) { line = _token.Line; charPos = _token.CharPositionInLine; // check the input streams - if different then token is embedded in templateToken and we need to adjust the offset if (_templateToken != null && !_templateToken.InputStream.Equals(Token.InputStream)) { int templateDelimiterSize = 1; if (_templateToken.Type == GroupParser.BIGSTRING || _templateToken.Type == GroupParser.BIGSTRING_NO_NL) { templateDelimiterSize = 2; } line += _templateToken.Line - 1; charPos += _templateToken.CharPositionInLine + templateDelimiterSize; } } string filepos = string.Format("{0}:{1}", line, charPos); if (_sourceName != null) { return(string.Format("{0} {1}: {2}", _sourceName, filepos, string.Format(Error.Message, Arg, Arg2))); } return(string.Format("{0}: {1}", filepos, string.Format(Error.Message, Arg, Arg2))); }
public override void ReportError( RecognitionException e ) { string header = GetErrorHeader( e ); string message = GetErrorMessage( e, TokenNames ); message = string.Format( "{0}: {1}: {2}", "$...$ chunk lexer error", header, message ); self.Error( message, e ); }
public GrammarSyntaxMessage( int msgID, Grammar grammar, IToken offendingToken, RecognitionException exception ) : this(msgID, grammar, offendingToken, null, exception) { }
public override string ToString() { RecognitionException re = (RecognitionException)Cause; int line = re.Line; int charPos = re.CharPositionInLine; if (_templateToken != null) { int templateDelimiterSize = 1; if (_templateToken.Type == GroupParser.BIGSTRING) { templateDelimiterSize = 2; } line += _templateToken.Line - 1; charPos += _templateToken.CharPositionInLine + templateDelimiterSize; } string filepos = line + ":" + charPos; if (_sourceName != null) { return(_sourceName + " " + filepos + ": " + string.Format(Error.Message, _message)); } return(filepos + ": " + string.Format(Error.Message, _message)); }
public override void ReportError(Antlr.Runtime.RecognitionException e) { _errors.Add(new ErrorInfo { Text = GetErrorHeader(e) + " " + GetErrorMessage(e, TokenNames) }); }
public void TestNoWildcardAsRootError() /*throws Exception*/ { ErrorQueue equeue = new ErrorQueue(); ErrorManager.SetErrorListener(equeue); string treeGrammar = "tree grammar TP;\n" + "options {output=AST;}\n" + "a : ^(. INT) \n" + " ;\n"; Grammar g = new Grammar(treeGrammar); AntlrTool antlr = newTool(); antlr.SetOutputDirectory(null); // write to /dev/null CodeGenerator generator = new CodeGenerator(antlr, g, "Java"); g.CodeGenerator = generator; generator.GenRecognizer(); Assert.AreEqual(1, equeue.errors.Count, "unexpected errors: " + equeue); int expectedMsgID = ErrorManager.MSG_WILDCARD_AS_ROOT; object expectedArg = null; RecognitionException expectedExc = null; GrammarSyntaxMessage expectedMessage = new GrammarSyntaxMessage(expectedMsgID, g, null, expectedArg, expectedExc); checkError(equeue, expectedMessage); }
public GrammarSyntaxMessage(int msgID, Grammar grammar, IToken offendingToken, RecognitionException exception) : this(msgID, grammar, offendingToken, null, exception) { }
public override string ToString() { RecognitionException re = (RecognitionException)Cause; int line = 0; int charPos = -1; if (token != null) { line = token.Line; charPos = token.CharPositionInLine; if (templateToken != null) { int templateDelimiterSize = 1; if (templateToken.Type == GroupParser.BIGSTRING) { templateDelimiterSize = 2; } line += templateToken.Line - 1; charPos += templateToken.CharPositionInLine + templateDelimiterSize; } } string filepos = string.Format("{0}:{1}", line, charPos); if (srcName != null) { return(string.Format("{0} {1}: {2}", srcName, filepos, string.Format(Error.Message, Arg, Arg2))); } return(string.Format("{0}: {1}", filepos, string.Format(Error.Message, Arg, Arg2))); }
public override string ToString() { RecognitionException re = (RecognitionException)Cause; int line = 0; int charPos = -1; if (token != null) { line = token.Line; charPos = token.CharPositionInLine; } else if (re != null) { line = re.Line; charPos = re.CharPositionInLine; } string filepos = line + ":" + charPos; if (srcName != null) { return(srcName + " " + filepos + ": " + string.Format(Error.Message, Arg, Arg2)); } return(filepos + ": " + string.Format(Error.Message, Arg, Arg2)); }
public void RecognitionException(RecognitionException e) { for (int i = 0; i < listeners.Count; i++) { IDebugEventListener listener = (IDebugEventListener)listeners[i]; listener.RecognitionException(e); } }
public override void ReportError(RecognitionException e) { string header = GetErrorHeader(e); string message = GetErrorMessage(e, TokenNames); message = string.Format("{0}: {1}: {2}", "$...$ chunk lexer error", header, message); self.Error(message, e); }
public virtual void SyntaxError(ErrorType etype, string fileName, Antlr.Runtime.IToken token, Antlr.Runtime.RecognitionException antlrException, params object[] args) { ANTLRMessage msg = new GrammarSyntaxMessage(etype, fileName, token, antlrException, args); Emit(etype, msg); }
override public void RecognitionException(RecognitionException e) { if (backtracking > 0) { return; } ParseTree ruleNode = (ParseTree)callStack.Peek(); ParseTree errorNode = Create(e); ruleNode.AddChild(errorNode); }
public GrammarSyntaxMessage( int msgID, Grammar grammar, IToken offendingToken, Object arg, RecognitionException exception ) : base(msgID, arg, null) { this.offendingToken = offendingToken; this.exception = exception; this.g = grammar; }
public GrammarSyntaxMessage(int msgID, Grammar grammar, IToken offendingToken, Object arg, RecognitionException exception) : base(msgID, arg, null) { this.offendingToken = offendingToken; this.exception = exception; this.g = grammar; }
public static void SyntaxError(int msgID, Grammar grammar, IToken token, Object arg, RecognitionException re) { GetErrorState().errors++; GetErrorState().errorMsgIDs.Add(msgID); GetErrorListener().Error( new GrammarSyntaxMessage(msgID, grammar, token, arg, re) ); }
public override void ReportError( RecognitionException e ) { StringTemplateGroup group = self.Group; if ( group == StringTemplate.defaultGroup ) { self.Error( "template parse error; template context is " + self.GetEnclosingInstanceStackString(), e ); } else { self.Error( "template parse error in group " + self.Group.Name + " line " + self.GroupFileLine + "; template context is " + self.GetEnclosingInstanceStackString(), e ); } }
public override void ReportError(RecognitionException e) { if (groupI != null) { groupI.Error("template group interface parse error", e); } else { Console.Error.WriteLine("template group interface parse error: " + e); e.PrintStackTrace(Console.Error); } }
public override void ReportError( RecognitionException e ) { if ( groupI != null ) { groupI.Error( "template group interface parse error", e ); } else { Console.Error.WriteLine( "template group interface parse error: " + e ); e.PrintStackTrace( Console.Error ); } }
public override void DisplayRecognitionError(string[] tokenNames, RecognitionException e) { string msg = GetParserErrorMessage(this, e); if (paraphrases.Count > 0) { string paraphrase = paraphrases.Peek(); msg = msg + " while " + paraphrase; } //List stack = getRuleInvocationStack(e, this.getClass().getName()); //msg += ", rule stack = " + stack; tool.errMgr.SyntaxError(ErrorType.SYNTAX_ERROR, SourceName, e.Token, e, msg); }
public override void ReportError(RecognitionException e) { StringTemplateGroup group = self.Group; if (group == StringTemplate.defaultGroup) { self.Error("template parse error; template context is " + self.GetEnclosingInstanceStackString(), e); } else { self.Error("template parse error in group " + self.Group.Name + " line " + self.GroupFileLine + "; template context is " + self.GetEnclosingInstanceStackString(), e); } }
public override void DisplayRecognitionError(string[] tokenNames, Antlr.Runtime.RecognitionException e) { var sb = new StringBuilder(); sb.AppendLine("There was a problem with the json input during syntactical analysis and it cannot be parsed. Here is some more info:"); sb.AppendLine("----"); sb.AppendLine(e.Message); sb.AppendLine("region: " + e.Input.ToString()); sb.AppendLine("line: " + e.Line); sb.AppendLine("col: " + e.CharPositionInLine); throw new JsonException(sb.ToString(), e); }
public GrammarSyntaxMessage(ErrorType etype, string fileName, IToken offendingToken, RecognitionException antlrException, params object[] args) : base(etype, antlrException, offendingToken, args) { this.fileName = fileName; this.offendingToken = offendingToken; if (offendingToken != null) { line = offendingToken.Line; charPosition = offendingToken.CharPositionInLine; } }
public override void ReportError(RecognitionException e) { if (_group != null) { string header = GetErrorHeader(e); string message = GetErrorMessage(e, TokenNames); message = string.Format("{0}: {1}: {2}", "template group parse error", header, message); _group.Error(message, e); } else { Console.Error.WriteLine("template group parse error: " + e); e.PrintStackTrace(Console.Error); } }
public override void ReportError( RecognitionException e ) { if ( _group != null ) { string header = GetErrorHeader( e ); string message = GetErrorMessage( e, TokenNames ); message = string.Format( "{0}: {1}: {2}", "template group parse error", header, message ); _group.Error( message, e ); } else { Console.Error.WriteLine( "template group parse error: " + e ); e.PrintStackTrace( Console.Error ); } }
public override void RecognitionException(RecognitionException e) { StringBuilder buf = new StringBuilder(50); buf.Append("exception\t"); buf.Append(e.GetType().FullName); // dump only the data common to all exceptions for now buf.Append("\t"); buf.Append(e.Index); buf.Append("\t"); buf.Append(e.Line); buf.Append("\t"); buf.Append(e.CharPositionInLine); Transmit(buf.ToString()); }
public virtual string GetParserErrorMessage(Parser parser, RecognitionException e) { string msg; if (e is NoViableAltException) { string name = parser.GetTokenErrorDisplay(e.Token); msg = name + " came as a complete surprise to me"; } else if (e is v4ParserException) { msg = ((v4ParserException)e).msg; } else { msg = parser.GetErrorMessage(e, parser.TokenNames); } return msg; }
public virtual string GetParserErrorMessage(Parser parser, RecognitionException e) { string msg; if (e is NoViableAltException) { string name = parser.GetTokenErrorDisplay(e.Token); msg = name + " came as a complete surprise to me"; } else if (e is v4ParserException) { msg = ((v4ParserException)e).msg; } else { msg = parser.GetErrorMessage(e, parser.TokenNames); } return(msg); }
public override void ReportError(RecognitionException ex) { IToken token = null; if (ex is MismatchedTokenException) { token = ((MismatchedTokenException)ex).Token; } else if (ex is NoViableAltException) { token = ((NoViableAltException)ex).Token; } ErrorManager.SyntaxError( ErrorManager.MSG_SYNTAX_ERROR, grammar, token, "codegen: " + ex.ToString(), ex); }
override public void RecognitionException(RecognitionException e) { if ( backtracking>0 ) return; ParseTree ruleNode = (ParseTree)callStack.Peek(); ParseTree errorNode = Create(e); ruleNode.AddChild(errorNode); }
public void RecognitionException(RecognitionException e) { listener.RecognitionException(e); }
public override void ReportError(Antlr.Runtime.RecognitionException e) { throw new UnexpectedTokenSaqlException(e); }
public static void SyntaxError( int msgID, Grammar grammar, IToken token, Object arg, RecognitionException re ) { GetErrorState().errors++; GetErrorState().errorMsgIDs.Add( msgID ); GetErrorListener().Error( new GrammarSyntaxMessage( msgID, grammar, token, arg, re ) ); }
public override void ReportError( RecognitionException ex ) { IToken token = null; if ( ex is MismatchedTokenException ) { token = ( (MismatchedTokenException)ex ).Token; } else if ( ex is NoViableAltException ) { token = ( (NoViableAltException)ex ).Token; } ErrorManager.SyntaxError( ErrorManager.MSG_SYNTAX_ERROR, grammar, token, "codegen: " + ex.ToString(), ex ); }
public override void DisplayRecognitionError(string[] tokenNames, RecognitionException e) { string msg = GetErrorMessage(e, tokenNames); tool.errMgr.SyntaxError(ErrorType.SYNTAX_ERROR, SourceName, e.Token, e, msg); }
public GrammarASTErrorNode(ITokenStream input, IToken start, IToken stop, RecognitionException e) { @delegate = new CommonErrorNode(input, start, stop, e); }
public override object ErrorNode(Antlr.Runtime.ITokenStream input, Antlr.Runtime.IToken start, Antlr.Runtime.IToken stop, Antlr.Runtime.RecognitionException e) { return(new LSLErrorNode(input, start, stop, e)); }
public void RecognitionException(Antlr.Runtime.RecognitionException e) { Console.WriteLine("RecognitionException {0} {1} {2}", e.Line, e.Message, e.Index); }
public override void ReportError( RecognitionException e ) { self.Error( "<...> chunk lexer error", e ); }
public override void RecognitionException(RecognitionException e) { numberReportedErrors++; }
public override void ReportError(RecognitionException e) { self.Error("<...> chunk lexer error", e); }
public ParseErrorEventArgs(Antlr.Runtime.RecognitionException exception) { this.exception = exception; }