private void EarleyReducer(EarleyItem completed, int setNumber) { int position = completed.GetOrignPosition(); EarleySet set = Sets[position]; List <EarleyItem> items = set.GetEarleyItemList(); for (int j = 0; j < items.Count; j++) { EarleyItem current = items[j]; Symbol next = current.GetCurrentNextSymbol(); if (next != null && next.Equals(completed.GetRule().GetLeftHandSideOfRule())) { EarleyItem newEarleyItem = new EarleyItem( setNumber, new DottedRule(current.GetRule(), current.GetRulePosition() + 1), current.GetOrignPosition() ); if (current.GetCurrentPrevSymbolList() != null && current.GetCurrentPrevSymbolList().Count > 0) { newEarleyItem.AddPredecessorLink(current, position); } newEarleyItem.AddReducerLink(completed, position); AddToSet(newEarleyItem, setNumber, "EarleyReducer"); } } }
private bool LeoReducer(EarleyItem completed, int setNumber) { int position = completed.GetOrignPosition(); Symbol lhs = completed.GetRule().GetLeftHandSideOfRule(); EarleySet set = Sets[position]; LeoItem transitiveItem = set.FindLeoItemBySymbol(lhs); if (transitiveItem == null) { return(false); } EarleyItem newEarleyItem = new EarleyItem( setNumber, transitiveItem.GetDottedRule(), transitiveItem.GetOrignPosition() ); EarleyItem current = Sets[transitiveItem.GetOrignPosition()].GetEarleyItemList() .Find(el => el.GetDottedRule().Equals(transitiveItem.GetDottedRule()) && el.GetOrignPosition() == transitiveItem.GetOrignPosition()); if (current.GetCurrentPrevSymbolList() != null && current.GetCurrentPrevSymbolList().Count > 0) { newEarleyItem.AddPredecessorLink(current, position); } newEarleyItem.AddReducerLink(completed, position); AddToSet( newEarleyItem, setNumber, "LeoReducer" ); return(true); }
private void Scanner(EarleyItem current, int setNumber, Char inputSymbol) { Symbol nextSymbol = current.GetCurrentNextSymbol(); if (nextSymbol != null && nextSymbol.Equals(inputSymbol.ToString())) { EarleyItem newEarleyItem = new EarleyItem( setNumber + 1, new DottedRule(current.GetRule(), current.GetRulePosition() + 1), current.GetOrignPosition() ); if (newEarleyItem.GetCurrentPrevSymbolList() != null && newEarleyItem.GetCurrentPrevSymbolList().Count > 0) { newEarleyItem.AddPredecessorLink(current, setNumber); } AddToSet(newEarleyItem, setNumber + 1, "Scanner"); } }