parsargs.core

alternative

(alternative & parse-fns)
Returns a parser function that tries each of the given parser-fns on the input.
It returns when the first parser function succeeds with the result
[parsed-result remaining-input].
If no parser function succeeds an IllegalArgumentException is thrown.

descent-with

(descent-with parser-fn)
Returns a parser function that applies the given parser-fn to the
first element of the given input and returns a pair
[parsed-result remaining-input].

map

(map f parser-fn)
Returns a parser function that parses input using the given parser function
and applies f to the parsed result. A pair [(f parsed-result) remaining-input]
is returned. f is a one-arg function.

omit

(omit pred)
Returns a parser function that returns a pair [nil remaining-input]
if the first element fulfills predicate pred. Otherwise an IllegalArgumentException
is thrown.

optional

(optional parser-fn)
Returns a parser that applies the given parser and either returns its result
or the pair [nil input] if parser-fn fails.

optval

(optval pred)(optval pred default)
Returns a parser function that returns a pair [first-element remaining-input]
if first element fulfills predicate pred, otherwise the pair
[default input]. If default is omitted the pair [nil input] is returned.

parse

(parse parser-fn input)
Applies the parser function to the given input. Returns either the
parsed result or throws an IllegalArgumentException if parsing fails
or remaining input is not empty.

sequence

(sequence & keys-parse-fn-pairs)
Returns a parser function that parses each element according to the given
parser function and associates the parsed value with the key (preceding the
specified parser function). The result is a pair [parsed-results-map remaining-input].
Optional tokens that have no default value will be omitted completely.

some

(some parse-fn)(some min-count max-count parse-fn)
Returns a parser function that parses each element of input using the given
parser function. Stops when parse-fn fails on an input.
The result is a pair [parsed-results-vector remaining-input].

value

(value pred)
Returns a parser function that returns a pair [first-element remaining-input]
if first-element fulfills the predicate pred. Otherwise an IllegalArgumentException
is thrown.