Пример #1
0
        public LocalCorrectionErrorRecovery(
            RuntimeGrammar grammar,
            IPushParser exit,
            ILogging logging)
        {
            this.grammar = grammar;
            this.exit    = exit;
            this.logging = logging;

            this.terms = grammar
                         .EnumerateTokens()
                         .Where(t => grammar.IsTerminal(t) && t >= PredefinedTokens.Count)
                         .ToArray();
        }
Пример #2
0
        private int[] GetExpectedTokens(int state)
        {
            var result     = new List <int>();
            int tokenCount = grammar.SymbolCount;

            for (int i = 0; i != tokenCount; ++i)
            {
                var action = actionTable(state, i);
                if (action != ParserAction.FailActionCell && grammar.IsTerminal(i))
                {
                    result.Add(i);
                }
            }

            return(result.ToArray());
        }