private StatePattern StatePatternFor(IEnumerator <Token> input, ParsingStack stack) => input.Current is EndOfInput ? new StateEnd(stack.StateIndex) : input.Current is Lexeme lexeme ? (StatePattern) new StateIndexAndLabel(stack.StateIndex, lexeme.Label)
private IEnumerable <Func <IEnumerable <TreeElement> > > ShiftAction(IEnumerator <Token> input, ParsingStack stack) { if (this.Shift.StateFor(this.StatePatternFor(input, stack)).ToList() is List <int> nextState && nextState.Any()) { yield return(() => this.ExecuteShift(input, stack, nextState.First())); } }
private IEnumerable <Func <IEnumerable <TreeElement> > > ReduceAction(IEnumerator <Token> input, ParsingStack stack) { if (this.Reduce.ReductionFor(this.StatePatternFor(input, stack)).ToList() is List <RulePattern> rule && rule.Any()) { yield return(() => this.ExecuteReduce(input, stack, rule.First())); } }
public void Initialization() { stack = new ParsingStack(); }