protected virtual void NoViableAlt(int s, IIntStream input) { if (recognizer.state.backtracking > 0) { recognizer.state.failed = true; return; } NoViableAltException nvae = new NoViableAltException(Description, decisionNumber, s, input); Error(nvae); throw nvae; }
public override string GetErrorMessage(RecognitionException e, string[] tokenNames) { string msg = null; if (e is MismatchedTokenException) { MismatchedTokenException mte = (MismatchedTokenException)e; msg = "mismatched character " + GetCharErrorDisplay(e.Character) + " expecting " + GetCharErrorDisplay(mte.Expecting); } else if (e is NoViableAltException) { NoViableAltException nvae = (NoViableAltException)e; // for development, can add "decision=<<"+nvae.grammarDecisionDescription+">>" // and "(decision="+nvae.decisionNumber+") and // "state "+nvae.stateNumber msg = "no viable alternative at character " + GetCharErrorDisplay(e.Character); } else if (e is EarlyExitException) { EarlyExitException eee = (EarlyExitException)e; // for development, can add "(decision="+eee.decisionNumber+")" msg = "required (...)+ loop did not match anything at character " + GetCharErrorDisplay(e.Character); } else if (e is MismatchedNotSetException) { MismatchedNotSetException mse = (MismatchedNotSetException)e; msg = "mismatched character " + GetCharErrorDisplay(e.Character) + " expecting set " + mse.Expecting; } else if (e is MismatchedSetException) { MismatchedSetException mse = (MismatchedSetException)e; msg = "mismatched character " + GetCharErrorDisplay(e.Character) + " expecting set " + mse.Expecting; } else if (e is MismatchedRangeException) { MismatchedRangeException mre = (MismatchedRangeException)e; msg = "mismatched character " + GetCharErrorDisplay(e.Character) + " expecting set " + GetCharErrorDisplay(mre.A) + ".." + GetCharErrorDisplay(mre.B); } else { msg = base.GetErrorMessage(e, tokenNames); } return(msg); }
/** <summary>A hook for debugging interface</summary> */ public virtual void Error(NoViableAltException nvae) { }