public void ReportError(RecognitionException e)
		{
			ReportError( e.ToString() );
			_recognitionExceptions.Add( e );
			if ( log.IsDebugEnabled ) {
				log.Debug( e.ToString(), e );
			}
		}
Beispiel #2
0
 public SyntaxErrorException(string message, RecognitionException innerException, IToken offendingSymbol, int line, int position)
     : base(message, innerException)
 {
     _token    = offendingSymbol;
     _line     = line;
     _position = position;
     Debug.WriteLine(innerException.ToString());
     Debug.WriteLine("Token: {0} (L{1}C{2})", offendingSymbol.Text, line, position);
 }
        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,
                "assign.types: " + ex.ToString(),
                ex);
        }
        public override void ReportError( RecognitionException ex )
        {
            if ( inTest > 0 )
                throw 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,
                "buildnfa: " + ex.ToString(),
                ex );
        }
 public override void SyntaxError([NotNull] IRecognizer recognizer, [Nullable] IToken offendingSymbol, int line, int charPositionInLine, [NotNull] string msg, [Nullable] RecognitionException e)
 {
     Errors.Add(string.Format("Syntax error in line {0},{1} at {2} with message:{2}", line.ToString(), charPositionInLine.ToString(), offendingSymbol.Text, e?.ToString()));
     base.SyntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
 }
 public override string ToString()
 {
     return(recog.ToString());
 }
Beispiel #7
0
        public static string GetErrorMessage(RecognitionException recognitionException)
        {
            var message = recognitionException.Message;

            if (message.EndsWith("."))
            {
                // strip ending period from message
                message = message.Substring(0, message.Length - 1);
            }

            if (message.Length > 0)
            {
                message = message + " ";
            }

            var result = message + (recognitionException.ApproximateLineInfo ? "near" : "at") + " line " + recognitionException.Line + " column " + (recognitionException.CharPositionInLine + 1) + " \"" + recognitionException.ToString() + "\"";

            return(result);
        }