Exemple #1
0
        public bool SaveXML5(string FileName)
        {
            bool   flag;
            string str = Strings.Space(8);

            try
            {
                int        num;
                int        num2;
                TextWriter writer = new StreamWriter(FileName, false);
                writer.WriteLine("<?GOLDParserTables version={0}5.0{0}?>", '"');
                writer.WriteLine("<Tables>");
                writer.WriteLine("{0}<Properties>", str);
                writer.WriteLine("{0}{0}<Property Index=\"0\" Name=\"Name\" Value=\"{1}\"/>", str, BuilderUtility.XMLText(this.m_Properties["Name"].Value));
                writer.WriteLine("{0}{0}<Property Index=\"1\" Name=\"Author\" Value=\"{1}\"/>", str, BuilderUtility.XMLText(this.m_Properties["Author"].Value));
                writer.WriteLine("{0}{0}<Property Index=\"2\" Name=\"Version\" Value=\"{1}\"/>", str, BuilderUtility.XMLText(this.m_Properties["Version"].Value));
                writer.WriteLine("{0}{0}<Property Index=\"3\" Name=\"About\" Value=\"{1}\"/>", str, BuilderUtility.XMLText(this.m_Properties["About"].Value));
                writer.WriteLine("{0}{0}<Property Index=\"4\" Name=\"Character Set\" Value=\"{1}\"/>", str, BuilderUtility.XMLText(this.m_Properties["Character Set"].Value));
                writer.WriteLine("{0}{0}<Property Index=\"5\" Name=\"Character Mapping\" Value=\"{1}\"/>", str, BuilderUtility.XMLText(this.m_Properties["Character Mapping"].Value));
                writer.WriteLine("{0}{0}<Property Index=\"6\" Name=\"Generated By\" Value=\"{1}\"/>", str, BuilderUtility.XMLText(this.m_Properties["Generated By"].Value));
                writer.WriteLine("{0}{0}<Property Index=\"7\" Name=\"Generated Date\" Value=\"{1}\"/>", str, this.m_Properties["Generated Date"].Value);
                writer.WriteLine("{0}</Properties>", str);
                writer.WriteLine("{0}<m_Symbol Count=\"{1}\">", str, this.m_Symbol.Count());
                int num3 = this.m_Symbol.Count() - 1;
                for (num2 = 0; num2 <= num3; num2++)
                {
                    Symbol symbol = this.m_Symbol[num2];
                    writer.WriteLine("{0}{0}<Symbol Index=\"{1}\" Name=\"{2}\" Type=\"{3}\"/>", new object[] { str, num2, BuilderUtility.XMLText(symbol.Name), Conversion.Int((int)symbol.Type) });
                    symbol = null;
                }
                writer.WriteLine("{0}</m_Symbol>", str);
                writer.WriteLine("{0}<m_Group Count=\"{1}\">", str, this.m_Group.Count);
                int num4 = this.m_Group.Count - 1;
                for (num2 = 0; num2 <= num4; num2++)
                {
                    Group group = this.m_Group[num2];
                    writer.WriteLine("{0}{0}<Group Index=\"{1}\" Name=\"{2}\" ContainerIndex=\"{3}\" StartIndex=\"{4}\" EndIndex=\"{5}\" Advance=\"{6}\" Ending=\"{7}\" NestingCount=\"{8}\">", new object[] { str, num2, BuilderUtility.XMLText(group.Name), group.Container.TableIndex, group.Start.TableIndex, group.End.TableIndex, Conversion.Int((int)group.Advance), Conversion.Int((int)group.Ending), group.Nesting.Count });
                    int num5 = group.Nesting.Count - 1;
                    num = 0;
                    while (num <= num5)
                    {
                        writer.WriteLine("{0}{0}{0}<NestedGroup Index=\"{1}\"/>", str, group.Nesting[num]);
                        num++;
                    }
                    writer.WriteLine("{0}{0}</Group>", str);
                    group = null;
                }
                writer.WriteLine("{0}</m_Group>", str);
                writer.WriteLine("{0}<m_Production Count=\"{1}\">", str, this.m_Production.Count());
                int num6 = this.m_Production.Count() - 1;
                for (num2 = 0; num2 <= num6; num2++)
                {
                    Production production = this.m_Production[num2];
                    writer.WriteLine("{0}{0}<Production Index=\"{1}\" NonTerminalIndex=\"{2}\" SymbolCount=\"{3}\">", new object[] { str, num2, production.Head.TableIndex, production.Handle().Count() });
                    int num7 = production.Handle().Count() - 1;
                    num = 0;
                    while (num <= num7)
                    {
                        writer.WriteLine("{0}{0}{0}<ProductionSymbol SymbolIndex=\"{1}\"/>", str, production.Handle()[num].TableIndex);
                        num++;
                    }
                    writer.WriteLine("{0}{0}</Production>", str);
                    production = null;
                }
                writer.WriteLine("{0}</m_Production>", str);
                writer.WriteLine("{0}<m_CharSet Count=\"{1}\">", str, this.m_CharSet.Count);
                int num8 = this.m_CharSet.Count - 1;
                for (num2 = 0; num2 <= num8; num2++)
                {
                    CharacterSet set = this.m_CharSet[num2];
                    writer.WriteLine("{0}{0}<CharSet Index=\"{1}\" Count=\"{2}\">", str, num2, set.Count());
                    int num9 = set.Count() - 1;
                    num = 0;
                    while (num <= num9)
                    {
                        writer.WriteLine("{0}{0}{0}<Char UnicodeIndex=\"{1}\"/>", str, set[num]);
                        num++;
                    }
                    writer.WriteLine("{0}{0}</CharSet>", str);
                    set = null;
                }
                writer.WriteLine("{0}</m_CharSet>", str);
                writer.WriteLine("{0}<DFATable Count=\"{1}\" InitialState=\"{2}\">", str, this.m_DFA.Count, this.m_DFA.InitialState);
                int num10 = this.DFA.Count - 1;
                for (num2 = 0; num2 <= num10; num2++)
                {
                    FAState state = this.DFA[num2];
                    writer.WriteLine("{0}{0}<DFAState Index=\"{1}\" EdgeCount=\"{2}\" AcceptSymbol=\"{3}\">", new object[] { str, num2, state.Edges().Count(), state.AcceptIndex() });
                    int num11 = state.Edges().Count() - 1;
                    num = 0;
                    while (num <= num11)
                    {
                        writer.WriteLine("{0}{0}{0}<DFAEdge CharSetIndex=\"{1}\" Target=\"{2}\"/>", str, state.Edges()[num].Characters.TableIndex, state.Edges()[num].Target);
                        num++;
                    }
                    writer.WriteLine("{0}{0}</DFAState>", str);
                    state = null;
                }
                writer.WriteLine("{0}</DFATable>", str);
                writer.WriteLine("{0}<LALRTable Count=\"{1}\" InitialState=\"{2}\">", str, this.m_LALR.Count, this.m_LALR.InitialState);
                int num12 = this.m_LALR.Count - 1;
                for (num2 = 0; num2 <= num12; num2++)
                {
                    LRState state2 = this.m_LALR[num2];
                    writer.WriteLine("{0}{0}<LALRState Index=\"{1}\" ActionCount=\"{2}\">", str, num2, state2.Count);
                    int num13 = state2.Count - 1;
                    for (num = 0; num <= num13; num++)
                    {
                        writer.WriteLine("{0}{0}{0}<LALRAction SymbolIndex=\"{1}\" Action=\"{2}\" Value=\"{3}\"/>", new object[] { str, state2[(short)num].SymbolIndex(), Conversion.Int((int)state2[(short)num].Type()), state2[(short)num].Value() });
                    }
                    writer.WriteLine("{0}{0}</LALRState>", str);
                    state2 = null;
                }
                writer.WriteLine("{0}</LALRTable>", str);
                writer.WriteLine("</Tables>");
                writer.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                flag = false;
            }
            return(flag);
        }
