/// <summary>
 /// Creates a new LALR parser.
 /// </summary>
 /// <param name="tokenizer">A tokenizer.</param>
 /// <param name="states">The LALR states.</param>
 /// <param name="startState">The starting state.</param>
 public LALRParser(IStringTokenizer tokenizer,
                   StateCollection states,
                   State startState,
                   SymbolCollection symbols)
 {
     this.tokenizer  = tokenizer;
     this.states     = states;
     this.startState = startState;
     this.symbols    = symbols;
     storeTokens     = StoreTokensMode.NoUserObject;
 }
Example #2
0
        private SymbolCollection CreateSymbols(CGTContent content)
        {
            SymbolCollection symbols = new SymbolCollection();

            foreach (SymbolRecord symbolRecord in content.SymbolTable)
            {
                Symbol symbol = SymbolFactory.CreateSymbol(symbolRecord);
                symbols.Add(symbol);
            }
            return(symbols);
        }
        private SymbolCollection FindExpectedTokens()
        {
            SymbolCollection symbols = new SymbolCollection();
            State            state   = stateStack.Peek();

            foreach (Action action in state.Actions)
            {
                if ((action is ShiftAction) || (action is ReduceAction) ||
                    (action is AcceptAction))
                {
                    symbols.Add(action.symbol);
                }
            }
            return(symbols);
        }