Parser
recurse
Recurse on a parser. Used in combination with {@see recursive()}. After calling this method, this parser behaves like a regular parser.
run
Run the parser on an input
optional
Optionally parse something, but still succeed if the thing is not there.
or
Try the first parser, and failing that, try the second parser. Returns the first succeeding result, or the first failing result.
Caveat: The order matters! string('http')->or(string('https')
followedBy
Alias for sequence()
. Parse something, then follow by something else. Ignore the result of the first parser and return the result of the
second parser.
sequence
Parse something, then follow by something else. Ignore the result of the first parser and return the result of the second parser.
label
Label a parser. When a parser fails, instead of a generated error message, you'll see your label. eg (char(':')->followedBy(char(')')).followedBy(char(')')).
bind
Create a parser that takes the output from the first parser (if successful) and feeds it to the callable. The callable must return another parser. If the first parser fails, the first parser is returned.
map
Map a function over the parser (which in turn maps it over the result).
continueFrom
Take the remaining input from the result and parse it
construct
Construct a class with thee parser's output as the constructor argument
append
Combine the parser with another parser of the same type, which will cause the results to be appended.
try
Try to parse the input, or throw an exception;
apply
Sequential application.
The first parser must be of type Parser<callable(T2):T3>.
apply :: f (a -> b) -> f a -> f b
thenIgnore
Sequence two parsers, and return the output of the first one, ignore the second.
notFollowedBy
notFollowedBy only succeeds when $second fails. It never consumes any input.
Example:
string("print")
will also match "printXYZ"
string("print")->notFollowedBy(alphaNumChar()))
will match "print something" but not "printXYZ something"