示例#1
0
 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)
示例#2
0
 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()));
     }
 }
示例#3
0
 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()));
     }
 }
示例#4
0
 public void Initialization()
 {
     stack = new ParsingStack();
 }