Exemple #1
0
        public static bool Parse(TextReader Reader)
        {
            string right = "";
            string str   = "";

            Grammar.Clear();
            Accepted = false;
            Parser scanner = Scanner;

            scanner.Open(Reader);
            scanner.TrimReductions = false;
            bool flag = false;

            while (!flag)
            {
                short        num;
                short        num2;
                object[]     objArray;
                ParseMessage message = scanner.Parse();
                switch (((int)message))
                {
                case 0:
                    str = Conversions.ToString(scanner.CurrentToken().Data);
                    goto Label_0296;

                case 1:
                {
                    Parser    parser2          = scanner;
                    Reduction currentReduction = (Reduction)parser2.CurrentReduction;
                    parser2.CurrentReduction = currentReduction;
                    scanner.CurrentReduction = RuntimeHelpers.GetObjectValue(CreateNewObject(currentReduction));
                    goto Label_0296;
                }

                case 2:
                    flag = true;
                    goto Label_0296;

                case 3:
                    BuilderApp.Log.Add(SysLogSection.Grammar, SysLogAlert.Critical, "INTERNAL ERROR", "The scanner was unable to be initialized. Please report this bug.", "");
                    flag = true;
                    goto Label_0296;

                case 4:
                    BuilderApp.Log.Add(SysLogSection.Grammar, SysLogAlert.Critical, "Lexical Error", "Cannot recognize the token after: " + str, Conversions.ToString(scanner.CurrentPosition().Line));
                    flag = true;
                    goto Label_0296;

                case 5:
                    if (scanner.ExpectedSymbols().Count() < 1)
                    {
                        goto Label_011B;
                    }
                    right = FriendlyTerminalName(scanner.ExpectedSymbols()[0]);
                    num2  = (short)(scanner.ExpectedSymbols().Count() - 1);
                    num   = 1;
                    goto Label_0112;

                case 6:
                    BuilderApp.Log.Add(SysLogSection.Grammar, SysLogAlert.Critical, "Runaway Comment", "You have a unterminated block comment.", "");
                    flag = true;
                    goto Label_0296;

                case 7:
                    BuilderApp.Log.Add(SysLogSection.Grammar, SysLogAlert.Critical, "INTERNAL ERROR", "The scanner had an internal error. Please report this bug.", "");
                    flag = true;
                    goto Label_0296;

                default:
                    goto Label_0296;
                }
Label_00EC:
                right = right + ", " + FriendlyTerminalName(scanner.ExpectedSymbols()[num]);
                num   = (short)(num + 1);
Label_0112:
                if (num <= num2)
                {
                    goto Label_00EC;
                }
Label_011B:
                objArray = new object[2];
                Token token = scanner.CurrentToken();
                objArray[0] = RuntimeHelpers.GetObjectValue(token.Data);
                objArray[1] = false;
                object[] arguments = objArray;
                bool[]   copyBack  = new bool[] { true, false };
                if (copyBack[0])
                {
                    token.Data = RuntimeHelpers.GetObjectValue(arguments[0]);
                }
                BuilderApp.Log.Add(SysLogSection.Grammar, SysLogAlert.Critical, "Syntax Error", Conversions.ToString(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("Read: ", NewLateBinding.LateGet(null, typeof(BuilderUtility), "DisplayText", arguments, null, null, copyBack)), "\r\n"), "Expecting: "), right)), Conversions.ToString(scanner.CurrentPosition().Line));
                flag = true;
Label_0296:
                Notify.Counter = scanner.CurrentPosition().Line;
            }
            Notify.Counter = scanner.CurrentPosition().Line;
            scanner        = null;
            return(Accepted);
        }
Exemple #2
0
        public static string ToIdentifier(string Label, IDTypeCase TypeCase = IDTypeCase.Propercase, string ConvertSpaceChar = "", bool RemoveDashes = false)
        {
            string source = "";
            string str3   = Label.Trim();

            if (str3 == "")
            {
                source = "";
            }
            else
            {
                char   ch;
                string text = Conversions.ToString(str3[0]);
                if (IsAlphaNumeric(text))
                {
                    source = text;
                }
                else
                {
                    ch     = Conversions.ToChar(text);
                    text   = Conversions.ToString(ch);
                    source = CharNameShort(ch);
                }
                short num2 = (short)(str3.Length - 1);
                for (short i = 1; i <= num2; i = (short)(i + 1))
                {
                    text = Conversions.ToString(str3[i]);
                    if (IsAlphaNumeric(text) | (text == "_"))
                    {
                        source = source + text;
                    }
                    else if (!((text == "-") & RemoveDashes))
                    {
                        if (text == " ")
                        {
                            source = source + ConvertSpaceChar;
                        }
                        else
                        {
                            ch     = Conversions.ToChar(text);
                            text   = Conversions.ToString(ch);
                            source = source + CharNameShort(ch);
                        }
                    }
                }
            }
            switch (((int)TypeCase))
            {
            case 1:
                return(source.ToUpper());

            case 2:
                return(source.ToLower());

            case 3:
                return(IdentifierCase(source, true));

            case 4:
                return(IdentifierCase(source, false));
            }
            return(source);
        }
