A {@link Parser} that sequentially runs 5 parser objects and collects the results in a
{@link Tuple5} object.

@deprecated Prefer to converting to your own object with a lambda.
513184
@Deprecated
  public static <A,B,C,D,E> Parser<Tuple5<A,B,C,D,E>> tuple(
      Parser<? extends A> p1, Parser<? extends B> p2, Parser<? extends C> p3,
      Parser<? extends D> p4, Parser<? extends E> p5) {
    return sequence(p1, p2, p3, p4, p5, Tuple5::new);
  }
695475
public static <T> Parser<List<T>> list(Iterable<? extends Parser<? extends T>> parsers) {
    final Parser<? extends T>[] array = toArray(parsers);
    return new Parser<List<T>>() {
      @Override boolean apply(ParseContext ctxt) {
        ArrayList<T> list = Lists.arrayList(array.length);
        for (Parser<? extends T> parser : array) {
          if (!parser.apply(ctxt)) return false;
          list.add(parser.getReturn(ctxt));
        }
        ctxt.result = list;
        return true;
      }
      
      @Override public String toString() {
        return "list";
      }
    };
  }
253221
public final Parser<List<T>> sepBy1(Parser<?> delim) {
    final Parser<T> afterFirst = delim.asDelimiter().next(this);
    return next((Function<T, Parser<List<T>>>) firstValue ->
        new RepeatAtLeastParser<T>(
            afterFirst, 0, ListFactory.arrayListFactoryWithFirstElement(firstValue)));
  }
419534
def invoke_parser(self, supparser=None, noexit=False):
        
        if supparser:
            parser = supparser.add_parser(self.NAME, description=self.DESCRIPTION)
        else:
            if noexit:
                class NoExitArgumentParser(argparse.ArgumentParser):
                    def exit(self, status=0, message=None):
                        raise ParserError()
                    def error(self, message):
                        raise ParserError()

                parser = NoExitArgumentParser(prog=self.NAME, description=self.DESCRIPTION)
            else:
                parser = argparse.ArgumentParser(prog=self.NAME, description=self.DESCRIPTION)


        def populate_parser(parser, dataset):
            for elem in dataset:
                opts = {}
                opts['help'] = elem.description
                opts['required'] = not elem.optional
                if elem.multi: opts['action'] = 'append'
                parser.add_argument('--'+elem.name, **opts)

        # populate parser with INPUTS
        populate_parser(parser, self.INPUTS)
        # populate parser with OUTPUTS
        populate_parser(parser, self.OUTPUTS)
        # populate parser with PARAMETERS
        for param in self.PARAMETERS:
            opts = {}
            opts['help'] = param.description
            opts['required'] = not param.optional
            if isinstance(param.datatype, tuple):
                opts['type'] = str
                #opts['type'] = param.datatype[1]
            else:
                opts['type'] = param.datatype

            if param.multi: opts['action'] = 'append'
            if param.choices:
                if isinstance(param.choices, tuple):
                    # if choices is a tuple, assume it is a tuple of mappings
                    # and expand them
                    opts['choices'] = [ choice[0] for choice in param.choices ]
                else:
                    opts['choices'] = param.choices
            parser.add_argument('--'+param.name, **opts)

        if self.USE_ARGUMENTS:
            parser.add_argument('--_tempdir',required=False, help=argparse.SUPPRESS)
        return parser
953199
public static Parser<Object[]> array(final Parser<?>... parsers) {
    return new Parser<Object[]>() {
      @Override boolean apply(ParseContext ctxt) {
        Object[] ret = new Object[parsers.length];
        for (int i = 0; i < parsers.length; i++) {
          Parser<?> parser = parsers[i];
          if (!parser.apply(ctxt)) return false;
          ret[i] = parser.getReturn(ctxt);
        }
        ctxt.result = ret;
        return true;
      }
      
      @Override public String toString() {
        return "array";
      }
    };
  }
799702
public static <T> Parser<T> or(Iterable<? extends Parser<? extends T>> alternatives) {
    return or(toArray(alternatives));
  }
1343069
@SuppressWarnings("unchecked")
    @NotNull
    public final Parser<Object> getParser() {
        if (parser != null) {
            return parser;
        }
        LOG.info("Creating parser: {}", className);
        if (className == null) {
            throw new IllegalStateException("Class name was not set: " + getName());
        }
        if (context == null) {
            throw new IllegalStateException("Context class loader was not set: " + getName() + " / " + className);
        }
        final Object obj = Utils4J.createInstance(className, context.getClassLoader());
        if (!(obj instanceof Parser<?>)) {
            throw new IllegalStateException("Expected class to be of type '" + Parser.class.getName() + "', but was: " + className);
        }
        parser = (Parser<Object>) obj;
        parser.initialize(context, this);
        return parser;
    }
610411
public static Parser<Object> sequence(final Parser<?>... parsers) {
    return new Parser<Object>() {
      @Override boolean apply(ParseContext ctxt) {
        for (Parser<?> p : parsers) {
          if (!p.apply(ctxt)) return false;
        }
        return true;
      }
      @Override public String toString() {
        return "sequence";
      }
    };
  }
258774
final Parser<T> asDelimiter() {
    return new Parser<T>() {
      @Override boolean apply(ParseContext ctxt) {
        return ctxt.applyAsDelimiter(Parser.this);
      }
      @Override public String toString() {
        return Parser.this.toString();
      }
    };
  }
