public virtual void MatchRange(int a, int b) { if (input.LA(1) < a || input.LA(1) > b) { if (state.backtracking > 0) { state.failed = true; return; } MismatchedRangeException mre = new MismatchedRangeException(a, b, input); Recover(mre); throw mre; } input.Consume(); state.failed = false; }
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); }
public virtual void MatchRange(int a, int b) { if (this.input.LA(1) < a || this.input.LA(1) > b) { if (this.state.backtracking > 0) { this.state.failed = true; } else { MismatchedRangeException mismatchedRangeException = new MismatchedRangeException(a, b, (IIntStream)this.input); this.Recover((RecognitionException)mismatchedRangeException); throw mismatchedRangeException; } } else { this.input.Consume(); this.state.failed = false; } }
public override string GetErrorMessage(RecognitionException e, string[] tokenNames) { string str; if (e is MismatchedTokenException) { MismatchedTokenException mismatchedTokenException = (MismatchedTokenException)e; str = "mismatched character " + this.GetCharErrorDisplay(e.Character) + " expecting " + this.GetCharErrorDisplay(mismatchedTokenException.Expecting); } else if (e is NoViableAltException) { str = "no viable alternative at character " + this.GetCharErrorDisplay(e.Character); } else if (e is EarlyExitException) { str = "required (...)+ loop did not match anything at character " + this.GetCharErrorDisplay(e.Character); } else if (e is MismatchedNotSetException) { MismatchedNotSetException mismatchedNotSetException = (MismatchedNotSetException)e; str = "mismatched character " + this.GetCharErrorDisplay(e.Character) + " expecting set " + (object)mismatchedNotSetException.Expecting; } else if (e is MismatchedSetException) { MismatchedSetException mismatchedSetException = (MismatchedSetException)e; str = "mismatched character " + this.GetCharErrorDisplay(e.Character) + " expecting set " + (object)mismatchedSetException.Expecting; } else if (e is MismatchedRangeException) { MismatchedRangeException mismatchedRangeException = (MismatchedRangeException)e; str = "mismatched character " + this.GetCharErrorDisplay(e.Character) + " expecting set " + this.GetCharErrorDisplay(mismatchedRangeException.A) + ".." + this.GetCharErrorDisplay(mismatchedRangeException.B); } else { str = base.GetErrorMessage(e, tokenNames); } return(str); }
public virtual void MatchRange(int a, int b) { if ((this.input.LA(1) < a) || (this.input.LA(1) > b)) { if (base.state.backtracking > 0) { base.state.failed = true; return; } MismatchedRangeException re = new MismatchedRangeException(a, b, this.input); this.Recover(re); throw re; } this.input.Consume(); base.state.failed = false; }