// 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); }
public ConflictTableItem(string newName, LRActionType newAction1, LRActionType newAction2, LRConflict newConflict) { Name = newName; Action1 = newAction1; Action2 = newAction2; Conflict = newConflict; }
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; }
internal LRAction ReadLRAction() { ushort index = ReadUInt16(); LRActionType actionType = ReadActionType(); ushort target = ReadUInt16(); //Reserved; skip ReadEntry(); return(new LRAction(grammarTables.Symbols[index], actionType, target)); }
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); }
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); }
public LRConflict ConflictWith(LRActionType TypeB) { if ((this.m_Type == LRActionType.Reduce) & (TypeB == LRActionType.Reduce)) { return(LRConflict.ReduceReduce); } if ((this.m_Type == LRActionType.Shift) & (TypeB == LRActionType.Reduce)) { return(LRConflict.ShiftReduce); } if ((this.m_Type == LRActionType.Reduce) & (TypeB == LRActionType.Shift)) { return(LRConflict.ShiftReduce); } if ((this.m_Type == LRActionType.Accept) & (TypeB == LRActionType.Shift)) { return(LRConflict.AcceptReduce); } if ((this.m_Type == LRActionType.Reduce) & (TypeB == LRActionType.Accept)) { return(LRConflict.AcceptReduce); } return(LRConflict.None); }
internal EGT(BinaryReader Reader) { EGTReader EGT = new EGTReader(Reader); EGTRecord RecType = default(EGTRecord); try { while (!EGT.EndOfFile()) { EGT.GetNextRecord(); RecType = (EGTRecord)EGT.RetrieveByte(); switch (RecType) { case EGTRecord.Property: { //Index, Name, Value int Index = 0; string Name = null; Index = EGT.RetrieveInt16(); Name = EGT.RetrieveString(); //Just discard m_Grammar.SetValue(Index, EGT.RetrieveString()); } break; case EGTRecord.TableCounts: //Symbol, CharacterSet, Rule, DFA, LALR m_SymbolTable = new SymbolList(EGT.RetrieveInt16()); m_CharSetTable = new CharacterSetList(EGT.RetrieveInt16()); m_ProductionTable = new ProductionList(EGT.RetrieveInt16()); m_DFA = new FAStateList(EGT.RetrieveInt16()); m_LRStates = new LRStateList(EGT.RetrieveInt16()); m_GroupTable = new GroupList(EGT.RetrieveInt16()); break; case EGTRecord.InitialStates: //DFA, LALR m_DFA.InitialState = EGT.RetrieveInt16(); m_LRStates.InitialState = EGT.RetrieveInt16(); break; case EGTRecord.Symbol: { //#, Name, Kind short Index = 0; string Name = null; SymbolType Type = default(SymbolType); Index = EGT.RetrieveInt16(); Name = EGT.RetrieveString(); Type = (SymbolType)EGT.RetrieveInt16(); m_SymbolTable[Index] = new Symbol(Name, Type, Index); } break; case EGTRecord.Group: //#, Name, Container#, Start#, End#, Tokenized, Open Ended, Reserved, Count, (Nested Group #...) { Group G = new Group(); G.TableIndex = EGT.RetrieveInt16(); //# G.Name = EGT.RetrieveString(); G.Container = m_SymbolTable[EGT.RetrieveInt16()]; G.Start = m_SymbolTable[EGT.RetrieveInt16()]; G.End = m_SymbolTable[EGT.RetrieveInt16()]; G.Advance = (Group.AdvanceMode)EGT.RetrieveInt16(); G.Ending = (Group.EndingMode)EGT.RetrieveInt16(); EGT.RetrieveEntry(); //Reserved int Count = EGT.RetrieveInt16(); for (int n = 1; n <= Count; n++) { G.Nesting.Add(EGT.RetrieveInt16()); } //=== Link back m_GroupStart.Add(G.Start, G); m_GroupTable[G.TableIndex] = G; } break; case EGTRecord.CharRanges: //#, Total Sets, RESERVED, (Start#, End# ...) { int Index = 0; int Total = 0; Index = EGT.RetrieveInt16(); EGT.RetrieveInt16(); //Codepage Total = EGT.RetrieveInt16(); EGT.RetrieveEntry(); //Reserved m_CharSetTable[Index] = new CharacterSet(); while (!(EGT.RecordComplete())) { m_CharSetTable[Index].Add(new CharacterRange(EGT.RetrieveUInt16(), EGT.RetrieveUInt16())); } } break; case EGTRecord.Production: //#, ID#, Reserved, (Symbol#, ...) { short Index = 0; int HeadIndex = 0; int SymIndex = 0; Index = EGT.RetrieveInt16(); HeadIndex = EGT.RetrieveInt16(); EGT.RetrieveEntry(); //Reserved List <Symbol> symbols = new List <Symbol>(); while (!(EGT.RecordComplete())) { SymIndex = EGT.RetrieveInt16(); //m_ProductionTable[Index].Handle().Add(m_SymbolTable[SymIndex]); symbols.Add(m_SymbolTable[SymIndex]); } SymbolList symbolList = new SymbolList(symbols); m_ProductionTable[Index] = new Production(m_SymbolTable[HeadIndex], Index, symbolList); } break; case EGTRecord.DFAState: //#, Accept?, Accept#, Reserved (CharSet#, Target#, Reserved)... { int Index = 0; bool Accept = false; int AcceptIndex = 0; int SetIndex = 0; short Target = 0; Index = EGT.RetrieveInt16(); Accept = EGT.RetrieveBoolean(); AcceptIndex = EGT.RetrieveInt16(); EGT.RetrieveEntry(); //Reserved if (Accept) { m_DFA[Index] = new FAState(m_SymbolTable[AcceptIndex]); } else { m_DFA[Index] = new FAState(); } //(Edge chars, Target#, Reserved)... while (!(EGT.RecordComplete())) { SetIndex = EGT.RetrieveInt16(); //Char table index Target = EGT.RetrieveInt16(); //Target EGT.RetrieveEntry(); //Reserved m_DFA[Index].Edges.Add(new FAEdge(m_CharSetTable[SetIndex], Target)); } } break; case EGTRecord.LRState: //#, Reserved (Symbol#, Action, Target#, Reserved)... { int Index = 0; int SymIndex = 0; LRActionType Action = 0; short Target = 0; Index = EGT.RetrieveInt16(); EGT.RetrieveEntry(); //Reserved m_LRStates[Index] = new LRState(); //(Symbol#, Action, Target#, Reserved)... while (!EGT.RecordComplete()) { SymIndex = EGT.RetrieveInt16(); Action = (LRActionType)EGT.RetrieveInt16(); Target = EGT.RetrieveInt16(); EGT.RetrieveEntry(); //Reserved m_LRStates[Index].Add(new LRAction(m_SymbolTable[SymIndex], Action, Target)); } } break; default: //RecordIDComment throw new ParserException("File Error. A record of type '" + (char)RecType + "' was read. This is not a valid code."); } } } catch (Exception ex) { throw new ParserException(ex.Message, ex, "LoadTables"); } }
internal LRAction(Symbol symbol, LRActionType type, ushort value) { Symbol = symbol; Type = type; Value = value; }
public LRAction(Symbol symbol, LRActionType type, short value) { Symbol = symbol; Type = type; Value = value; }
public LRAction(Symbol TheSymbol, LRActionType Type, short Value) { this.Symbol = TheSymbol; this.Type = Type; this.Value = Value; }
public LRAction(Symbol TheSymbol, LRActionType Type) { this.m_Symbol = TheSymbol; this.m_Type = Type; this.m_Value = 0; }
public LRAction(Symbol symbol, LRActionType type, short value) { this.Symbol = symbol; this.Type = type; this.Value = value; }