コード例 #1
0
ファイル: ParseTables.cs プロジェクト: tvandijck/Frustel
        private bool LoadVer1(SimpleDB.Reader CGT)
        {
            bool flag2 = true;

            while (!(CGT.EndOfFile() | !flag2))
            {
                int num7;
                int num8;
                int num10;
                int num14;
                int num15;
                CGT.GetNextRecord();
                switch (CGT.RetrieveByte())
                {
                case 0x43:
                {
                    int          num5 = CGT.RetrieveInt16();
                    CharacterSet set  = new CharacterSet(CGT.RetrieveString())
                    {
                        TableIndex = num5
                    };
                    this.m_CharSet[num5] = set;
                    continue;
                }

                case 0x44:
                {
                    FAState state = new FAState();
                    num10 = CGT.RetrieveInt16();
                    bool flag3 = CGT.RetrieveBoolean();
                    int  num9  = CGT.RetrieveInt16();
                    CGT.RetrieveEntry();
                    if (!flag3)
                    {
                        goto Label_02D3;
                    }
                    this.m_DFA[num10] = new FAState(this.m_Symbol[num9]);
                    goto Label_0329;
                }

                case 0x49:
                {
                    this.m_DFA.InitialState  = (short)CGT.RetrieveInt16();
                    this.m_LALR.InitialState = (short)CGT.RetrieveInt16();
                    continue;
                }

                case 0x4c:
                    num14 = CGT.RetrieveInt16();
                    CGT.RetrieveEntry();
                    this.m_LALR[num14] = new LRState();
                    goto Label_03AC;

                case 80:
                {
                    this.m_Properties["Name"].Value           = CGT.RetrieveString();
                    this.m_Properties["Version"].Value        = CGT.RetrieveString();
                    this.m_Properties["Author"].Value         = CGT.RetrieveString();
                    this.m_Properties["About"].Value          = CGT.RetrieveString();
                    this.m_Properties["Case Sensitive"].Value = Conversions.ToString(CGT.RetrieveBoolean());
                    int num3 = CGT.RetrieveInt16();
                    continue;
                }

                case 0x52:
                {
                    num7 = CGT.RetrieveInt16();
                    int num6 = CGT.RetrieveInt16();
                    CGT.RetrieveEntry();
                    this.m_Production[num7] = new Production(this.m_Symbol[num6], (short)num7);
                    goto Label_026E;
                }

                case 0x53:
                {
                    int        num4 = CGT.RetrieveInt16();
                    string     name = CGT.RetrieveString();
                    SymbolType type = (SymbolType)CGT.RetrieveInt16();
                    this.m_Symbol[num4] = new Symbol(name, type, (short)num4);
                    continue;
                }

                case 0x54:
                {
                    this.m_Symbol     = new SymbolList(CGT.RetrieveInt16());
                    this.m_CharSet    = new CharacterSetList(CGT.RetrieveInt16());
                    this.m_Production = new ProductionList(CGT.RetrieveInt16());
                    this.m_DFA        = new FAStateList(CGT.RetrieveInt16());
                    this.m_LALR       = new LRStateList(CGT.RetrieveInt16());
                    continue;
                }

                default:
                    goto Label_03BD;
                }
Label_0240:
                num8 = CGT.RetrieveInt16();
                this.m_Production[num7].Handle().Add(this.m_Symbol[num8]);
Label_026E:
                if (!CGT.RecordComplete())
                {
                    goto Label_0240;
                }
                continue;
Label_02D3:
                this.m_DFA[num10] = new FAState();
Label_0329:
                while (!CGT.RecordComplete())
                {
                    int num11  = CGT.RetrieveInt16();
                    int target = CGT.RetrieveInt16();
                    CGT.RetrieveEntry();
                    this.m_DFA[num10].AddEdge(new FAEdge(this.m_CharSet[num11], target));
                }
                continue;
Label_0362:
                num15 = CGT.RetrieveInt16();
                int num13 = CGT.RetrieveInt16();
                int num16 = CGT.RetrieveInt16();
                CGT.RetrieveEntry();
                this.m_LALR[num14].Add(new LRAction(this.m_Symbol[num15], (LRActionType)num13, (short)num16));
Label_03AC:
                if (!CGT.RecordComplete())
                {
                    goto Label_0362;
                }
                continue;
Label_03BD:
                flag2 = false;
            }
            Symbol symbol3 = null;
            Symbol symbol2 = null;
            Symbol symbol  = null;
            int    num19   = this.m_Symbol.Count() - 1;

            for (int i = 0; i <= num19; i++)
            {
                Symbol symbol4 = this.m_Symbol[i];
                switch (((int)symbol4.Type))
                {
                case 2:
                    if (symbol == null)
                    {
                        symbol = symbol4;
                    }
                    break;

                case 4:
                    symbol3 = symbol4;
                    break;

                case 5:
                    symbol2 = symbol4;
                    break;
                }
            }
            if (symbol3 != null)
            {
                Group item  = new Group();
                int   num17 = this.m_Group.Add(item);
                item.TableIndex = 0;
                item.Name       = "Comment Block";
                item.Container  = symbol;
                item.Nesting.Add(item.TableIndex);
                item.Advance     = AdvanceMode.Token;
                item.Ending      = EndingMode.Closed;
                item.Start       = symbol3;
                item.End         = symbol2;
                item.Start.Group = item;
                item.End.Group   = item;
            }
            return(flag2);
        }
コード例 #2
0
ファイル: ParseTables.cs プロジェクト: tvandijck/Frustel
        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);
        }