Parser<T> class

Abstract base class of all parsers.

Implemented types
Implementers
Annotations
  • @optionalTypeArgs

Constructors

Parser()
const

Properties

children List<Parser>
Returns a list of directly referenced parsers. [...]
read-only
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

Methods

accept(String input) bool
Tests if the input can be successfully parsed. [...]
allMatches(String string, [int start = 0]) Iterable<Match>
Matches this parser against string repeatedly. [...]
override
and() Parser<T>
Returns a parser (logical and-predicate) that succeeds whenever the receiver does, but never consumes input. [...]
cast<R>() Parser<R>
Returns a parser that casts itself to Parser<R>.
castList<R>() Parser<List<R>>
Returns a parser that casts itself to Parser<List<R>>. Assumes this parser to be of type Parser<List>.
copy() Parser<T>
Returns a shallow copy of the receiver. [...]
end([String message = 'end of input expected']) Parser<T>
Returns a parser that succeeds only if the receiver consumes the complete input, otherwise return a failure with the optional message. [...]
fastParseOn(String buffer, int position) int
Primitive method doing the actual parsing. [...]
flatten([String message]) Parser<String>
Returns a parser that discards the result of the receiver, and returns a sub-string of the consumed range in the string/list being parsed. [...]
hasEqualChildren(Parser other, Set<Parser> seen) bool
Compare the children of two parsers. Normally this method should not be called directly, instead use Parser#equals. [...]
hasEqualProperties(covariant Parser<T> other) bool
Compare the properties of two parsers. Normally this method should not be called directly, instead use Parser#equals. [...]
isEqualTo(Parser other, [Set<Parser> seen]) bool
Recursively tests for structural equality of two parsers. [...]
map<R>(ActionCallback<T, R> callback, {bool hasSideEffects: false}) Parser<R>
Returns a parser that evaluates a callback as the production action on success of the receiver. [...]
matchAsPrefix(String string, [int start = 0]) Match
Match this pattern against the start of string. [...]
override
matches(String input) List<T>
Returns a list of all successful overlapping parses of the input. [...]
matchesSkipping(String input) List<T>
Returns a list of all successful non-overlapping parses of the input. [...]
neg([String message = 'input not expected']) Parser<String>
Returns a parser that consumes any input token (character), but the receiver. [...]
not([String message = 'success not expected']) Parser<void>
Returns a parser (logical not-predicate) that succeeds whenever the receiver fails, but never consumes input. [...]
optional([T otherwise]) Parser<T>
Returns new parser that accepts the receiver, if possible. The resulting parser returns the result of the receiver, or null if not applicable. The returned value can be provided as an optional argument otherwise. [...]
or(Parser other) Parser
Returns a parser that accepts the receiver or other. The resulting parser returns the parse result of the receiver, if the receiver fails it returns the parse result of other (exclusive ordered choice). [...]
parse(String input) Result<T>
Returns the parse result of the input. [...]
parseOn(Context context) Result<T>
Primitive method doing the actual parsing. [...]
permute<R>(List<int> indexes) Parser<List<R>>
Returns a parser that transforms a successful parse result by returning the permuted elements at indexes of a list. Negative indexes can be used to access the elements from the back of the list. Assumes this parser to be of type Parser<List<R>>. [...]
pick<R>(int index) Parser<R>
Returns a parser that transforms a successful parse result by returning the element at index of a list. A negative index can be used to access the elements from the back of the list. Assumes this parser to be of type Parser<List<R>>. [...]
plus() Parser<List<T>>
Returns a parser that accepts the receiver one or more times. The resulting parser returns a list of the parse results of the receiver. [...]
plusGreedy(Parser limit) Parser<List<T>>
Returns a parser that parses the receiver one or more times until it reaches limit. This is a greedy non-blind implementation of the Parser.plus operator. The limit is not consumed. [...]
plusLazy(Parser limit) Parser<List<T>>
Returns a parser that parses the receiver one or more times until it reaches a limit. This is a lazy non-blind implementation of the Parser.plus operator. The limit is not consumed. [...]
repeat(int min, [int max]) Parser<List<T>>
Returns a parser that accepts the receiver between min and max times. The resulting parser returns a list of the parse results of the receiver. [...]
repeatGreedy(Parser limit, int min, int max) Parser<List<T>>
Returns a parser that parses the receiver at least min and at most max times until it reaches a limit. This is a greedy non-blind implementation of the Parser.repeat operator. The limit is not consumed. [...]
repeatLazy(Parser limit, int min, int max) Parser<List<T>>
Returns a parser that parses the receiver at least min and at most max times until it reaches a limit. This is a lazy non-blind implementation of the Parser.repeat operator. The limit is not consumed. [...]
replace(Parser source, Parser target) → void
Changes the receiver by replacing source with target. Does nothing if source does not exist in Parser.children. [...]
separatedBy<R>(Parser separator, {bool includeSeparators: true, bool optionalSeparatorAtEnd: false}) Parser<List<R>>
Returns a parser that consumes the receiver one or more times separated by the separator parser. The resulting parser returns a flat list of the parse results of the receiver interleaved with the parse result of the separator parser. The type parameter R defines the type of the returned list. [...]
seq(Parser other) Parser<List>
Returns a parser that accepts the receiver followed by other. The resulting parser returns a list of the parse result of the receiver followed by the parse result of other. Calling this method on an existing sequence code does not nest this sequence into a new one, but instead augments the existing sequence with other. [...]
settable() SettableParser<T>
Returns a parser that points to the receiver, but can be changed to point to something else at a later point in time. [...]
star() Parser<List<T>>
Returns a parser that accepts the receiver zero or more times. The resulting parser returns a list of the parse results of the receiver. [...]
starGreedy(Parser limit) Parser<List<T>>
Returns a parser that parses the receiver zero or more times until it reaches a limit. This is a greedy non-blind implementation of the Parser.star operator. The limit is not consumed. [...]
starLazy(Parser limit) Parser<List<T>>
Returns a parser that parses the receiver zero or more times until it reaches a limit. This is a lazy non-blind implementation of the Parser.star operator. The limit is not consumed. [...]
times(int count) Parser<List<T>>
Returns a parser that accepts the receiver exactly count times. The resulting parser returns a list of the parse results of the receiver. [...]
token() Parser<Token<T>>
Returns a parser that returns a Token. The token carries the parsed value of the receiver Token.value, as well as the consumed input Token.input from Token.start to Token.stop of the input being parsed. [...]
trim([Parser left, Parser right]) Parser<T>
Returns a parser that consumes input before and after the receiver, discards the excess input and only returns returns the result of the receiver. The optional arguments are parsers that consume the excess input. By default whitespace() is used. Up to two arguments can be provided to have different parsers on the left and right side. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator &(Parser other) Parser<List>
Convenience operator returning a parser that accepts the receiver followed by other. See Parser.seq for details.
operator |(Parser other) Parser
Convenience operator returning a parser that accepts the receiver or other. See Parser.or for details.
operator ==(dynamic other) bool
The equality operator. [...]
inherited