- Companion
- class
Type members
Classlikes
Represents where a failure occurred and all the expectations that were broken
Represents where a failure occurred and all the expectations that were broken
An expectation reports the kind or parsing error and where it occured.
An expectation reports the kind or parsing error and where it occured.
- Companion
- object
If we can parse this then that, do so, if we fail that without consuming, rewind before this without consuming. If either consume 1 or more, do not rewind
If we can parse this then that, do so, if we fail that without consuming, rewind before this without consuming. If either consume 1 or more, do not rewind
If we can parse this then that, do so, if we fail that without consuming, rewind before this without consuming. If either consume 1 or more, do not rewind
If we can parse this then that, do so, if we fail that without consuming, rewind before this without consuming. If either consume 1 or more, do not rewind
If we can parse this then that, do so, if we fail that without consuming, rewind before this without consuming. If either consume 1 or more, do not rewind
If we can parse this then that, do so, if we fail that without consuming, rewind before this without consuming. If either consume 1 or more, do not rewind
Value members
Concrete methods
If we fail, rewind the offset back so that we can try other branches. This tends to harm debuggability and ideally should be minimized
If we fail, rewind the offset back so that we can try other branches. This tends to harm debuggability and ideally should be minimized
If we fail, rewind the offset back so that we can try other branches. This tends to harm debuggability and ideally should be minimized
If we fail, rewind the offset back so that we can try other branches. This tends to harm debuggability and ideally should be minimized
Parse a string while the given function is true parses at least one character
Parse a string while the given function is true parses at least one character
Lazily create a Parser This is useful to create some recursive parsers see Defer0[Parser].fix
Lazily create a Parser This is useful to create some recursive parsers see Defer0[Parser].fix
Lazily create a Parser0 This is useful to create some recursive parsers see Defer0[Parser].fix
Lazily create a Parser0 This is useful to create some recursive parsers see Defer0[Parser].fix
If the first parser fails to parse its input with an epsilon error, try the second parser instead.
If the first parser fails to parse its input with an epsilon error, try the second parser instead.
If the first parser fails with an arresting error, the second parser won't be tried.
Backtracking may be used on the first parser to allow the second one to pick up after any error, resetting any state that was modified by the first parser.
If the first parser fails to parse its input with an epsilon error, try the second parser instead.
If the first parser fails to parse its input with an epsilon error, try the second parser instead.
If the first parser fails with an arresting error, the second parser won't be tried.
Backtracking may be used on the first parser to allow the second one to pick up after any error, resetting any state that was modified by the first parser.
A parser that always fails with an epsilon failure
A parser that always fails with an epsilon failure
A parser that always fails with an epsilon failure and a given message this is generally used with flatMap to validate a result beyond the literal parsing.
A parser that always fails with an epsilon failure and a given message this is generally used with flatMap to validate a result beyond the literal parsing.
e.g. parsing a number then validate that it is bounded.
Standard monadic flatMap Avoid this function if possible. If you can instead use product, ~, >, or < use that. flatMap always has to allocate a parser, and the parser is less amenable to optimization
Standard monadic flatMap Avoid this function if possible. If you can instead use product, ~, >, or < use that. flatMap always has to allocate a parser, and the parser is less amenable to optimization
Standard monadic flatMap where you end with a Parser Avoid this function if possible. If you can instead use product, ~, >, or < use that. flatMap always has to allocate a parser, and the parser is less amenable to optimization
Standard monadic flatMap where you end with a Parser Avoid this function if possible. If you can instead use product, ~, >, or < use that. flatMap always has to allocate a parser, and the parser is less amenable to optimization
Standard monadic flatMap where you start with a Parser Avoid this function if possible. If you can instead use product, ~, >, or < use that. flatMap always has to allocate a parser, and the parser is less amenable to optimization
Standard monadic flatMap where you start with a Parser Avoid this function if possible. If you can instead use product, ~, >, or < use that. flatMap always has to allocate a parser, and the parser is less amenable to optimization
Parse a given string, in a case-insensitive manner, or fail. This backtracks on failure this is an error if the string is empty
Parse a given string, in a case-insensitive manner, or fail. This backtracks on failure this is an error if the string is empty
Parse a potentially empty string, in a case-insensitive manner, or fail. This backtracks on failure
Parse a potentially empty string, in a case-insensitive manner, or fail. This backtracks on failure
Ignore the case of a single character If you want to know if it is upper or lower, use .string to capture the string and then map to process the result.
Ignore the case of a single character If you want to know if it is upper or lower, use .string to capture the string and then map to process the result.
Parse any single character in a set of characters as lower or upper case
Parse any single character in a set of characters as lower or upper case
Parse any single character in a set of characters as lower or upper case
Parse any single character in a set of characters as lower or upper case
return the current position in the string we are parsing. This lets you record position information in your ASTs you are parsing
return the current position in the string we are parsing. This lets you record position information in your ASTs you are parsing
Parse the next len characters where len > 0 if (len < 1) throw IllegalArgumentException
Parse the next len characters where len > 0 if (len < 1) throw IllegalArgumentException
returns a parser that succeeds if the current parser fails. Note, this parser backtracks (never returns an arresting failure)
returns a parser that succeeds if the current parser fails. Note, this parser backtracks (never returns an arresting failure)
go through the list of parsers trying each as long as they are epsilon failures (don't advance) see @backtrack if you want to do backtracking.
go through the list of parsers trying each as long as they are epsilon failures (don't advance) see @backtrack if you want to do backtracking.
This is the same as parsers.foldLeft(fail)(.orElse())
recommended style: oneOf(p1 :: p2 :: p3 :: Nil) rather than oneOf(List(p1, p2, p3))
Note: order matters here, since we don't backtrack by default.
go through the list of parsers trying each as long as they are epsilon failures (don't advance) see @backtrack if you want to do backtracking.
go through the list of parsers trying each as long as they are epsilon failures (don't advance) see @backtrack if you want to do backtracking.
This is the same as parsers.foldLeft(fail)(.orElse())
recommended style: oneOf(p1 :: p2 :: p3 :: Nil) rather than oneOf(List(p1, p2, p3))
Note: order matters here, since we don't backtrack by default.
a parser that consumes nothing when it succeeds, basically rewind on success
a parser that consumes nothing when it succeeds, basically rewind on success
Don't advance in the parsed string, just return a This is used by the Applicative typeclass.
Don't advance in the parsed string, just return a This is used by the Applicative typeclass.
Build a recursive parser by assuming you have it Useful for parsing recurive structures, like for instance JSON.
Build a recursive parser by assuming you have it Useful for parsing recurive structures, like for instance JSON.
Repeat the parser min
or more times
Repeat the parser min
or more times
The parser fails if it can't match at least min
times
- Throws
- java.lang.IllegalArgumentException
if min < 1
Repeat the parser min
or more times, but no more than max
Repeat the parser min
or more times, but no more than max
The parser fails if it can't match at least min
times
After repeating the parser max
times, the parser completes succesfully
- Throws
- java.lang.IllegalArgumentException
if min < 1 or max < min
Repeat the parser 0 or more times
Repeat the parser 0 or more times
- Note
this can wind up parsing nothing
Repeat the parser 0 or more times, but no more than max
Repeat the parser 0 or more times, but no more than max
It may seem weird to accept 0 here, but without, composing this method becomes more complex. Since and empty parse is possible for this method, we do allow max = 0
- Throws
- java.lang.IllegalArgumentException
if max < 0
- Note
this can wind up parsing nothing
Repeat the parser exactly times
times
Repeat the parser exactly times
times
- Throws
- java.lang.IllegalArgumentException
if times < 1
Repeat min
or more times with a separator, at least once.
Repeat min
or more times with a separator, at least once.
- Throws
- java.lang.IllegalArgumentException
if
min <= 0
Repeat min
or more, up to max
times with a separator, at least once.
Repeat min
or more, up to max
times with a separator, at least once.
- Throws
- java.lang.IllegalArgumentException
if
min <= 0
ormax < min
Repeat min
or more times with a separator.
Repeat min
or more times with a separator.
- Throws
- java.lang.IllegalArgumentException
if
min < 0
Repeat min
or more, up to max
times with a separator.
Repeat min
or more, up to max
times with a separator.
- Throws
- java.lang.IllegalArgumentException
if
min < 0
ormax < min
parse one or more times until Parser end
succeeds.
parse one or more times until Parser end
succeeds.
parse zero or more times until Parser end
succeeds.
parse zero or more times until Parser end
succeeds.
parse one or more times until Parser end
succeeds.
parse one or more times until Parser end
succeeds.
parse zero or more times until Parser end
succeeds.
parse zero or more times until Parser end
succeeds.
Parse p and if we get the Left side, parse fn This function name comes from seletive functors. This should be more efficient than flatMap since the fn Parser0 is evaluated once, not on every item parsed
Parse p and if we get the Left side, parse fn This function name comes from seletive functors. This should be more efficient than flatMap since the fn Parser0 is evaluated once, not on every item parsed
softProduct, a variant of product A soft product backtracks if the first succeeds and the second is an epsilon-failure. By contrast product will be a failure in that case
softProduct, a variant of product A soft product backtracks if the first succeeds and the second is an epsilon-failure. By contrast product will be a failure in that case
see @Parser.soft
softProduct with the second argument being a Parser A soft product backtracks if the first succeeds and the second is an epsilon-failure. By contrast product will be a failure in that case
softProduct with the second argument being a Parser A soft product backtracks if the first succeeds and the second is an epsilon-failure. By contrast product will be a failure in that case
see @Parser.soft
softProduct with the first argument being a Parser A soft product backtracks if the first succeeds and the second is an epsilon-failure. By contrast product will be a failure in that case
softProduct with the first argument being a Parser A soft product backtracks if the first succeeds and the second is an epsilon-failure. By contrast product will be a failure in that case
see @Parser.soft
Parse a given string or fail. This backtracks on failure this is an error if the string is empty
Parse a given string or fail. This backtracks on failure this is an error if the string is empty
Discard the result A and instead capture the matching string this is optimized to avoid internal allocations
Discard the result A and instead capture the matching string this is optimized to avoid internal allocations
Parse a potentially empty string or fail. This backtracks on failure
Parse a potentially empty string or fail. This backtracks on failure
Discard the result A and instead capture the matching string this is optimized to avoid internal allocations
Discard the result A and instead capture the matching string this is optimized to avoid internal allocations
Parse the longest matching string between alternatives. The order of the strings does not matter.
Parse the longest matching string between alternatives. The order of the strings does not matter.
If no string matches, this parser results in an epsilon failure.
It is an error to pass the empty string here, if you need that see stringIn0
tail recursive monadic flatMaps on Parser This is a rarely used function, but needed to implement cats.FlatMap Avoid this function if possible. If you can instead use product, ~, >, or < use that. flatMap always has to allocate a parser, and the parser is less amenable to optimization
tail recursive monadic flatMaps on Parser This is a rarely used function, but needed to implement cats.FlatMap Avoid this function if possible. If you can instead use product, ~, >, or < use that. flatMap always has to allocate a parser, and the parser is less amenable to optimization
tail recursive monadic flatMaps This is a rarely used function, but needed to implement cats.FlatMap Avoid this function if possible. If you can instead use product, ~, >, or < use that. flatMap always has to allocate a parser, and the parser is less amenable to optimization
tail recursive monadic flatMaps This is a rarely used function, but needed to implement cats.FlatMap Avoid this function if possible. If you can instead use product, ~, >, or < use that. flatMap always has to allocate a parser, and the parser is less amenable to optimization
parse one or more characters as long as they don't match p
parse one or more characters as long as they don't match p
parse zero or more characters as long as they don't match p this is useful for parsing comment strings, for instance.
parse zero or more characters as long as they don't match p this is useful for parsing comment strings, for instance.
discard the value in a Parser. This is an optimization because we remove trailing map operations and don't allocate internal data structures This function is called internal to Functor.as and Apply.> and Apply.< so those are good uses.
discard the value in a Parser. This is an optimization because we remove trailing map operations and don't allocate internal data structures This function is called internal to Functor.as and Apply.> and Apply.< so those are good uses.
discard the value in a Parser. This is an optimization because we remove trailing map operations and don't allocate internal data structures This function is called internal to Functor.as and Apply.> and Apply.< so those are good uses.
discard the value in a Parser. This is an optimization because we remove trailing map operations and don't allocate internal data structures This function is called internal to Functor.as and Apply.> and Apply.< so those are good uses.