236515
public final <T5> Tuple5<T1, T2, T3, T4, T5> concat(Tuple1<T5> tuple) {
        return new Tuple5<>(v1, v2, v3, v4, tuple.v1);
    }
832999
function Parser(tokens, options) {
  options = options || {};
  if (!Array.isArray(tokens)) {
    throw new Error('Expected tokens to be an Array but got "' + (typeof tokens) + '"');
  }
  if (typeof options !== 'object') {
    throw new Error('Expected "options" to be an object but got "' + (typeof options) + '"');
  }
  this.tokens = new TokenStream(tokens);
  this.filename = options.filename;
  this.src = options.src;
  this.inMixin = 0;
  this.plugins = options.plugins || [];
}
730620
public final Tuple5<T10, T11, T12, T13, T14> skip9() {
        return new Tuple5<>(v10, v11, v12, v13, v14);
    }
732987
public final static <T> Tuple2<Stream<T>, Stream<T>> splitBy(final Stream<T> stream, final Predicate<T> splitter) {
        final Tuple2<Stream<T>, Stream<T>> Tuple2 = duplicate(stream);
        return Tuple.tuple(
                          takeWhile(Tuple2._1(), splitter), dropWhile(Tuple2._2(), splitter));
    }
354802
@SuppressWarnings({"unchecked", "rawtypes"})
  @Private static <T> Parser<T>[] toArray(Iterable<? extends Parser<? extends T>> parsers) {
    if (parsers instanceof Collection<?>) {
      return toArray((Collection) parsers);
    }
    return toArrayWithIteration(parsers);
  }
812212
@SuppressWarnings({ "PMD.AvoidInstantiatingObjectsInLoops",
            "PMD.LongVariable", "PMD.ExcessiveMethodLength",
            "PMD.DataflowAnomalyAnalysis", "PMD.NcssMethodCount",
            "PMD.NPathComplexity" })
    private List<Token> parseTokenLogFileDefinition(final String tokenLogFormat) {

        // Add all available parsers
        final List<TokenParser> tokenParsers = createAllTokenParsers();
        final List<Token> tokens = new ArrayList<>(50);

        // We first change all the references to headers to lowercase
        // because we must handle these as "case insensitive"
        String cleanedTokenLogFormat = cleanupLogFormat(tokenLogFormat);

        // Now we let all tokens figure out if they are present in here
        for (TokenParser tokenParser : tokenParsers) {
            List<Token> newTokens = tokenParser.getTokens(cleanedTokenLogFormat);
            if (newTokens != null) {
                tokens.addAll(newTokens);
            }
        }

        // We now have a full list of all matched tokens
        // ---------------------------------------
        // We sort them by position of the token in the format specifier
        tokens.sort(new TokenSorterByStartPos());

        // First we take out the duplicates with a lower prio(=relevance score)
        final List<Token> kickTokens = new ArrayList<>(50);
        Token prevToken = null;
        for (Token token : tokens) {
            if (prevToken==null){
                prevToken=token;
                continue;
            }

            if (prevToken.getStartPos() == token.getStartPos()) {
                if (prevToken.getLength() == token.getLength()) {
                    if (prevToken.getPrio() < token.getPrio()) {
                        kickTokens.add(prevToken);
                    } else {
                        kickTokens.add(token);
                    }
                } else {
                    if (prevToken.getLength() < token.getLength()) {
                        kickTokens.add(prevToken);
                    } else {
                        kickTokens.add(token);
                    }
                }
            } else {
                // Sometimes we find that a part of a token matches another token aswell.
                // Example: %{%H}t    Custom Timeformat (only the hour) also matches the protocol token.
                // So we kick them of they overlap
                if (prevToken.getStartPos() + prevToken.getLength() > token.getStartPos()) {
                    kickTokens.add(token);
                    continue;
                }
            }
            prevToken=token;

        }

        tokens.removeAll(kickTokens);

        final List<Token> allTokens = new ArrayList<>(50);
        // We now look for the holes and add "FIXED STRING" tokens
        int tokenBegin;
        int tokenEnd = 0;
        for (Token token : tokens) {
            tokenBegin = token.getStartPos();
            // Space between the begin of the next token and the end of the previous token?
            if (tokenBegin - tokenEnd > 0) {
                String separator = cleanedTokenLogFormat.substring(tokenEnd, tokenBegin);
                Token fixedStringToken = new FixedStringToken(separator, tokenBegin, tokenBegin - tokenEnd, 0);
                allTokens.add(fixedStringToken);
            }
            allTokens.add(token);
            tokenEnd = tokenBegin + token.getLength();
        }

        int logFormatLength = cleanedTokenLogFormat.length();
        if (tokenEnd < logFormatLength) {
            String separator = cleanedTokenLogFormat.substring(tokenEnd);
            Token fixedStringToken = new FixedStringToken(separator, tokenEnd, cleanedTokenLogFormat.length() - tokenEnd, 0);
            allTokens.add(fixedStringToken);
        }

        return allTokens;
    }
257568
public final Tuple2<Tuple5<T1, T2, T3, T4, T5>, Tuple0> split5() {
        return new Tuple2<>(limit5(), skip5());
    }
45867
function Parser() {
  if (!(this instanceof Parser))
    return new Parser();

  EventEmitter.call(this);

  this.waiting = 9;
  this.header = null;
  this.pending = [];
  this.total = 0;
}