Beispiel #1
0
        private static string DisplayChar(int CharCode, bool ReplaceSpaceChar)
        {
            switch (CharCode)
            {
            case 9:
                return("{HT}");

            case 10:
                return("{LF}");

            case 11:
                return("{VT}");

            case 12:
                return("{FF}");

            case 13:
                return("{CR}");

            case 0x20:
                return(Conversions.ToString(ReplaceSpaceChar ? "{Space}" : " "));

            case 160:
                return("{NBSP}");

            case 0x20ac:
                return("{Euro Sign}");
            }
            if (((CharCode >= 0x20) & (CharCode <= 0x7e)) | ((CharCode >= 160) & (CharCode <= 0xff)))
            {
                return(Conversions.ToString(Strings.ChrW(CharCode)));
            }
            return("{#" + Conversions.ToString(CharCode) + "}");
        }
Beispiel #2
0
        public char Chars(int Index)
        {
            char ch = '\0';

            if ((Index >= 0) & (Index < base.Count()))
            {
                ch = Strings.ChrW(base[Index]);
            }
            return(ch);
        }
Beispiel #3
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();
            int           num2    = base.Count() - 1;

            for (int i = 0; i <= num2; i++)
            {
                builder.Append(Strings.ChrW(base[i]));
            }
            return(builder.ToString());
        }
Beispiel #4
0
            private string RawReadCString()
            {
                string str2 = "";
                bool   flag = false;

                while (!flag)
                {
                    ushort charCode = this.RawReadUInt16();
                    if (charCode == 0)
                    {
                        flag = true;
                    }
                    else
                    {
                        str2 = str2 + Conversions.ToString(Strings.ChrW(charCode));
                    }
                }
                return(str2);
            }
Beispiel #5
0
        public static string HTMLChar(int CharCode, bool SpaceToNBSP = false)
        {
            switch (CharCode)
            {
            case 10:
                return("<br/>");

            case 13:
                return("");

            case 0x20:
                return(Conversions.ToString(Interaction.IIf(SpaceToNBSP, "&nbsp;", " ")));

            case 0x22:
                return("&quot;");

            case 60:
                return("&lt;");

            case 0x3e:
                return("&gt;");

            case 0x26:
                return("&amp;");

            case 0x95:
                return("&middot;");

            case 160:
                return("&nbsp;");
            }
            if (CharCode > 0xff)
            {
                return("&#" + Conversions.ToString(CharCode) + ";");
            }
            return(Conversions.ToString(Strings.ChrW(CharCode)));
        }
Beispiel #6
0
        public string XMLText()
        {
            string str  = "";
            int    num3 = base.Count() - 1;

            for (int i = 0; i <= num3; i++)
            {
                int charCode = base[i];
                int num4     = base[i];
                if (num4 == 60)
                {
                    str = str + "&lt;";
                }
                else if (num4 == 0x3e)
                {
                    str = str + "&gt;";
                }
                else if (num4 == 0x26)
                {
                    str = str + "&amp;";
                }
                else if (num4 == 0x22)
                {
                    str = str + "&quot;";
                }
                else if ((charCode >= 0x20) & (charCode <= 0x7e))
                {
                    str = str + Conversions.ToString(Strings.ChrW(charCode));
                }
                else
                {
                    str = str + "&#" + Conversions.ToString(charCode) + ";";
                }
            }
            return(str);
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
 private string Lookahead(int CharIndex)
 {
     if (CharIndex > this.m_LookaheadBuffer.Length)
     {
         int num3 = CharIndex - this.m_LookaheadBuffer.Length;
         for (int i = 1; i <= num3; i++)
         {
             this.m_LookaheadBuffer = this.m_LookaheadBuffer + Conversions.ToString(Strings.ChrW(this.m_Source.Read()));
         }
     }
     if (CharIndex <= this.m_LookaheadBuffer.Length)
     {
         return(Conversions.ToString(this.m_LookaheadBuffer[CharIndex - 1]));
     }
     return("");
 }
Beispiel #9
0
        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);
        }
Beispiel #10
0
 public IOException(SimpleDB.EntryType Type, BinaryReader Reader) : base("Type mismatch in file. Read '" + Conversions.ToString(Strings.ChrW((int)Type)) + "' at " + Conversions.ToString(Reader.BaseStream.Position))
 {
 }