public new bool Load(string Path) { bool flag2; SimpleDB.Reader cGT = new SimpleDB.Reader(); this.Clear(); cGT.Open(Path); string str = cGT.Header(); if (str == "GOLD Parser Tables/v1.0") { flag2 = this.LoadVer1(cGT); } else if (str == "GOLD Parser Tables/v5.0") { flag2 = this.LoadVer5(cGT); } else { flag2 = false; } this.ComputeCGTMetadata(); cGT.Close(); return(flag2); }
private static void LoadMapping() { SimpleDB.Reader reader = new SimpleDB.Reader(); try { reader.Open("mapping.dat"); if (Operators.CompareString(reader.Header(), "GOLD Character Mapping", true) != 0) { //BuilderApp.Log.Add(SysLogSection.Internal, SysLogAlert.Critical, "The file 'mapping.dat' is invalid."); } else { while (!reader.EndOfFile()) { reader.GetNextRecord(); string str = reader.RetrieveString(); int uppercaseCode = reader.RetrieveInt16(); int lowercaseCode = reader.RetrieveInt16(); string left = str; if (Operators.CompareString(left, "C", true) == 0) { AddCase(uppercaseCode, lowercaseCode, ""); } else if (Operators.CompareString(left, "W", true) == 0) { AddWin1252(uppercaseCode, lowercaseCode); } } reader.Close(); } } catch (Exception exception1) { //ProjectData.SetProjectError(exception1); Exception exception = exception1; //BuilderApp.Log.Add(SysLogSection.Internal, SysLogAlert.Critical, exception.Message); //ProjectData.ClearProjectError(); } }
private bool LoadVer5(SimpleDB.Reader EGT) { bool flag2; try { flag2 = true; while (!(EGT.EndOfFile() | !flag2)) { GroupBuild build; int num3; int num4; CharacterSetBuild build2; int num5; int num7; int num8; int num10; int num14; int num15; GroupBuild build3; int num17; EGT.GetNextRecord(); ParseTables.EGTRecord record = (ParseTables.EGTRecord)EGT.RetrieveByte(); switch (((byte)(((int)record) - 0x44))) { case 0: { num10 = EGT.RetrieveInt16(); bool flag3 = EGT.RetrieveBoolean(); int num9 = EGT.RetrieveInt16(); EGT.RetrieveEntry(); if (!flag3) { goto Label_0423; } base.m_DFA[num10] = new FAStateBuild((SymbolBuild)base.m_Symbol[num9]); goto Label_0483; } case 5: { base.m_DFA.InitialState = (short)EGT.RetrieveInt16(); base.m_LALR.InitialState = (short)EGT.RetrieveInt16(); continue; } case 8: num14 = EGT.RetrieveInt16(); EGT.RetrieveEntry(); base.m_LALR[num14] = new LRStateBuild(); goto Label_0506; case 14: { num7 = EGT.RetrieveInt16(); int num6 = EGT.RetrieveInt16(); EGT.RetrieveEntry(); base.m_Production[num7] = new ProductionBuild((SymbolBuild)base.m_Symbol[num6], (short)num7); goto Label_03C0; } case 15: { int tableIndex = EGT.RetrieveInt16(); string name = EGT.RetrieveString(); SymbolType type = (SymbolType)EGT.RetrieveInt16(); base.m_Symbol[tableIndex] = new SymbolBuild(name, type, tableIndex); continue; } case 0x1f: build2 = new CharacterSetBuild(); num5 = EGT.RetrieveInt16(); EGT.RetrieveInt16(); EGT.RetrieveInt16(); EGT.RetrieveEntry(); goto Label_0323; case 0x23: build = new GroupBuild(); build3 = build; num3 = EGT.RetrieveInt16(); build3.Name = EGT.RetrieveString(); build3.Container = base.m_Symbol[EGT.RetrieveInt16()]; build3.Start = base.m_Symbol[EGT.RetrieveInt16()]; build3.End = base.m_Symbol[EGT.RetrieveInt16()]; build3.Advance = (AdvanceMode)EGT.RetrieveInt16(); build3.Ending = (EndingMode)EGT.RetrieveInt16(); EGT.RetrieveEntry(); num17 = EGT.RetrieveInt16(); num4 = 1; goto Label_029B; case 0x2c: { EGT.RetrieveInt16(); string str = EGT.RetrieveString(); string str2 = EGT.RetrieveString(); base.m_Properties.Add(str, str2); continue; } case 0x30: { base.m_Symbol = new SymbolBuildList(EGT.RetrieveInt16()); base.m_CharSet = new CharacterSetBuildList(EGT.RetrieveInt16()); base.m_Production = new ProductionBuildList(EGT.RetrieveInt16()); base.m_DFA = new FAStateBuildList(EGT.RetrieveInt16()); base.m_LALR = new LRStateBuildList(EGT.RetrieveInt16()); base.m_Group = new GroupBuildList(EGT.RetrieveInt16()); continue; } default: goto Label_0517; } Label_0281: build3.Nesting.Add(EGT.RetrieveInt16()); num4++; Label_029B: if (num4 <= num17) { goto Label_0281; } build3 = null; build.Container.Group = build; build.Start.Group = build; build.End.Group = build; base.m_Group[num3] = build; continue; Label_030E: build2.AddRange(EGT.RetrieveInt16(), EGT.RetrieveInt16()); Label_0323: if (!EGT.RecordComplete()) { goto Label_030E; } build2.TableIndex = num5; base.m_CharSet[num5] = build2; continue; Label_0392: num8 = EGT.RetrieveInt16(); base.m_Production[num7].Handle().Add(base.m_Symbol[num8]); Label_03C0: if (!EGT.RecordComplete()) { goto Label_0392; } continue; Label_0423: base.m_DFA[num10] = new FAStateBuild(); Label_0483: while (!EGT.RecordComplete()) { int num11 = EGT.RetrieveInt16(); int target = EGT.RetrieveInt16(); EGT.RetrieveEntry(); base.m_DFA[num10].Edges().Add(new FAEdgeBuild((CharacterSetBuild)base.m_CharSet[num11], target)); } continue; Label_04BC: num15 = EGT.RetrieveInt16(); int num13 = EGT.RetrieveInt16(); int num16 = EGT.RetrieveInt16(); EGT.RetrieveEntry(); base.m_LALR[num14].Add(new LRAction(base.m_Symbol[num15], (LRActionType)num13, (short)num16)); Label_0506: if (!EGT.RecordComplete()) { goto Label_04BC; } continue; Label_0517: flag2 = false; throw new ParserException("File Error. A record of type '" + Conversions.ToString(Strings.ChrW((int)record)) + "' was read. This is not a valid code."); } EGT.Close(); } catch (Exception exception1) { Exception inner = exception1; throw new ParserException(inner.Message, inner, "LoadTables"); } return(flag2); }
private bool LoadVer5(SimpleDB.Reader EGT) { bool flag2; try { flag2 = true; while (!(EGT.EndOfFile() | !flag2)) { Group group; int num3; int num4; CharacterSet set; int num5; int num7; int num8; int num10; int num14; int num15; Group group2; int num17; EGT.GetNextRecord(); EGTRecord record = (EGTRecord)EGT.RetrieveByte(); switch (((byte)(((int)record) - 0x44))) { case 0: { num10 = EGT.RetrieveInt16(); bool flag3 = EGT.RetrieveBoolean(); int num9 = EGT.RetrieveInt16(); EGT.RetrieveEntry(); if (!flag3) { goto Label_041A; } this.m_DFA[num10] = new FAState(this.m_Symbol[num9]); goto Label_0475; } case 5: { this.m_DFA.InitialState = (short)EGT.RetrieveInt16(); this.m_LALR.InitialState = (short)EGT.RetrieveInt16(); continue; } case 8: num14 = EGT.RetrieveInt16(); EGT.RetrieveEntry(); this.m_LALR[num14] = new LRState(); goto Label_04F8; case 14: { num7 = EGT.RetrieveInt16(); int num6 = EGT.RetrieveInt16(); EGT.RetrieveEntry(); this.m_Production[num7] = new Production(this.m_Symbol[num6], (short)num7); goto Label_03BC; } case 15: { int num = EGT.RetrieveInt16(); string name = EGT.RetrieveString(); SymbolType type = (SymbolType)EGT.RetrieveInt16(); this.m_Symbol[num] = new Symbol(name, type, (short)num); continue; } case 0x1f: set = new CharacterSet(); num5 = EGT.RetrieveInt16(); EGT.RetrieveInt16(); EGT.RetrieveInt16(); EGT.RetrieveEntry(); goto Label_0324; case 0x23: group = new Group(); group2 = group; num3 = EGT.RetrieveInt16(); group2.Name = EGT.RetrieveString(); group2.Container = this.m_Symbol[EGT.RetrieveInt16()]; group2.Start = this.m_Symbol[EGT.RetrieveInt16()]; group2.End = this.m_Symbol[EGT.RetrieveInt16()]; group2.Advance = (AdvanceMode)EGT.RetrieveInt16(); group2.Ending = (EndingMode)EGT.RetrieveInt16(); EGT.RetrieveEntry(); num17 = EGT.RetrieveInt16(); num4 = 1; goto Label_029C; case 0x2c: { EGT.RetrieveInt16(); string str = EGT.RetrieveString(); string str2 = EGT.RetrieveString(); this.m_Properties.Add(str, str2); continue; } case 0x30: { this.m_Symbol = new SymbolList(EGT.RetrieveInt16()); this.m_CharSet = new CharacterSetList(EGT.RetrieveInt16()); this.m_Production = new ProductionList(EGT.RetrieveInt16()); this.m_DFA = new FAStateList(EGT.RetrieveInt16()); this.m_LALR = new LRStateList(EGT.RetrieveInt16()); this.m_Group = new GroupList(EGT.RetrieveInt16()); continue; } default: goto Label_0509; } Label_0282: group2.Nesting.Add(EGT.RetrieveInt16()); num4++; Label_029C: if (num4 <= num17) { goto Label_0282; } group2 = null; group.Container.Group = group; group.Start.Group = group; group.End.Group = group; this.m_Group[num3] = group; continue; Label_030F: set.AddRange(EGT.RetrieveInt16(), EGT.RetrieveInt16()); Label_0324: if (!EGT.RecordComplete()) { goto Label_030F; } set.TableIndex = num5; this.m_CharSet[num5] = set; continue; Label_038E: num8 = EGT.RetrieveInt16(); this.m_Production[num7].Handle().Add(this.m_Symbol[num8]); Label_03BC: if (!EGT.RecordComplete()) { goto Label_038E; } continue; Label_041A: this.m_DFA[num10] = new FAState(); Label_0475: while (!EGT.RecordComplete()) { int num11 = EGT.RetrieveInt16(); int target = EGT.RetrieveInt16(); EGT.RetrieveEntry(); this.m_DFA[num10].Edges().Add(new FAEdge(this.m_CharSet[num11], target)); } continue; Label_04AE: num15 = EGT.RetrieveInt16(); int num13 = EGT.RetrieveInt16(); int num16 = EGT.RetrieveInt16(); EGT.RetrieveEntry(); this.m_LALR[num14].Add(new LRAction(this.m_Symbol[num15], (LRActionType)num13, (short)num16)); Label_04F8: if (!EGT.RecordComplete()) { goto Label_04AE; } continue; Label_0509: flag2 = false; throw new Exception("File Error. A record of type '" + Conversions.ToString(Strings.ChrW((int)record)) + "' was read. This is not a valid code."); } EGT.Close(); } catch (Exception exception1) { Exception exception = exception1; throw exception; } return(flag2); }