Esempio n. 1
0
        internal bool SaveVer5(string Path)
        {
            bool flag2;

            SimpleDB.Writer writer = new SimpleDB.Writer();
            try
            {
                short num;
                short num2;
                writer.Open(Path, "GOLD Parser Tables/v5.0");
                writer.NewRecord();
                writer.StoreByte(0x70);
                writer.StoreInt16(0);
                string name = "Name";
                writer.StoreString(name);
                writer.StoreString(this.Properties["Name"].Value);
                writer.NewRecord();
                writer.StoreByte(0x70);
                writer.StoreInt16(1);
                name = "Version";
                writer.StoreString(name);
                writer.StoreString(this.Properties["Version"].Value);
                writer.NewRecord();
                writer.StoreByte(0x70);
                writer.StoreInt16(2);
                name = "Author";
                writer.StoreString(name);
                writer.StoreString(this.Properties["Author"].Value);
                writer.NewRecord();
                writer.StoreByte(0x70);
                writer.StoreInt16(3);
                name = "About";
                writer.StoreString(name);
                writer.StoreString(this.Properties["About"].Value);
                writer.NewRecord();
                writer.StoreByte(0x70);
                writer.StoreInt16(4);
                name = "Character Set";
                writer.StoreString(name);
                writer.StoreString(this.Properties["Character Set"].Value);
                writer.NewRecord();
                writer.StoreByte(0x70);
                writer.StoreInt16(5);
                name = "Character Mapping";
                writer.StoreString(name);
                writer.StoreString(this.Properties["Character Mapping"].Value);
                writer.NewRecord();
                writer.StoreByte(0x70);
                writer.StoreInt16(6);
                name = "Generated By";
                writer.StoreString(name);
                writer.StoreString(this.Properties["Generated By"].Value);
                writer.NewRecord();
                writer.StoreByte(0x70);
                writer.StoreInt16(7);
                name = "Generated Date";
                writer.StoreString(name);
                writer.StoreString(this.Properties["Generated Date"].Value);
                writer.NewRecord();
                writer.StoreByte(0x74);
                writer.StoreInt16(this.m_Symbol.Count());
                writer.StoreInt16(this.m_CharSet.Count);
                writer.StoreInt16(this.m_Production.Count());
                writer.StoreInt16(this.m_DFA.Count);
                writer.StoreInt16(this.m_LALR.Count);
                writer.StoreInt16(this.m_Group.Count);
                writer.NewRecord();
                writer.StoreByte(0x49);
                writer.StoreInt16(this.m_DFA.InitialState);
                writer.StoreInt16(this.m_LALR.InitialState);
                short num3 = (short)(this.m_CharSet.Count - 1);
                for (num2 = 0; num2 <= num3; num2 = (short)(num2 + 1))
                {
                    NumberRangeList list = this.m_CharSet[num2].RangeList();
                    writer.NewRecord();
                    writer.StoreByte(0x63);
                    writer.StoreInt16(num2);
                    writer.StoreInt16(0);
                    writer.StoreInt16(list.Count);
                    writer.StoreEmpty();
                    short num4 = (short)(list.Count - 1);
                    num = 0;
                    while (num <= num4)
                    {
                        writer.StoreInt16(list[num].First);
                        writer.StoreInt16(list[num].Last);
                        num = (short)(num + 1);
                    }
                }
                short num5 = (short)(this.m_Symbol.Count() - 1);
                for (num2 = 0; num2 <= num5; num2 = (short)(num2 + 1))
                {
                    writer.NewRecord();
                    writer.StoreByte(0x53);
                    writer.StoreInt16(num2);
                    Symbol symbol  = this.m_Symbol[num2];
                    Symbol symbol2 = symbol;
                    name = symbol2.Name;
                    writer.StoreString(name);
                    symbol2.Name = name;
                    writer.StoreInt16((int)symbol.Type);
                    symbol = null;
                }
                short num6 = (short)(this.m_Group.Count - 1);
                for (num2 = 0; num2 <= num6; num2 = (short)(num2 + 1))
                {
                    writer.NewRecord();
                    writer.StoreByte(0x67);
                    Group group = this.m_Group[num2];
                    writer.StoreInt16(num2);
                    writer.StoreString(group.Name);
                    writer.StoreInt16(group.Container.TableIndex);
                    writer.StoreInt16(group.Start.TableIndex);
                    writer.StoreInt16(group.End.TableIndex);
                    writer.StoreInt16((int)group.Advance);
                    writer.StoreInt16((int)group.Ending);
                    writer.StoreEmpty();
                    writer.StoreInt16(group.Nesting.Count);
                    short num7 = (short)(group.Nesting.Count - 1);
                    num = 0;
                    while (num <= num7)
                    {
                        writer.StoreInt16(group.Nesting[num]);
                        num = (short)(num + 1);
                    }
                    group = null;
                }
                short num8 = (short)(this.m_Production.Count() - 1);
                for (num2 = 0; num2 <= num8; num2 = (short)(num2 + 1))
                {
                    writer.NewRecord();
                    writer.StoreByte(0x52);
                    writer.StoreInt16(num2);
                    writer.StoreInt16(this.m_Production[num2].Head.TableIndex);
                    writer.StoreEmpty();
                    short num9 = (short)(this.m_Production[num2].Handle().Count() - 1);
                    num = 0;
                    while (num <= num9)
                    {
                        writer.StoreInt16(this.m_Production[num2].Handle()[num].TableIndex);
                        num = (short)(num + 1);
                    }
                }
                short num10 = (short)(this.DFA.Count - 1);
                for (num2 = 0; num2 <= num10; num2 = (short)(num2 + 1))
                {
                    writer.NewRecord();
                    writer.StoreByte(0x44);
                    writer.StoreInt16(num2);
                    if (this.DFA[num2].Accept != null)
                    {
                        writer.StoreBoolean(true);
                        writer.StoreInt16(this.DFA[num2].Accept.TableIndex);
                    }
                    else
                    {
                        writer.StoreBoolean(false);
                        writer.StoreInt16(0);
                    }
                    writer.StoreEmpty();
                    short num11 = (short)(this.DFA[num2].Edges().Count() - 1);
                    num = 0;
                    while (num <= num11)
                    {
                        writer.StoreInt16(this.DFA[num2].Edges()[num].Characters.TableIndex);
                        writer.StoreInt16(this.DFA[num2].Edges()[num].Target);
                        writer.StoreEmpty();
                        num = (short)(num + 1);
                    }
                }
                short num12 = (short)(this.LALR.Count - 1);
                for (num2 = 0; num2 <= num12; num2 = (short)(num2 + 1))
                {
                    writer.NewRecord();
                    writer.StoreByte(0x4c);
                    writer.StoreInt16(num2);
                    writer.StoreEmpty();
                    short num13 = (short)(this.LALR[num2].Count - 1);
                    for (num = 0; num <= num13; num = (short)(num + 1))
                    {
                        writer.StoreInt16(this.LALR[num2][num].SymbolIndex());
                        writer.StoreInt16((int)this.LALR[num2][num].Type());
                        writer.StoreInt16(this.LALR[num2][num].Value());
                        writer.StoreEmpty();
                    }
                }
                writer.Close();
                flag2 = true;
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                flag2 = false;
            }
            return(flag2);
        }
