private void LoadEGT(BinaryReader reader) { using (EGTReader egtReader = new EGTReader(reader)) { while (egtReader.GetNextRecord()) { switch (egtReader.ReadRecordType()) { case EGTRecord.Property: GrammarProperties.SetProperty(egtReader.ReadGrammarProperty()); break; case EGTRecord.TableCounts: GrammarTables = egtReader.ReadGrammarTables(); break; case EGTRecord.InitialStates: //DFA, LALR ushort dfaState = egtReader.ReadUInt16(); ushort lalrState = egtReader.ReadUInt16(); Debug.Assert(dfaState == 0, "The initial DFA State is not 0!"); Debug.Assert(lalrState == 0, "The initial LALR State is not 0!"); break; case EGTRecord.Symbol: Symbol sym = egtReader.ReadSymbol(); GrammarTables.Symbols[sym.TableIndex] = sym; break; case EGTRecord.Group: Group group = egtReader.ReadGroup(); GrammarTables.Groups[group.TableIndex] = group; break; case EGTRecord.CharRanges: CharacterSet charSet = egtReader.ReadCharacterSet(); GrammarTables.CharacterSets[charSet.Index] = charSet; break; case EGTRecord.Production: Production prod = egtReader.ReadProduction(); GrammarTables.Productions[prod.TableIndex] = prod; break; case EGTRecord.DFAState: FAState faState = egtReader.ReadFAState(); GrammarTables.FAStates[faState.TableIndex] = faState; break; case EGTRecord.LRState: LRActionList actionList = egtReader.ReadLRActionList(); GrammarTables.LRActionLists[actionList.Index] = actionList; break; } } } }
internal LRActionList ReadLRActionList() { ushort index = ReadUInt16(); //Reserved; skip ReadEntry(); LRActionList actionList = new LRActionList(index); while (!IsRecordComplete()) { actionList.Add(ReadLRAction()); } return(actionList); }
internal LRActionList ReadLRActionList() { ushort index = ReadUInt16(); //Reserved; skip ReadEntry(); LRActionList actionList = new LRActionList(index); while (!IsRecordComplete()) { actionList.Add(ReadLRAction()); } return actionList; }