/// <summary>Checks the productions righ side start no terminal.</summary> /// <param name="productions">The productions.</param> /// <param name="x">The x.</param> /// <returns></returns> public bool CheckProductionsRighSideStartNoTerminal(List <Production> productions, char x) { foreach (Production production in productions) { if (production.rightSide [0].kind.Equals(Element.Kind.noTerminal)) { if (GrammarTools.GetSeleccionSetOfProduction(new List <char> (), production.leftSide.index, grammar).Contains(x)) { stack.Pop(); for (int i = production.rightSide.Count - 1; i >= 0; i--) { stack.Push(production.rightSide [i]); } return(Transition(x)); } return(false); } } return(true); }
/// <summary>Determines whether [is disjoint productions] [the specified same productions].</summary> /// <param name="sameProductions">The same productions.</param> /// <param name="grammar">The grammar.</param> /// <returns> /// <c>true</c> if [is disjoint productions] [the specified same productions]; otherwise, <c>false</c>.</returns> private static bool IsDisjointProductions(List <Production> sameProductions, GenericGrammar grammar) { for (int i = 0; i < sameProductions.Count; i++) { List <char> selectionSet = GrammarTools.GetSeleccionSetOfProduction(new List <char>(), sameProductions[i].leftSide.index, grammar); for (int j = 0; j < sameProductions.Count; j++) { if (i != j) { List <char> selectionSetToCompare = GrammarTools.GetSeleccionSetOfProduction(new List <char>(), sameProductions[j].leftSide.index, grammar); if (ListAreEqual(selectionSet, selectionSetToCompare)) { return(false); } } } } return(true); }
/// <summary>Checks the selection set of peek.</summary> /// <param name="productions">The productions.</param> /// <param name="x">The x.</param> /// <returns></returns> public bool CheckSelectionSetOfPeek(List <Production> productions, char x) { foreach (Production production in productions) { if (production.rightSide [0].kind.Equals(Element.Kind.nulo)) { if (GrammarTools.GetSeleccionSetOfProduction(new List <char> (), production.leftSide.index, grammar).Contains(x)) { stack.Pop(); return(Transition(x)); } else { //GamEvent.instance.RejectRow return(false); } } } return(true); }