Exemple #3
0
        // Methods
        private static object CreateNewObject(Reduction TheReduction)
        {
            object    left = null;
            Reduction reduction2;
            int       num2;

            object[]   objArray;
            object[]   objArray2;
            bool[]     flagArray;
            RegExpItem item4;
            RegExpSeq  seq5;
            Reduction  reduction = TheReduction;

            switch (reduction.Parent.TableIndex)
            {
            case 13:
                left = Grammar.TokenText(Conversions.ToString(reduction.get_Data(0)));
                break;

            case 14:
                left = Grammar.TokenText(Conversions.ToString(reduction.get_Data(0)));
                break;

            case 15:
            {
                GrammarValueList instance = (GrammarValueList)reduction.get_Data(0);
                objArray    = new object[1];
                reduction2  = reduction;
                num2        = 3;
                objArray[0] = RuntimeHelpers.GetObjectValue(reduction2.get_Data(num2));
                objArray2   = objArray;
                flagArray   = new bool[] { true };
                NewLateBinding.LateCall(instance, null, "Add", objArray2, null, null, flagArray, true);
                if (flagArray[0])
                {
                    reduction2.set_Data(num2, RuntimeHelpers.GetObjectValue(objArray2[0]));
                }
                left = instance;
                break;
            }

            case 0x10:
            {
                GrammarValueList list2 = new GrammarValueList();
                objArray2    = new object[1];
                reduction2   = reduction;
                num2         = 0;
                objArray2[0] = RuntimeHelpers.GetObjectValue(reduction2.get_Data(num2));
                objArray     = objArray2;
                flagArray    = new bool[] { true };
                NewLateBinding.LateCall(list2, null, "Add", objArray, null, null, flagArray, true);
                if (flagArray[0])
                {
                    reduction2.set_Data(num2, RuntimeHelpers.GetObjectValue(objArray[0]));
                }
                left = list2;
                break;
            }

            case 0x11:
                left = Conversions.ToString(reduction.get_Data(0)) + " " + reduction.get_Data(1).ToString();
                break;

            case 0x12:
                left = RuntimeHelpers.GetObjectValue(reduction.get_Data(0));
                break;

            case 0x13:
                left = Grammar.TokenText(Conversions.ToString(reduction.get_Data(0)));
                break;

            case 20:
                left = Grammar.TokenText(Conversions.ToString(reduction.get_Data(0)));
                break;

            case 0x15:
                left = Grammar.TokenText(Conversions.ToString(reduction.get_Data(0)));
                break;

            case 0x16:
            {
                string name = Grammar.TokenText(Conversions.ToString(reduction.get_Data(0)));
                Grammar.AddProperty(name, ((GrammarValueList)reduction.get_Data(3)).ToString(), reduction[0].Position.Line);
                break;
            }

            case 0x17:
            {
                GrammarValueList list4 = (GrammarValueList)reduction.get_Data(0);
                GrammarValueList list  = (GrammarValueList)reduction.get_Data(3);
                list4.Add(list);
                left = list4;
                break;
            }

            case 0x18:
                left = RuntimeHelpers.GetObjectValue(reduction.get_Data(0));
                break;

            case 0x19:
            {
                GrammarAttribAssign assign = new GrammarAttribAssign
                {
                    Name   = Conversions.ToString(reduction.get_Data(0)),
                    Values = (GrammarAttribList)reduction.get_Data(4),
                    Line   = reduction[2].Position.Line
                };
                Grammar.AddSymbolAttrib(assign);
                break;
            }

            case 0x1a:
            {
                GrammarAttribAssign assign2 = new GrammarAttribAssign
                {
                    Name   = Conversions.ToString(Operators.ConcatenateObject(Operators.ConcatenateObject(reduction.get_Data(0), " "), reduction.get_Data(1))),
                    Values = (GrammarAttribList)reduction.get_Data(5),
                    Line   = reduction[3].Position.Line
                };
                Grammar.AddGroupAttrib(assign2);
                break;
            }

            case 0x1b:
            {
                GrammarAttribList list6 = (GrammarAttribList)reduction.get_Data(0);
                list6.Add((GrammarAttrib)reduction.get_Data(3));
                left = list6;
                break;
            }

            case 0x1c:
            {
                GrammarAttribList list7 = new GrammarAttribList();
                list7.Add((GrammarAttrib)reduction.get_Data(0));
                left = list7;
                break;
            }

            case 0x1d:
            {
                GrammarAttrib attrib = new GrammarAttrib
                {
                    Name = Conversions.ToString(reduction.get_Data(0))
                };
                objArray2    = new object[1];
                reduction2   = reduction;
                num2         = 2;
                objArray2[0] = RuntimeHelpers.GetObjectValue(reduction2.get_Data(num2));
                objArray     = objArray2;
                flagArray    = new bool[] { true };
                NewLateBinding.LateCall(attrib.List, null, "Add", objArray, null, null, flagArray, true);
                if (flagArray[0])
                {
                    reduction2.set_Data(num2, RuntimeHelpers.GetObjectValue(objArray[0]));
                }
                attrib.IsSet = false;
                left         = attrib;
                break;
            }

            case 30:
            {
                GrammarAttrib attrib2 = new GrammarAttrib
                {
                    Name  = Conversions.ToString(reduction.get_Data(0)),
                    List  = (GrammarValueList)reduction.get_Data(3),
                    IsSet = true
                };
                left = attrib2;
                break;
            }

            case 0x1f:
            {
                Grammar.GrammarSet charSet = new Grammar.GrammarSet
                {
                    Name = Conversions.ToString(reduction.get_Data(1)),
                    Exp  = (ISetExpression)reduction.get_Data(5),
                    Line = reduction[0].Position.Line
                };
                Grammar.AddUserSet(charSet);
                break;
            }

            case 0x20:
                left = new SetExp((ISetExpression)reduction.get_Data(0), '+', (ISetExpression)reduction.get_Data(3));
                break;

            case 0x21:
                left = new SetExp((ISetExpression)reduction.get_Data(0), '-', (ISetExpression)reduction.get_Data(3));
                break;

            case 0x22:
                left = RuntimeHelpers.GetObjectValue(reduction.get_Data(0));
                break;

            case 0x23:
            {
                reduction2 = reduction;
                num2       = 0;
                string fullText = Conversions.ToString(reduction2.get_Data(num2));
                Grammar.WarnRegexSetLiteral(fullText, reduction[0].Position.Line);
                reduction2.set_Data(num2, fullText);
                left = new SetItem(new CharacterSetBuild(Grammar.TokenText(Conversions.ToString(reduction.get_Data(0)))));
                break;
            }

            case 0x24:
                Grammar.AddUsedSetName(Conversions.ToString(reduction.get_Data(1)), reduction[0].Position.Line);
                left = new SetItem(SetItem.SetType.Name, Conversions.ToString(reduction.get_Data(1)));
                break;

            case 0x25:
            {
                CharacterSetBuild build = (CharacterSetBuild)reduction.get_Data(1);
                left = new SetItem(build);
                break;
            }

            case 0x26:
                left = Operators.ConcatenateObject(Operators.ConcatenateObject(reduction.get_Data(0), " "), reduction.get_Data(1));
                break;

            case 0x27:
                left = RuntimeHelpers.GetObjectValue(reduction.get_Data(0));
                break;

            case 40:
            {
                CharacterSetBuild build2 = (CharacterSetBuild)reduction.get_Data(0);
                CharacterSetRange range  = (CharacterSetRange)reduction.get_Data(3);
                build2.AddRange(range.First, range.Last);
                left = build2;
                break;
            }

            case 0x29:
            {
                CharacterSetBuild build3 = new CharacterSetBuild();
                CharacterSetRange range2 = (CharacterSetRange)reduction.get_Data(0);
                build3.AddRange(range2.First, range2.Last);
                left = build3;
                break;
            }

            case 0x2a:
                left = new CharacterSetRange(Conversions.ToInteger(reduction.get_Data(0)), Conversions.ToInteger(reduction.get_Data(0)));
                break;

            case 0x2b:
                left = new CharacterSetRange(Conversions.ToInteger(reduction.get_Data(0)), Conversions.ToInteger(reduction.get_Data(2)));
                break;

            case 0x2c:
                left = Grammar.GetHexValue(Conversions.ToString(reduction.get_Data(0)));
                if (Conversions.ToBoolean(Operators.OrObject(Operators.CompareObjectLess(left, 0, false), Operators.CompareObjectGreater(left, 0xffff, false))))
                {
                    BuilderApp.Log.Add(SysLogSection.Grammar, SysLogAlert.Critical, "Invalid set constant value", Conversions.ToString(Operators.ConcatenateObject(Operators.ConcatenateObject("The value '", reduction.get_Data(0)), "' is not valid.")), Conversions.ToString(reduction[0].Position.Line));
                }
                break;

            case 0x2d:
                left = Grammar.GetDecValue(Conversions.ToString(reduction.get_Data(0)));
                if (Conversions.ToBoolean(Operators.OrObject(Operators.CompareObjectLess(left, 0, false), Operators.CompareObjectGreater(left, 0xffff, false))))
                {
                    BuilderApp.Log.Add(SysLogSection.Grammar, SysLogAlert.Critical, "Invalid set constant value", Conversions.ToString(Operators.ConcatenateObject(Operators.ConcatenateObject("The value '", reduction.get_Data(0)), "' is not valid.")), Conversions.ToString(reduction[0].Position.Line));
                }
                break;

            case 0x2e:
            {
                string str3 = Conversions.ToString(reduction.get_Data(1));
                string str6 = str3.ToUpper();
                if (((str6 == "LINE") || (str6 == "START")) || (str6 == "END"))
                {
                    Grammar.GrammarGroup g = new Grammar.GrammarGroup(Conversions.ToString(reduction.get_Data(0)), Conversions.ToString(reduction.get_Data(1)), Conversions.ToString(reduction.get_Data(4)), reduction[1].Position.Line);
                    Grammar.AddGroup(g);
                }
                else
                {
                    BuilderApp.Log.Add(SysLogSection.Grammar, SysLogAlert.Critical, "Invalid group usage value", "The usage value '" + str3 + "' is not valid. It can be either Start, End or Line.", Conversions.ToString(reduction[1].Position.Line));
                }
                break;
            }

            case 0x2f:
                left = Grammar.TokenText(Conversions.ToString(reduction.get_Data(0)));
                break;

            case 0x30:
                left = Grammar.TokenText(Conversions.ToString(reduction.get_Data(0)));
                break;

            case 0x31:
            {
                Grammar.GrammarSymbol sym = new Grammar.GrammarSymbol
                {
                    Name = Conversions.ToString(reduction.get_Data(0)),
                    Exp  = (RegExp)reduction.get_Data(3),
                    Line = reduction[2].Position.Line,
                    Type = SymbolType.Content
                };
                Grammar.AddTerminalHead(sym);
                break;
            }

            case 50:
            {
                RegExp    exp = (RegExp)reduction.get_Data(0);
                RegExpSeq seq = (RegExpSeq)reduction.get_Data(3);
                seq.Priority = -1;
                exp.Add(seq);
                left = exp;
                break;
            }

            case 0x33:
            {
                RegExp    exp2 = new RegExp();
                RegExpSeq seq2 = (RegExpSeq)reduction.get_Data(0);
                seq2.Priority = -1;
                exp2.Add(seq2);
                left = exp2;
                break;
            }

            case 0x34:
            {
                RegExpSeq seq3 = (RegExpSeq)reduction.get_Data(0);
                reduction2 = reduction;
                num2       = 1;
                item4      = (RegExpItem)reduction2.get_Data(num2);
                seq3.Add(item4);
                reduction2.set_Data(num2, item4);
                left = seq3;
                break;
            }

            case 0x35:
            {
                RegExpSeq seq4 = new RegExpSeq();
                reduction2 = reduction;
                num2       = 0;
                item4      = (RegExpItem)reduction2.get_Data(num2);
                seq4.Add(item4);
                reduction2.set_Data(num2, item4);
                left = seq4;
                break;
            }

            case 0x36:
            {
                SetItem data = (SetItem)reduction.get_Data(0);
                left = new RegExpItem(data, Conversions.ToString(reduction.get_Data(1)));
                break;
            }

            case 0x37:
            {
                SetItem item2 = new SetItem(SetItem.SetType.Sequence, Grammar.TokenText(Conversions.ToString(reduction.get_Data(0))));
                left = new RegExpItem(item2, Conversions.ToString(reduction.get_Data(1)));
                break;
            }

            case 0x38:
            {
                SetItem item3 = new SetItem(SetItem.SetType.Sequence, Conversions.ToString(reduction.get_Data(0)));
                left = new RegExpItem(item3, Conversions.ToString(reduction.get_Data(1)));
                break;
            }

            case 0x39:
                left = new RegExpItem(RuntimeHelpers.GetObjectValue(reduction.get_Data(1)), Conversions.ToString(reduction.get_Data(3)));
                break;

            case 0x3a:
            {
                RegExp exp3 = (RegExp)reduction.get_Data(0);
                reduction2 = reduction;
                num2       = 2;
                seq5       = (RegExpSeq)reduction2.get_Data(num2);
                exp3.Add(seq5);
                reduction2.set_Data(num2, seq5);
                left = exp3;
                break;
            }

            case 0x3b:
            {
                RegExp exp4 = new RegExp();
                reduction2 = reduction;
                num2       = 0;
                seq5       = (RegExpSeq)reduction2.get_Data(num2);
                exp4.Add(seq5);
                reduction2.set_Data(num2, seq5);
                left = exp4;
                break;
            }

            case 60:
                left = "+";
                break;

            case 0x3d:
                left = "?";
                break;

            case 0x3e:
                left = "*";
                break;

            case 0x3f:
                left = "";
                break;

            case 0x40:
            {
                IEnumerator enumerator;
                Grammar.GrammarProductionList list8   = (Grammar.GrammarProductionList)reduction.get_Data(3);
                Grammar.GrammarSymbol         symbol2 = new Grammar.GrammarSymbol
                {
                    Name = Grammar.TokenText(Conversions.ToString(reduction.get_Data(0))),
                    Type = SymbolType.Nonterminal,
                    Line = reduction[2].Position.Line
                };
                try
                {
                    enumerator = list8.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        Grammar.GrammarProduction current = (Grammar.GrammarProduction)enumerator.Current;
                        current.Head = symbol2;
                        Grammar.AddProduction(current);
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                break;
            }

            case 0x41:
            {
                Grammar.GrammarProductionList list9 = (Grammar.GrammarProductionList)reduction.get_Data(0);
                Grammar.GrammarProduction     item  = new Grammar.GrammarProduction
                {
                    Handle = (Grammar.GrammarSymbolList)reduction.get_Data(3),
                    Line   = reduction[2].Position.Line
                };
                list9.Add(item);
                left = list9;
                break;
            }

            case 0x42:
            {
                Grammar.GrammarProductionList list10      = new Grammar.GrammarProductionList();
                Grammar.GrammarProduction     production3 = new Grammar.GrammarProduction
                {
                    Handle = (Grammar.GrammarSymbolList)reduction.get_Data(0)
                };
                list10.Add(production3);
                left = list10;
                break;
            }

            case 0x43:
            {
                Grammar.GrammarSymbolList list11 = (Grammar.GrammarSymbolList)reduction.get_Data(0);
                left = list11;
                break;
            }

            case 0x44:
            {
                Grammar.GrammarSymbolList list12 = new Grammar.GrammarSymbolList();
                left = list12;
                break;
            }

            case 0x45:
            {
                Grammar.GrammarSymbolList list13 = (Grammar.GrammarSymbolList)reduction.get_Data(0);
                list13.Add((Grammar.GrammarSymbol)reduction.get_Data(1));
                left = list13;
                break;
            }

            case 70:
            {
                Grammar.GrammarSymbolList list14 = new Grammar.GrammarSymbolList();
                left = list14;
                break;
            }

            case 0x47:
            {
                Grammar.GrammarSymbol symbol3 = new Grammar.GrammarSymbol(Conversions.ToString(reduction.get_Data(0)), SymbolType.Content, reduction[0].Position.Line);
                Grammar.AddHandleSymbol(symbol3);
                left = symbol3;
                break;
            }

            case 0x48:
            {
                Grammar.GrammarSymbol symbol4 = new Grammar.GrammarSymbol(Grammar.TokenText(Conversions.ToString(reduction.get_Data(0))), SymbolType.Nonterminal, reduction[0].Position.Line);
                Grammar.AddHandleSymbol(symbol4);
                left = symbol4;
                break;
            }
            }
            reduction = null;
            return(left);
        }
Exemple #4
0
        public static int OpenWebsite(int hwndOwner, string URL)
        {
            int    num;
            string lpOperation = "Open";
            int    num2        = ShellExecute(hwndOwner, lpOperation, URL, Conversions.ToString(0), Conversions.ToString(0), 1);

            return(num);

            Information.Err().Clear();
            return(0);
        }
Exemple #5
0
 public static string TimeDiffString(DateTime StartTime, DateTime EndTime)
 {
     return(Conversions.ToString(Conversion.Int((double)(((double)DateTime.DateDiff(DateInterval.Minute, StartTime, EndTime, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1)) / 60.0))) + " Hours " + Conversions.ToString(Conversion.Int((long)(DateTime.DateDiff(DateInterval.Minute, StartTime, EndTime, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1) % 60L))) + " Minutes " + Conversions.ToString(Conversion.Int((long)(DateTime.DateDiff(DateInterval.Second, StartTime, EndTime, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1) % 60L))) + " Seconds");
 }
Exemple #6
0
        // Methods
        public static string CharNameShort(char TheChar)
        {
            switch ((TheChar - ' '))
            {
            case '\0':
                return("Space");

            case '\x0001':
                return("Exclam");

            case '\x0002':
                return("Quote");

            case '\x0003':
                return("Num");

            case '\x0004':
                return("Dollar");

            case '\x0005':
                return("Percent");

            case '\x0006':
                return("Amp");

            case '\a':
                return("Apost");

            case '\b':
                return("LParen");

            case '\t':
                return("RParen");

            case '\n':
                return("Times");

            case '\v':
                return("Plus");

            case '\f':
                return("Comma");

            case '\r':
                return("Minus");

            case '\x000e':
                return("Dot");

            case '\x000f':
                return("Div");

            case '\x001a':
                return("Colon");

            case '\x001b':
                return("Semi");

            case '\x001c':
                return("Lt");

            case '\x001d':
                return("Eq");

            case '\x001e':
                return("Gt");

            case '\x001f':
                return("Question");

            case ' ':
                return("At");

            case ';':
                return("LBracket");

            case '<':
                return("Backslash");

            case '=':
                return("RBracket");

            case '>':
                return("Caret");

            case '?':
                return("UScore");

            case '@':
                return("Accent");

            case '[':
                return("LBrace");

            case '\\':
                return("Pipe");

            case ']':
                return("RBrace");

            case '^':
                return("Tilde");
            }
            return(Conversions.ToString((char)TheChar));
        }
Exemple #7
0
        public static string CleanString(string Text, bool ReplaceSpaceChar = true)
        {
            long num2;
            bool flag2 = ReplaceSpaceChar;

            if (!flag2)
            {
                bool flag = false;
                for (num2 = 1L; !((num2 > Strings.Len(Text)) | flag); num2 += 1L)
                {
                    if (Strings.Mid(Text, (int)num2, 1) != " ")
                    {
                        flag = true;
                    }
                }
                if (!flag)
                {
                    flag2 = true;
                }
            }
            string str4 = "";
            long   num3 = Strings.Len(Text);

            for (num2 = 1L; num2 <= num3; num2 += 1L)
            {
                string str3;
                string str  = Strings.Mid(Text, (int)num2, 1);
                long   num  = Strings.AscW(str);
                long   num4 = num;
                switch (num4)
                {
                case 9L:
                    str3 = "{HT}";
                    break;

                case 10L:
                    str3 = "{LF}";
                    break;

                case 11L:
                    str3 = "{VT}";
                    break;

                case 12L:
                    str3 = "{FF}";
                    break;

                case 13L:
                    str3 = "{CR}";
                    break;

                case 0x20L:
                    if (flag2)
                    {
                        str3 = "{Space}";
                    }
                    else
                    {
                        str3 = " ";
                    }
                    break;

                default:
                    if (num4 == 160L)
                    {
                        str3 = "{NBSP}";
                    }
                    else if (num4 == 0x20acL)
                    {
                        str3 = "{Euro Sign}";
                    }
                    else if (((num >= 0x20L) & (num <= 0x7eL)) | ((num >= 160L) & (num <= 0xffL)))
                    {
                        str3 = str;
                    }
                    else
                    {
                        str3 = "{#" + Conversions.ToString(num) + "}";
                    }
                    break;
                }
                str4 = str4 + str3;
            }
            return(str4);
        }
Exemple #8
0
        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);
        }
Exemple #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);
        }
Exemple #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))
 {
 }