Exemple #2
0
        public bool SaveXML1(string FileName)
        {
            int  num3;
            bool flag;
            int  tableIndex = -1;
            int  num4       = this.m_Group.Count - 1;

            for (num3 = 0; num3 <= num4; num3++)
            {
                Group group = this.m_Group[num3];
                if (group.Name.ToUpper() == "COMMENT LINE")
                {
                    tableIndex = group.Start.TableIndex;
                }
                group = null;
            }
            string str = Strings.Space(8);

            try
            {
                int        num2;
                TextWriter writer = new StreamWriter(FileName, false);
                writer.WriteLine("<?GOLDParserTables version={0}1.0{0}?>", '"');
                writer.WriteLine("<Tables>");
                writer.WriteLine("{0}<Parameters>", str);
                writer.WriteLine("{0}{0}<Parameter Name={1}Name{1} Value={1}{2}{1}/>", str, '"', BuilderUtility.XMLText(this.m_Properties["Name"].Value));
                writer.WriteLine("{0}{0}<Parameter Name={1}Author{1} Value={1}{2}{1}/>", str, '"', BuilderUtility.XMLText(this.m_Properties["Author"].Value));
                writer.WriteLine("{0}{0}<Parameter Name={1}Version{1} Value={1}{2}{1}/>", str, '"', BuilderUtility.XMLText(this.m_Properties["Version"].Value));
                writer.WriteLine("{0}{0}<Parameter Name={1}About{1} Value={1}{2}{1}/>", str, '"', BuilderUtility.XMLText(this.m_Properties["About"].Value));
                writer.WriteLine("{0}{0}<Parameter Name={1}Case Sensitive{1} Value={1}{2}{1}/>", str, '"', BuilderUtility.XMLText(this.m_Properties["Case Sensitive"].Value));
                writer.WriteLine("{0}{0}<Parameter Name={1}Start Symbol{1} Value={1}{2}{1}/>", str, '"', BuilderUtility.XMLText(this.m_StartSymbol.Text(false)));
                writer.WriteLine("{0}</Parameters>", str);
                writer.WriteLine("{0}<SymbolTable Count={1}{2}{1}>", str, '"', this.m_Symbol.Count());
                int num5 = this.m_Symbol.Count() - 1;
                for (num3 = 0; num3 <= num5; num3++)
                {
                    SymbolType lEGACYCommentLine;
                    Symbol     symbol = this.m_Symbol[num3];
                    if (num3 == tableIndex)
                    {
                        lEGACYCommentLine = SymbolType.LEGACYCommentLine;
                    }
                    else
                    {
                        lEGACYCommentLine = symbol.Type;
                    }
                    writer.WriteLine("{0}{0}<Symbol Index={1}{2}{1} Name={1}{3}{1} Kind={1}{4}{1}/>", new object[] { str, '"', num3, BuilderUtility.XMLText(symbol.Name), Conversion.Int((int)lEGACYCommentLine) });
                    symbol = null;
                }
                writer.WriteLine("{0}</SymbolTable>", str);
                writer.WriteLine("{0}<RuleTable Count={1}{2}{1}>", str, '"', this.m_Production.Count());
                int num6 = this.m_Production.Count() - 1;
                for (num3 = 0; num3 <= num6; num3++)
                {
                    Production production = this.m_Production[num3];
                    writer.WriteLine("{0}{0}<Rule Index={1}{2}{1} NonTerminalIndex={1}{3}{1} SymbolCount={1}{4}{1}>", new object[] { str, '"', num3, production.Head.TableIndex, production.Handle().Count() });
                    int num7 = production.Handle().Count() - 1;
                    num2 = 0;
                    while (num2 <= num7)
                    {
                        writer.WriteLine("{0}{0}{0}<RuleSymbol SymbolIndex={1}{2}{1}/>", str, '"', production.Handle()[num2].TableIndex);
                        num2++;
                    }
                    writer.WriteLine("{0}{0}</Rule>", str);
                    production = null;
                }
                writer.WriteLine("{0}</RuleTable>", str);
                writer.WriteLine("{0}<CharSetTable Count={1}{2}{1}>", str, '"', this.m_CharSet.Count);
                int num8 = this.m_CharSet.Count - 1;
                for (num3 = 0; num3 <= num8; num3++)
                {
                    CharacterSet set = this.m_CharSet[num3];
                    writer.WriteLine("{0}{0}<CharSet Index={1}{2}{1} Count={1}{3}{1}>", new object[] { str, '"', num3, set.Count() });
                    int num9 = set.Count() - 1;
                    num2 = 0;
                    while (num2 <= num9)
                    {
                        writer.WriteLine("{0}{0}{0}<Char UnicodeIndex={1}{2}{1}/>", str, '"', set[num2]);
                        num2++;
                    }
                    writer.WriteLine("{0}{0}</CharSet>", str);
                    set = null;
                }
                writer.WriteLine("{0}</CharSetTable>", str);
                writer.WriteLine("{0}<DFATable Count={1}{2}{1} InitialState={1}{3}{1}>", new object[] { str, '"', this.m_DFA.Count, this.DFA.InitialState });
                int num10 = this.DFA.Count - 1;
                for (num3 = 0; num3 <= num10; num3++)
                {
                    FAState state = this.DFA[num3];
                    writer.WriteLine("{0}{0}<DFAState Index={1}{2}{1} EdgeCount={1}{3}{1} AcceptSymbol={1}{4}{1}>", new object[] { str, '"', num3, state.Edges().Count(), state.AcceptIndex() });
                    int num11 = state.Edges().Count() - 1;
                    num2 = 0;
                    while (num2 <= num11)
                    {
                        writer.WriteLine("{0}{0}{0}<DFAEdge CharSetIndex={1}{2}{1} Target={1}{3}{1}/>", new object[] { str, '"', state.Edges()[num2].Characters.TableIndex, state.Edges()[num2].Target });
                        num2++;
                    }
                    writer.WriteLine("{0}{0}</DFAState>", str);
                    state = null;
                }
                writer.WriteLine("{0}</DFATable>", str);
                writer.WriteLine("{0}<LALRTable Count={1}{2}{1} InitialState={1}{3}{1}>", new object[] { str, '"', this.LALR.Count, this.LALR.InitialState });
                int num12 = this.LALR.Count - 1;
                for (num3 = 0; num3 <= num12; num3++)
                {
                    LRState state2 = this.LALR[num3];
                    writer.WriteLine("{0}{0}<LALRState Index={1}{2}{1} ActionCount={1}{3}{1}>", new object[] { str, '"', num3, state2.Count });
                    int num13 = state2.Count - 1;
                    for (num2 = 0; num2 <= num13; num2++)
                    {
                        writer.WriteLine("{0}{0}{0}<LALRAction SymbolIndex={1}{2}{1} Action={1}{3}{1} Value={1}{4}{1}/>", new object[] { str, '"', state2[(short)num2].SymbolIndex(), Conversion.Int((int)state2[(short)num2].Type()), state2[(short)num2].Value() });
                    }
                    writer.WriteLine("{0}{0}</LALRState>", str);
                    state2 = null;
                }
                writer.WriteLine("{0}</LALRTable>", str);
                writer.WriteLine("</Tables>");
                writer.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                flag = false;
            }
            return(flag);
        }