Пример #1
0
        internal override TokenParseResult Execute <T>(IParser <T> parser, T token)
        {
            bool           trim       = reduceRule.ContainsOneNonterminal && parser.CanTrim(reduceRule);
            T              head       = trim ? parser.PopToken() : parser.CreateReduction(reduceRule);
            LalrActionGoto gotoAction = parser.TopState.GetActionBySymbol(reduceRule.RuleSymbol) as LalrActionGoto;

            if (gotoAction == null)
            {
                Debug.Fail("Internal table error.");
                return(TokenParseResult.InternalError);
            }
            parser.PushTokenAndState(head, gotoAction.State);
            return(trim ? TokenParseResult.ReduceEliminated : TokenParseResult.ReduceNormal);
        }