public IReceiver <Msg> Next(Msg item) { // Skip valid tokens before the error which were used for local error recovery. if (validPrefixVerifier != null) { validPrefixVerifier = validPrefixVerifier.Next(item); if (validPrefixVerifier != null) { return(this); } } var error = new Msg(PredefinedTokens.Error, null, errorLocation); // TODO: Location? if (null != exit.CloneVerifier().ForceNext(error, item)) { ReportError(); return(exit.ForceNext(error, item)); } else if (grammar.IsBeacon(item.Id) && null != exit.CloneVerifier().ForceNext(item)) { ReportError(); return(exit.ForceNext(item)); } errorLocation += item.Location; errorHLocation += item.HLocation; collectedInput.Add(item); return(this); }
public PanicModeErrorRecovery(RuntimeGrammar grammar, IPushParser exit, ILogging logging) { this.grammar = grammar; this.exit = exit; this.logging = logging; this.validPrefixVerifier = exit.CloneVerifier(); }
private bool ValidateCorrection() { IReceiver <Msg> r = exit.CloneVerifier(); int pos = 0; int minLength = currentModel.GetMinimalLength(); foreach (var msg in correction) { r = r.Next(msg); if (r == null) { return(false); } if (pos >= minLength && (PredefinedTokens.Eoi == msg.Id || grammar.IsBeacon(msg.Id))) { return(true); } ++pos; } return(true); }