Exemplo n.º 1
0
        private static AutomataType CreateAutomataItem(RegExpItem Item)
        {
            AutomataType type;
            int          head;
            int          num3;
            int          num4;
            int          tail;

            if (Item.Data is RegExp)
            {
                RegExpItem item2 = Item;
                RegExp     data  = (RegExp)item2.Data;
                item2.Data = data;
                AutomataType type3 = CreateSubAutomata(data);
                head = type3.Head;
                tail = type3.Tail;
                num3 = head;
                num4 = tail;
            }
            else if (!(Item.Data is SetItem))
            {
                BuilderApp.Log.Add(SysLogSection.Grammar, SysLogAlert.Critical, "Invalid internal token at CreateAutomataItem(): " + Versioned.TypeName(RuntimeHelpers.GetObjectValue(Item.Data)));
            }
            else
            {
                CharacterSetBuild characters;
                SetItem           item = (SetItem)Item.Data;
                switch (item.Type)
                {
                case SetItem.SetType.Chars:
                    characters = (CharacterSetBuild)item.Characters;
                    head       = AddState();
                    tail       = AddState();
                    NFA[head].AddEdge(characters, tail);
                    num3 = head;
                    num4 = tail;
                    break;

                case SetItem.SetType.Name:
                    characters = (CharacterSetBuild)BuilderApp.GetCharacterSet(item.Text);
                    if (characters == null)
                    {
                        BuilderApp.Log.Add(SysLogSection.Grammar, SysLogAlert.Critical, "Unknown user-defined set: {" + item.Text + "}");
                        break;
                    }
                    tail = AddState();
                    head = AddState();
                    NFA[head].AddEdge(characters, tail);
                    num3 = head;
                    num4 = tail;
                    break;

                case SetItem.SetType.Sequence:
                {
                    int num6;
                    head = AddState();
                    tail = head;
                    string text = item.Text;
                    short  num7 = (short)(text.Length - 1);
                    for (short i = 0; i <= num7; i = (short)(i + 1))
                    {
                        num6 = tail;
                        tail = AddState();
                        NFA[num6].AddEdge(new CharacterSetBuild(Conversions.ToString(text[i])), tail);
                    }
                    num3 = num6;
                    num4 = tail;
                    break;
                }

                default:
                    BuilderApp.Log.Add(SysLogSection.Grammar, SysLogAlert.Critical, "Invalid internal token at CreateAutomataItem(): " + Versioned.TypeName(RuntimeHelpers.GetObjectValue(Item.Data)));
                    break;
                }
            }
            if ((num3 == 0) | (num4 == 0))
            {
                Debug.WriteLine("ERROR: BAD KLEENE DATA");
            }
            switch (Item.Kleene)
            {
            case "*":
                NFA[num3].AddLambdaEdge(num4);
                NFA[num4].AddLambdaEdge(num3);
                break;

            case "+":
                NFA[num4].AddLambdaEdge(num3);
                break;

            case "?":
                NFA[num3].AddLambdaEdge(num4);
                break;
            }
            type.Head = (short)head;
            type.Tail = (short)tail;
            return(type);
        }
Exemplo n.º 2
0
 public void TypeName(object expression, string expected)
 {
     Assert.Equal(expected, Versioned.TypeName(expression));
 }
Exemplo n.º 3
0
        internal bool FriendSetObjectID(double vdblObjectID, ref AcadObject nrobjAcadObject = null, ref string nrstrErrMsg = "")
        {
            nrstrErrMsg = null;
            AcadDatabase dobjAcadDatabase = Database;

            if (mdblObjectID == vdblObjectID)
            {
                return(true);
            }
            if (Operators.CompareString(mstrObjectName, nrobjAcadObject.ObjectName, TextCompare: false) != 0)
            {
                mdblObjectID = vdblObjectID;
                return(true);
            }
            if (mdblObjectID != -1.0 || vdblObjectID <= -1.0)
            {
                nrstrErrMsg = "Die Object-ID darf nicht geändert werden.";
                hwpDxf_Functions.BkDXF_DebugPrint(mstrObjectName + ": " + nrstrErrMsg);
            }
            else
            {
                if (dobjAcadDatabase.FriendValidObjectID(vdblObjectID, ref nrstrErrMsg))
                {
                    AcadObject robjAcadObject = (AcadObject)Interaction.IIf(nrobjAcadObject == null, this, nrobjAcadObject);
                    dobjAcadDatabase.FriendAddObjectID(vdblObjectID, ref robjAcadObject);
                    mdblObjectID = vdblObjectID;
                    if (mobjAcadXData != null)
                    {
                        mobjAcadXData.FriendLetOwnerID = mdblObjectID;
                    }
                    return(true);
                }
                hwpDxf_Functions.BkDXF_DebugPrint("2 " + mstrObjectName + ": " + nrstrErrMsg + ", " + Versioned.TypeName(nrobjAcadObject) + ", " + nrobjAcadObject.ObjectName);
            }
            bool FriendSetObjectID = default(bool);

            return(FriendSetObjectID);
        }