示例#1
0
            public int ItemIndex(Grammar.GrammarProduction Prod)
            {
                int num = -1;

                for (int i = 0; (i < base.Count) & (num == -1); i++)
                {
                    if (this[i].IsIdentical(Prod))
                    {
                        num = i;
                    }
                }
                return(num);
            }
示例#2
0
            // Methods
            internal bool IsIdentical(Grammar.GrammarProduction Prod)
            {
                bool flag2 = false;

                if (!this.Head.IsIdentical(Prod.Head))
                {
                    flag2 = true;
                }
                else if (this.Handle.Count != Prod.Handle.Count)
                {
                    flag2 = true;
                }
                else
                {
                    for (int i = 0; (i < this.Handle.Count) & !flag2; i++)
                    {
                        flag2 = !this.Handle[i].IsIdentical(Prod.Handle[i]);
                    }
                }
                return(!flag2);
            }
示例#3
0
 // Methods
 public int Add(Grammar.GrammarProduction Item)
 {
     return(base.Add(Item));
 }
示例#4
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);
        }