상속: RecognitionException
예제 #1
0
        /// <summary>
        /// This is called by
        /// <see cref="ReportError(Parser, RecognitionException)">ReportError(Parser, RecognitionException)
        ///     </see>
        /// when the exception is a
        /// <see cref="NoViableAltException">NoViableAltException</see>
        /// .
        /// </summary>
        /// <seealso cref="ReportError(Parser, RecognitionException)">ReportError(Parser, RecognitionException)
        ///     </seealso>
        /// <param name="recognizer">the parser instance</param>
        /// <param name="e">the recognition exception</param>
        protected internal virtual void ReportNoViableAlternative(Parser recognizer, NoViableAltException
                                                                  e)
        {
            ITokenStream tokens = ((ITokenStream)recognizer.InputStream);
            string       input;

            if (tokens is ITokenStream)
            {
                if (e.GetStartToken().Type == TokenConstants.Eof)
                {
                    input = "<EOF>";
                }
                else
                {
                    input = tokens.GetText(e.GetStartToken(), e.OffendingToken);
                }
            }
            else
            {
                input = "<unknown input>";
            }
            string msg = "no viable alternative at input " + EscapeWSAndQuote(input);

            NotifyErrorListeners(recognizer, msg, e);
        }
예제 #2
0
 /// <summary>
 /// This is called by
 /// <see cref="ReportError(Parser, RecognitionException)"/>
 /// when the exception is a
 /// <see cref="NoViableAltException"/>
 /// .
 /// </summary>
 /// <seealso cref="ReportError(Parser, RecognitionException)"/>
 /// <param name="recognizer">the parser instance</param>
 /// <param name="e">the recognition exception</param>
 protected internal virtual void ReportNoViableAlternative(Parser recognizer, NoViableAltException e)
 {
     ITokenStream tokens = ((ITokenStream)recognizer.InputStream);
     string input;
     if (tokens != null)
     {
         if (e.StartToken.Type == TokenConstants.Eof)
         {
             input = "<EOF>";
         }
         else
         {
             input = tokens.GetText(e.StartToken, e.OffendingToken);
         }
     }
     else
     {
         input = "<unknown input>";
     }
     string msg = "no viable alternative at input " + EscapeWSAndQuote(input);
     NotifyErrorListeners(recognizer, msg, e);
 }