Exemplo n.º 1
0
        private IReceiver <Msg> RecoverFromError(Msg currentInput)
        {
            if (currentInput.Id == PredefinedTokens.Eoi)
            {
                if (!isVerifier)
                {
                    logging.Write(
                        new LogEntry
                    {
                        Severity  = Severity.Error,
                        Message   = "Unexpected end of file.",
                        Location  = currentInput.Location,
                        HLocation = currentInput.HLocation,
                    });
                }

                return(null);
            }

            this.producer = producer.GetErrorRecoveryProducer();

            IReceiver <Msg> result = new LocalCorrectionErrorRecovery(grammar, this, logging);

            if (priorInput != null)
            {
                stateStack.Undo(1);
                result = result.Next(priorInput);
            }
            else
            {
                stateStack.Undo(0);
            }

            return(result.Next(currentInput));
        }