run method

List<Token?> run(
  1. List<Token?> tokens
)

Implementation

List<Token?> run(List<Token?> tokens) {
  var stackLength = _stack.length;

  for (int i = 0; i < stackLength; i++) {
    PipelineFunction fn = _stack[i];
    List<Token?> memo = [];

    for (var j = 0; j < tokens.length; j++) {
      var result = fn(tokens[j], j, tokens);
      if (result == null || result.toString() == '') continue;

      if (result is List<Token?>) {
        memo.addAll(result);
      } else {
        memo.add(result);
      }
    }

    tokens = memo;
  }

  return tokens;
}