private void PredictAycockHorspool(EarleyItem evidence, int location) { var nullParseNode = CreateNullParseNode(evidence.DottedRule.PostDotSymbol as NonTerminal, location); var dottedRule = DottedRules.GetNext(evidence.DottedRule); //var evidenceParseNode = evidence.ParseNode as IInternalForestNode; IForestNode parseNode; if (evidence.ParseNode is IInternalForestNode evidenceParseNode && evidenceParseNode.Children.Count > 0) { parseNode = CreateParseNode( dottedRule, evidence.Origin, evidenceParseNode, nullParseNode, location); }
private void EarleyComplete(CompletedState completed, int location) { var earleySet = Chart[completed.Origin]; // Predictions may grow var p = 0; for (; p < earleySet.Predictions.Count; ++p) { var prediction = earleySet.Predictions[p]; if (!prediction.IsSource(completed.LeftHandSide)) { continue; } var dottedRule = DottedRules.GetNext(prediction.DottedRule); var origin = prediction.Origin; // this will not create a node if the state already exists var parseNode = CreateParseNode( dottedRule, origin, prediction.ParseNode, completed.ParseNode, location); if (Chart.Contains(location, dottedRule, origin)) { continue; } var nextState = StateFactory.NewState(dottedRule, origin, parseNode); if (Chart.Enqueue(location, nextState)) { Log(completeLogName, location, nextState); } } }