Exemplo n.º 1
0
Arquivo: Cfg.cs Projeto: ph3rin/sacc
        public (Item?, ParseAction) FindTransitionOfItemOn(Item item, Symbol symbol)
        {
            var(target, action) = FindTransitionOfItemOnUnchecked(item, symbol);

            return(TransitionIsValidForItem(action, item, symbol)
                ? (target, action)
                : (null, ParseAction.MakeDiscard()));
        }
Exemplo n.º 2
0
Arquivo: Cfg.cs Projeto: ph3rin/sacc
        private (Item?, ParseAction) FindTransitionOfItemOnUnchecked(Item item, Symbol symbol)
        {
            var productionLen = item.Production.Ingredients.Length;

            if (item.DotPos < productionLen && symbol == item.Production.Ingredients[item.DotPos])
            {
                return(item.ShiftedByOne(), ParseAction.MakeShift());
            }

            if (item.DotPos >= productionLen && symbol == item.Follow)
            {
                if (symbol == Symbol.EndOfInput && item.Production.Product == Symbol.ExtendedStartSymbol)
                {
                    return(null, ParseAction.MakeAccept());
                }

                return(null, ParseAction.MakeReduce(item.Production));
            }

            return(null, ParseAction.MakeDiscard());
        }