Ejemplo n.º 1
0
        private bool Shift(ActionParsingTableEntry entry)
        {
            ItemSet arg1 = entry.ItemSet;
            ExpressionDefinition arg3 = entry.ExpressionDefinition;

            List <ItemSet> transitions = arg1.Transitions.Where(x => x.Key.IsEqualTo(arg3)).Select(x => x.Value).ToList();

            if (transitions.Count > 1)
            {
                throw new Exception();
            }

            ItemSet transition = transitions.First();

            if (DebugModeEnabled)
            {
                Console.WriteLine("SHIFT " + Current.ToString() + ", to" + transition.Id);
            }
            Stack.Add(transition);

            ParsingNode parsingNode = new ParsingNode()
            {
                Expression = new TerminalExpression
                {
                    TokenType = ((TerminalExpressionDefinition)arg3).TokenType,
                    Key       = ((TerminalExpressionDefinition)arg3).Key
                },
                Parser        = this,
                SubProduction = arg3.SubProduction
            };

            parsingNode.Attributes.Add(ParserConstants.Token, Current);

            ParsingNodes.Add(parsingNode);

            Current = LexicalAnalyzer.GetNextToken();

            return(true);
        }
 public override bool IsEqualTo(ExpressionDefinition definition)
 {
     return(true);
 }