Parser<T> class

A parser combinator, which can parse very complicated grammars in a manageable manner.





hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


and(Parser other) Parser<T>
Consumes this and another parser, but only considers the result of this parser.
back(int amount) Parser<T>
Moves backward a certain amount of steps after parsing, if it was successful.
cache() Parser<T>
Caches the results of parse attempts at various locations within the source text. [...]
cast<U extends T>() Parser<U>
Casts this parser to produce U objects.
castDynamic() Parser
Casts this parser to produce dynamic objects.
change<U>(ParseResult<U> f(ParseResult<T>)) Parser<U>
Runs the given function, which changes the returned ParseResult into one relating to a U object.
check(Matcher matcher, {String errorMessage, SyntaxErrorSeverity severity}) Parser<T>
Validates the parse result against a Matcher. [...]
error({String errorMessage, SyntaxErrorSeverity severity}) Parser<T>
Binds an errorMessage to a copy of this parser.
foldErrors({bool equal(SyntaxError a, SyntaxError b)}) Parser<T>
Removes multiple errors that occur in the same spot; this can reduce noise in parser output.
forward(int amount) Parser<T>
Skips forward a certain amount of steps after parsing, if it was successful.
map<U>(U f(ParseResult<T>)) Parser<U>
Transforms the parse result using a unary function.
maxDepth(int depth) Parser<T>
Prevents recursion past a certain depth, preventing stack overflow errors.
maybeParenthesized() Parser<T>
Parses this, either as-is or wrapped in parentheses.
negate({String errorMessage, SyntaxErrorSeverity severity}) Parser<T>
Ensures this pattern is not matched. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
opt({bool backtrack = true}) Parser<T>
Produces an optional copy of this parser. [...]
or<U>(Parser<T> other) Parser<T>
Shortcut for or-ing two parsers.
parenthesized() Parser<T>
Parses this, wrapped in parentheses.
parse(SpanScanner scanner, [int depth = 1]) ParseResult<T>
Parses text from a SpanScanner.
plus() ListParser<T>
Parses this sequence one or more times.
safe({bool backtrack = true, String errorMessage, SyntaxErrorSeverity severity}) Parser<T>
Safely escapes this parser when an error occurs. [...]
separatedBy(Parser other) Parser<List<T>>
Expects to see an infinite amounts of the pattern, separated by the other pattern. [...]
separatedByComma() Parser<List<T>>
space() Parser<T>
Consumes any trailing whitespace.
star({bool backtrack = true}) ListParser<T>
Consumes 0 or more instance(s) of this parser.
stringify(CodeBuffer buffer) → void
Prints a representation of this parser, ideally without causing a stack overflow.
surroundedBy(Parser left, [Parser right]) Parser<T>
Expects to see the pattern, surrounded by the others. [...]
surroundedByCurlyBraces({T defaultValue}) Parser<T>
surroundedBySquareBrackets({T defaultValue}) Parser<T>
then(Parser other) ListParser
Shortcut for chain-ing two parsers together.
times(int count, {bool exact = true, String tooFew, String tooMany, bool backtrack = true, SyntaxErrorSeverity severity}) ListParser<T>
Expect this pattern a certain number of times. [...]
toList() ListParser<T>
Casts this instance into a ListParser.
toString() String
A string representation of this object. [...]
trail(Pattern pattern) Parser<T>
Consumes and ignores any trailing occurrences of pattern.
value(T f(ParseResult<T>)) Parser<T>
Sets the value of the ParseResult.


operator &(Parser<T> other) Parser<T>
operator ==(Object other) bool
The equality operator. [...]
operator |(Parser<T> other) Parser<T>
operator ~() Parser<T>