private StateCollection CreateParserStates(CGTContent content)
        {
            rules = CreateRules(content);

            StateCollection states = new StateCollection();

            foreach (LR1StateRecord record in content.LALRStateTable)
            {
                State state = new State(record.Index);
                states.Add(state);
            }

            foreach (LR1StateRecord record in content.LALRStateTable)
            {
                State state = states[record.Index];
                foreach (ActionSubRecord subRecord in record.ActionSubRecords)
                {
                    lalr.Action action =
                        ActionFactory.CreateAction(subRecord,
                                                   states,
                                                   symbols,
                                                   rules);
                    state.Actions.Add(action);
                }
            }
            return(states);
        }
 private void Reset()
 {
     stream       = null;
     structure    = null;
     content      = null;
     dfaStates    = null;
     parserStates = null;
     symbols      = null;
     rules        = null;
 }
        private RuleCollection CreateRules(CGTContent content)
        {
            RuleCollection rules = new RuleCollection();

            foreach (RuleRecord ruleRecord in content.RuleTable)
            {
                SymbolNonterminal lhs = symbols[ruleRecord.Nonterminal] as SymbolNonterminal;
                Symbol[]          rhs = new Symbol[ruleRecord.Symbols.Count];
                for (int i = 0; i < rhs.Length; i++)
                {
                    rhs[i] = symbols[ruleRecord.Symbols[i]];
                }

                Rule rule = new Rule(ruleRecord.Index, lhs, rhs);
                rules.Add(rule);
            }
            return(rules);
        }