private void Scan(INormalState scan, int j, IToken token) { var i = scan.Origin; var currentSymbol = scan.PostDotSymbol; var lexerRule = currentSymbol as ILexerRule; if (token.TokenType == lexerRule.TokenType) { var tokenNode = _nodeSet.AddOrGetExistingTokenNode(token); var nextState = scan.NextState(); var parseNode = CreateParseNode( nextState, scan.ParseNode, tokenNode, j + 1); nextState.ParseNode = parseNode; if (_chart.Enqueue(j + 1, nextState)) LogScan(j + 1, nextState, token); } }
private void PredictProduction(INormalState evidence, int j, IProduction production) { // TODO: Pre-Compute Leo Items. If item is 1 step from being complete, add a transition item var predictedState = new NormalState(production, 0, j); if (_chart.Enqueue(j, predictedState)) Log("Predict", j, predictedState); var isNullable = Grammar.IsNullable(evidence.PostDotSymbol as INonTerminal); if (isNullable) { var nullParseNode = CreateNullParseNode(evidence.PostDotSymbol, j); var aycockHorspoolState = evidence.NextState(); var evidenceParseNode = evidence.ParseNode as IInternalForestNode; if (evidenceParseNode == null) aycockHorspoolState.ParseNode = CreateParseNode(aycockHorspoolState, null, nullParseNode, j); else if (evidenceParseNode.Children.Count > 0 && evidenceParseNode.Children[0].Children.Count > 0) { var firstChildNode = evidenceParseNode; var parseNode = CreateParseNode(aycockHorspoolState, firstChildNode, nullParseNode, j); aycockHorspoolState.ParseNode = parseNode; } if (_chart.Enqueue(j, aycockHorspoolState)) Log("Predict", j, aycockHorspoolState); } }