Esempio n. 2
0
        internal bool SaveVer1(string Path)
        {
            short num5;
            bool  flag2;

            SimpleDB.Writer writer     = new SimpleDB.Writer();
            CharacterSet    setB       = new CharacterSet(new int[] { 0 });
            int             tableIndex = -1;
            int             num3       = -1;
            int             num        = -1;
            short           num6       = (short)(this.m_Group.Count - 1);

            for (num5 = 0; num5 <= num6; num5 = (short)(num5 + 1))
            {
                Group group = this.m_Group[num5];
                if (group.Name.ToUpper() == "COMMENT LINE")
                {
                    tableIndex = group.Start.TableIndex;
                }
                else if (group.Name.ToUpper() == "COMMENT BLOCK")
                {
                    num3 = group.Start.TableIndex;
                    num  = group.End.TableIndex;
                }
                group = null;
            }
            try
            {
                short num4;
                writer.Open(Path, "GOLD Parser Tables/v1.0");
                writer.NewRecord();
                writer.StoreByte(80);
                writer.StoreString(this.Properties["Name"].Value);
                writer.StoreString(this.Properties["Version"].Value);
                writer.StoreString(this.Properties["Author"].Value);
                writer.StoreString(this.Properties["About"].Value);
                writer.StoreBoolean(Strings.UCase(this.Properties["Case Sensitive"].Value) == "TRUE");
                writer.StoreInt16(this.StartSymbol.TableIndex);
                writer.NewRecord();
                writer.StoreByte(0x54);
                writer.StoreInt16(this.m_Symbol.Count());
                writer.StoreInt16(this.m_CharSet.Count);
                writer.StoreInt16(this.m_Production.Count());
                writer.StoreInt16(this.m_DFA.Count);
                writer.StoreInt16(this.m_LALR.Count);
                writer.NewRecord();
                writer.StoreByte(0x49);
                writer.StoreInt16(this.m_DFA.InitialState);
                writer.StoreInt16(this.m_LALR.InitialState);
                short num7 = (short)(this.m_CharSet.Count - 1);
                for (num5 = 0; num5 <= num7; num5 = (short)(num5 + 1))
                {
                    CharacterSet set = new CharacterSet(this.m_CharSet[num5]);
                    set.DifferenceWith(setB);
                    writer.NewRecord();
                    writer.StoreByte(0x43);
                    writer.StoreInt16(num5);
                    writer.StoreString(set.ToString());
                }
                short num8 = (short)(this.m_Symbol.Count() - 1);
                for (num5 = 0; num5 <= num8; num5 = (short)(num5 + 1))
                {
                    SymbolType lEGACYCommentLine;
                    Symbol     symbol = this.m_Symbol[num5];
                    switch (((int)symbol.Type))
                    {
                    case 4:
                        if (num5 != tableIndex)
                        {
                            break;
                        }
                        lEGACYCommentLine = SymbolType.LEGACYCommentLine;
                        goto Label_034D;

                    case 5:
                        if (num5 != num)
                        {
                            goto Label_033C;
                        }
                        lEGACYCommentLine = SymbolType.GroupEnd;
                        goto Label_034D;

                    default:
                        lEGACYCommentLine = symbol.Type;
                        goto Label_034D;
                    }
                    if (num5 == num3)
                    {
                        lEGACYCommentLine = SymbolType.GroupStart;
                    }
                    else
                    {
                        lEGACYCommentLine = SymbolType.Content;
                    }
                    goto Label_034D;
Label_033C:
                    lEGACYCommentLine = SymbolType.Content;
Label_034D:
                    writer.NewRecord();
                    writer.StoreByte(0x53);
                    writer.StoreInt16(num5);
                    Symbol symbol2 = symbol;
                    string name    = symbol2.Name;
                    writer.StoreString(name);
                    symbol2.Name = name;
                    writer.StoreInt16((int)lEGACYCommentLine);
                    symbol = null;
                }
                short num9 = (short)(this.m_Production.Count() - 1);
                for (num5 = 0; num5 <= num9; num5 = (short)(num5 + 1))
                {
                    writer.NewRecord();
                    writer.StoreByte(0x52);
                    writer.StoreInt16(num5);
                    writer.StoreInt16(this.m_Production[num5].Head.TableIndex);
                    writer.StoreEmpty();
                    short num10 = (short)(this.m_Production[num5].Handle().Count() - 1);
                    num4 = 0;
                    while (num4 <= num10)
                    {
                        writer.StoreInt16(this.m_Production[num5].Handle()[num4].TableIndex);
                        num4 = (short)(num4 + 1);
                    }
                }
                short num11 = (short)(this.DFA.Count - 1);
                for (num5 = 0; num5 <= num11; num5 = (short)(num5 + 1))
                {
                    writer.NewRecord();
                    writer.StoreByte(0x44);
                    writer.StoreInt16(num5);
                    if (this.DFA[num5].Accept == null)
                    {
                        writer.StoreBoolean(false);
                        writer.StoreInt16(-1);
                    }
                    else
                    {
                        writer.StoreBoolean(true);
                        writer.StoreInt16(this.DFA[num5].Accept.TableIndex);
                    }
                    writer.StoreEmpty();
                    short num12 = (short)(this.DFA[num5].Edges().Count() - 1);
                    num4 = 0;
                    while (num4 <= num12)
                    {
                        writer.StoreInt16(this.DFA[num5].Edges()[num4].Characters.TableIndex);
                        writer.StoreInt16(this.DFA[num5].Edges()[num4].Target);
                        writer.StoreEmpty();
                        num4 = (short)(num4 + 1);
                    }
                }
                short num13 = (short)(this.LALR.Count - 1);
                for (num5 = 0; num5 <= num13; num5 = (short)(num5 + 1))
                {
                    writer.NewRecord();
                    writer.StoreByte(0x4c);
                    writer.StoreInt16(num5);
                    writer.StoreEmpty();
                    short num14 = (short)(this.LALR[num5].Count - 1);
                    for (num4 = 0; num4 <= num14; num4 = (short)(num4 + 1))
                    {
                        writer.StoreInt16(this.LALR[num5][num4].SymbolIndex());
                        writer.StoreInt16((int)this.LALR[num5][num4].Type());
                        writer.StoreInt16(this.LALR[num5][num4].Value());
                        writer.StoreEmpty();
                    }
                }
                writer.Close();
                flag2 = true;
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                flag2 = false;
            }
            return(flag2);
        }