A parser that recognises whitespace.
A parser that recognises whitespace. Normal whitespace handling is
turned off while this parser is applied, since we need to avoid an
infinite recursion if the form of whitespace is defined using
literal
or regex
.
As for Parser
but for the non-backtracking version OnceParser
.
As for Parser
but for the non-backtracking version OnceParser
.
Make a new parser that processes input according to f
.
Make a new parser that processes input according to f
. If the
result produced by f
is Positioned
, set its start and finish
positions. If the parser is ignoring whitespace then the start
position will be the first non-white character that was accepted.
A parser that matches any element, failing if the end of input is reached.
A parser that matches any element, failing if the end of input is reached.
Convenience conversion to allow arity two functions to be used directly in tree construction actions.
Convenience conversion to allow arity two functions to be used directly in tree construction actions.
Convenience conversion to allow arity three functions to be used directly in tree construction actions.
Convenience conversion to allow arity three functions to be used directly in tree construction actions.
Convenience conversion to allow arity four functions to be used directly in tree construction actions.
Convenience conversion to allow arity four functions to be used directly in tree construction actions.
Convenience conversion to allow arity five functions to be used directly in tree construction actions.
Convenience conversion to allow arity five functions to be used directly in tree construction actions.
Convenience conversion to allow arity six functions to be used directly in tree construction actions.
Convenience conversion to allow arity six functions to be used directly in tree construction actions.
Parse digit strings that are constrained to fit into an Int
value.
Parse digit strings that are constrained to fit into an Int
value.
If the digit string is too big, a parse error results.
Return an error after skipping white space.
Return an error after skipping white space.
Return a failure after skipping white space.
Return a failure after skipping white space.
Version of handleWhiteSpace
that accepts an Input
value and
skips over whitespace defined by the parser.
Version of handleWhiteSpace
that accepts an Input
value and
skips over whitespace defined by the parser. Used with
PositionedParserUtilities
so that correct positions are used.
Parser for keywords.
Parser for keywords. The list of string arguments gives the text
of the keywords in a language. The regular expression gives the
possible extension of the keyword to stop the keyword being seen as
an identifier instead. For example, the keyword list might contain
"begin"
and "end"
and the extension regular expression might
be [^a-zA-Z0-9]
. Thus,
begin followed by something other than
a letter or digit is a keyword, but
beginfoo8 is an identifier.
This parser succeeds if any of the keywords is present, provided
that it's not immediately followed by something that extends it.
A parser that matches a literal string after skipping any
whitespace that is parsed by whitespaceParser
.
A parser that matches a literal string after skipping any
whitespace that is parsed by whitespaceParser
.
Run a parse function on some input and if the result is Positioned
set its positions.
Run a parse function on some input and if the result is Positioned
set its positions.
Convenience conversion to lift parsers that return 2-tilde-tuples to parsers that return regular 2-tuples.
Convenience conversion to lift parsers that return 2-tilde-tuples to parsers that return regular 2-tuples.
Convenience conversion to lift parsers that return 3-tilde-tuples to parsers that return regular 3-tuples.
Convenience conversion to lift parsers that return 3-tilde-tuples to parsers that return regular 3-tuples.
Convenience conversion to lift parsers that return 4-tilde-tuples to parsers that return regular 4-tuples.
Convenience conversion to lift parsers that return 4-tilde-tuples to parsers that return regular 4-tuples.
Convenience conversion to lift parsers that return 5-tilde-tuples to parsers that return regular 5-tuples.
Convenience conversion to lift parsers that return 5-tilde-tuples to parsers that return regular 5-tuples.
Convenience conversion to lift parsers that return 6-tilde-tuples to parsers that return regular 6-tuples.
Convenience conversion to lift parsers that return 6-tilde-tuples to parsers that return regular 6-tuples.
Use parser
to parse the string str
.
Use parser
to parse the string str
. If the parse is sucessful and produces
the value t
, return Left (t)
. Otherwise, return Right (msg)
where msg
is the mesage produced by the parser.
If we are parsing whitespace already, fail if we are the end of the input, otherwise succeed with no progress.
If we are parsing whitespace already, fail if we are the end of the input, otherwise succeed with no progress. If we are not already parsing whitespace, then apply the whitespace parser, swallowing any errors from it unless they occur at the end of the input. In other words, an error not at the end is treated as the absence of whitespace.
Are we currently parsing whitespace?
Are we currently parsing whitespace?
As for positioned in RegexParsers
, but uses parseWhitespace
to skip whitespace.
As for positioned in RegexParsers
, but uses parseWhitespace
to skip whitespace.
A parser that matches a regex string after skipping any
whitespace that is parsed by whitespaceParser
.
A parser that matches a regex string after skipping any
whitespace that is parsed by whitespaceParser
.
Create a parser that matches a regex string, but doesn't skip whitespace first.
Create a parser that matches a regex string, but doesn't skip whitespace
first. This operation is useful if you want to recognise parts of a lexical
symbol with different regular expressions so you can use the parts
separately. Otherwise you have to parse with one regex and then split the
resulting string to get at its parts. Based on RegexParser.regex
in the
Scala library.
(Changed in version 2.9.0) The p0
call-by-name arguments is evaluated at most once per constructed Parser object, instead of on every need that arises during parsing.
Construct a parser that always succeeds and returns value v
.
Construct a parser that always succeeds and returns value v
. See
also the success
combinator in the Scala library that does something
similar but always returns the same value each time since the parameter
is not passed by name.
Convert the digit string s
to an Int
if it's in range, but return an
error message if it's too big.
Convert the digit string s
to an Int
if it's in range, but return an
error message if it's too big.
Wrap a parser p
that produces a value of type T
to produce a
parser returning values of type U
.
Wrap a parser p
that produces a value of type T
to produce a
parser returning values of type U
. Whitespace is skipped (if
we are skipping white space) before p
is applied, so that we
have access to the first non-whitespace position.
The function f
is responsible for converting the T
value into
either a U
value or a string that indicates what went wrong.
In the latter case, the resulting parser will error at the
original position with the message, ignoring any other errors
at that position. Failures or errors of p
will be lifted to
the returned type.
(Since version 2.10.0) lastNoSuccess was not thread-safe and will be removed in 2.11.0
(Since version 2.10.0) lastNoSuccess was not thread-safe and will be removed in 2.11.0
Combination of positioned parsing utilities and whitespace handling with a parser.