Ejemplo n.º 1
0
 public LRConflictItem(LRConflictItem Item, LRConflict Status)
 {
     this.Symbol   = Item.Symbol;
     this.Conflict = Status;
     this.Shifts   = Item.Shifts;
     this.Reduces  = Item.Reduces;
 }
Ejemplo n.º 2
0
        // Methods
        private LRConflict ActionAdd(SymbolBuild TheSymbol, LRActionType Type, short Value = 0)
        {
            bool       flag2 = false;
            bool       flag  = false;
            LRConflict none  = LRConflict.None;

            for (short i = 0; ((i < base.Count) & !flag2) & !flag; i = (short)(i + 1))
            {
                LRAction action = base[i];
                if (action.Symbol.IsEqualTo(TheSymbol))
                {
                    if ((action.Type() == Type) & (action.Value() == Value))
                    {
                        flag = true;
                    }
                    else
                    {
                        none  = BuildLR.GetConflict(action.Type(), Type);
                        flag2 = true;
                    }
                }
            }
            if (!flag)
            {
                base.Add(new LRAction(TheSymbol, Type, Value));
            }
            return(none);
        }
Ejemplo n.º 3
0
 // Methods
 public LRConflictItem(SymbolBuild Symbol)
 {
     this.Symbol   = Symbol;
     this.Conflict = LRConflict.None;
     this.Shifts   = new LRConfigSet();
     this.Reduces  = new LRConfigSet();
 }
Ejemplo n.º 4
0
 public ConflictTableItem(string newName, LRActionType newAction1, LRActionType newAction2, LRConflict newConflict)
 {
     Name     = newName;
     Action1  = newAction1;
     Action2  = newAction2;
     Conflict = newConflict;
 }
Ejemplo n.º 5
0
 public ConflictTableItem(string NewName, LRActionType NewAction1, LRActionType NewAction2, LRConflict NewConflict)
 {
     this          = new BuildLR.ConflictTableItem();
     this.Name     = NewName;
     this.Action1  = NewAction1;
     this.Action2  = NewAction2;
     this.Conflict = NewConflict;
 }
Ejemplo n.º 6
0
        public static string GetConflictResolvedDesc(LRConflict Conflict)
        {
            switch (((int)Conflict))
            {
            case 0:
                return("");

            case 1:
            {
                string str2 = "";
                return((str2 + "The conflict was resolved by selecting the 'shift' action over the 'reduce'. ") + "Be careful, some parts grammar may not be accessable. " + "It is recommended that you attempt to remove all conflicts.");
            }
            }
            return("This conflict cannot be automatically resolved");
        }
Ejemplo n.º 7
0
        public static LRConflict GetConflict(LRActionType Action1, LRActionType Action2)
        {
            LRConflict none = LRConflict.None;
            bool       flag = false;

            for (short i = 0; (i < m_ConflictTableCount) & !flag; i = (short)(i + 1))
            {
                ConflictTableItem[] conflictTable = m_ConflictTable;
                int index = i;
                if (((conflictTable[index].Action1 == Action1) & (conflictTable[index].Action2 == Action2)) | ((conflictTable[index].Action1 == Action2) & (conflictTable[index].Action2 == Action1)))
                {
                    none = m_ConflictTable[i].Conflict;
                    flag = true;
                }
            }
            return(none);
        }
Ejemplo n.º 8
0
        public static string GetConflictName(LRConflict Conflict)
        {
            switch (((int)Conflict))
            {
            case 0:
                return("None");

            case 1:
                return("Shift-Reduce");

            case 2:
                return("Reduce-Reduce");

            case 3:
                return("Accept-Reduce");
            }
            return("Unknown");
        }
Ejemplo n.º 9
0
        public static string GetConflictDesc(LRConflict Conflict)
        {
            string str2;

            switch (((int)Conflict))
            {
            case 0:
                return("There is no conflict.");

            case 1:
                str2 = "";
                return(((str2 + "A Shift-Reduce Conflict is caused when the system cannot " + "determine whether to advance (shift) one rule or complete ") + "(reduce) another. This means that the *same* text can be parsed " + "into two or more distrinct trees at the same time. ") + "The grammar is ambigious. " + "Please see the documentation for more information.");

            case 2:
                str2 = "";
                return(((str2 + "A Reduce-Reduce error is a caused when a grammar allows ") + "two or more rules to be reduced at the same time, for the " + "same token. ") + "The grammar is ambigious. " + "Please see the documentation for more information.");

            case 3:
                return("This NEVER happens");
            }
            return("Unknown");
        }
Ejemplo n.º 10
0
        public LRConflict ConflictForAction(SymbolBuild TheSymbol, LRActionType Type, short Value)
        {
            bool       flag = false;
            LRConflict none = LRConflict.None;

            for (short i = 0; (i < base.Count) & !flag; i = (short)(i + 1))
            {
                LRAction action = base[i];
                if (action.Symbol.IsEqualTo(TheSymbol))
                {
                    if ((action.Type() == Type) & (action.Value() == Value))
                    {
                        none = LRConflict.None;
                    }
                    else
                    {
                        none = BuildLR.GetConflict(action.Type(), Type);
                    }
                    flag = true;
                }
            }
            return(none);
        }