Parser<R> class abstract

Abstract base class of all parsers that produce a parse result of type R.

Implementers
Available extensions
Annotations
  • @optionalTypeArgs

Constructors

Parser()

Properties

children List<Parser>
Returns a list of directly referenced parsers.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

accept(String input, {int start = 0}) bool

Available on Parser<R>, provided by the AcceptParser extension

Tests if the input can be successfully parsed.
allMatches(String input, {int start = 0, bool overlapping = false}) Iterable<T>

Available on Parser<T>, provided by the MatchesParserExtension extension

Returns a lazy iterable over all non-overlapping successful parse results of type T over the provided input.
and() Parser<R>

Available on Parser<R>, provided by the AndParserExtension extension

Returns a parser (logical and-predicate) that succeeds whenever the receiver does, but never consumes input.
callCC<S>(ContinuationHandler<R, S> handler) Parser<S>

Available on Parser<R>, provided by the ContinuationParserExtension extension

Returns a parser that when activated captures a continuation function and passes it together with the current context into the handler.
captureResultGeneric<T>(T callback<R>(Parser<R> self)) → T
Internal helper to capture the generic type R of the parse result. This makes it possible to wrap the parser without loosing type information.
cast<S>() Parser<S>

Available on Parser<R>, provided by the CastParserExtension extension

Returns a parser that casts itself to Parser<R>.
castList<S>() Parser<List<S>>

Available on Parser<R>, provided by the CastListParserExtension extension

Returns a parser that casts itself to Parser<List<R>>. Assumes this parser to be of type Parser<List>.
copy() Parser<R>
Returns a shallow copy of the receiver.
end([String message = 'end of input expected']) Parser<R>

Available on Parser<R>, provided by the EndOfInputParserExtension extension

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>

Available on Parser<R>, provided by the FlattenParserExtension extension

Returns a parser that discards the result of the receiver and answers the sub-string its delegate consumes.
hasEqualChildren(covariant Parser other, Set<Parser> seen) bool
Compare the children of two parsers.
hasEqualProperties(covariant Parser other) bool
Compare the properties of two parsers.
isEqualTo(Parser other, [Set<Parser>? seen]) bool
Recursively tests for structural equality of two parsers.
labeled(String label) LabeledParser<R>

Available on Parser<R>, provided by the LabelParserExtension extension

Returns a parser that simply defers to its delegate, but that has a label for debugging purposes.
map<S>(Callback<R, S> callback, {bool hasSideEffects = false}) Parser<S>

Available on Parser<R>, provided by the MapParserExtension extension

Returns a parser that evaluates a callback as the production action on success of the receiver.
map2<R>(R callback(T1, T2), {bool hasSideEffects = false}) Parser<R>

Available on Parser<(T1, T2)>, provided by the RecordParserExtension2 extension

Maps a parsed Record to R using the provided callback, see MapParserExtension.map for details.
map3<R>(R callback(T1, T2, T3), {bool hasSideEffects = false}) Parser<R>

Available on Parser<(T1, T2, T3)>, provided by the RecordParserExtension3 extension

Maps a parsed Record to R using the provided callback, see MapParserExtension.map for details.
map4<R>(R callback(T1, T2, T3, T4), {bool hasSideEffects = false}) Parser<R>

Available on Parser<(T1, T2, T3, T4)>, provided by the RecordParserExtension4 extension

Maps a parsed Record to R using the provided callback, see MapParserExtension.map for details.
map5<R>(R callback(T1, T2, T3, T4, T5), {bool hasSideEffects = false}) Parser<R>

Available on Parser<(T1, T2, T3, T4, T5)>, provided by the RecordParserExtension5 extension

Maps a parsed Record to R using the provided callback, see MapParserExtension.map for details.
map6<R>(R callback(T1, T2, T3, T4, T5, T6), {bool hasSideEffects = false}) Parser<R>

Available on Parser<(T1, T2, T3, T4, T5, T6)>, provided by the RecordParserExtension6 extension

Maps a parsed Record to R using the provided callback, see MapParserExtension.map for details.
map7<R>(R callback(T1, T2, T3, T4, T5, T6, T7), {bool hasSideEffects = false}) Parser<R>

Available on Parser<(T1, T2, T3, T4, T5, T6, T7)>, provided by the RecordParserExtension7 extension

Maps a parsed Record to R using the provided callback, see MapParserExtension.map for details.
map8<R>(R callback(T1, T2, T3, T4, T5, T6, T7, T8), {bool hasSideEffects = false}) Parser<R>

Available on Parser<(T1, T2, T3, T4, T5, T6, T7, T8)>, provided by the RecordParserExtension8 extension

Maps a parsed Record to R using the provided callback, see MapParserExtension.map for details.
map9<R>(R callback(T1, T2, T3, T4, T5, T6, T7, T8, T9), {bool hasSideEffects = false}) Parser<R>

Available on Parser<(T1, T2, T3, T4, T5, T6, T7, T8, T9)>, provided by the RecordParserExtension9 extension

Maps a parsed Record to R using the provided callback, see MapParserExtension.map for details.
matches(String input) List<T>

Available on Parser<T>, provided by the MatchesParserExtension extension

Returns a list of all successful overlapping parses of input.
matchesSkipping(String input) List<T>

Available on Parser<T>, provided by the MatchesParserExtension extension

Returns a list of all successful non-overlapping parses of input.
neg([String message = 'input not expected']) Parser<String>

Available on Parser<R>, provided by the NotParserExtension extension

Returns a parser that consumes any input token (character), but the receiver.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
not([String message = 'success not expected']) Parser<Failure>

Available on Parser<R>, provided by the NotParserExtension extension

Returns a parser (logical not-predicate) that succeeds with the Failure whenever the receiver fails, but never consumes input.
optional() Parser<R?>

Available on Parser<R>, provided by the OptionalParserExtension extension

Returns new parser that accepts the receiver, if possible. The resulting parser returns the result of the receiver, or null if not applicable.
optionalWith(R value) Parser<R>

Available on Parser<R>, provided by the OptionalParserExtension extension

Returns new parser that accepts the receiver, if possible. The resulting parser returns the result of the receiver, or value if not applicable.
or(Parser other, {FailureJoiner? failureJoiner}) ChoiceParser

Available on Parser, provided by the ChoiceParserExtension extension

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, {int start = 0}) Result<R>
Returns the parse result of the input.
parseOn(Context context) Result<R>
Primitive method doing the actual parsing.
permute(List<int> indexes) Parser<List<R>>

Available on Parser<List<R>>, provided by the PermuteParserExtension extension

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.
pick(int index) Parser<R>

Available on Parser<List<R>>, provided by the PickParserExtension extension

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.
plus() Parser<List<R>>

Available on Parser<R>, provided by the PossessiveRepeatingParserExtension extension

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<void> limit) Parser<List<R>>

Available on Parser<R>, provided by the GreedyRepeatingParserExtension extension

Returns a parser that parses the receiver one or more times until it reaches limit. This is a greedy non-blind implementation of the PossessiveRepeatingParserExtension.plus operator. The limit is not consumed.
plusLazy(Parser<void> limit) Parser<List<R>>

Available on Parser<R>, provided by the LazyRepeatingParserExtension extension

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 PossessiveRepeatingParserExtension.plus operator. The limit is not consumed.
plusSeparated<S>(Parser<S> separator) Parser<SeparatedList<R, S>>

Available on Parser<R>, provided by the SeparatedRepeatingParserExtension extension

Returns a parser that consumes the receiver one or more times separated by the separator parser. The resulting parser returns a SeparatedList containing collections of both the elements of type R as well as the separators of type S.
plusString([String? message]) Parser<String>

Available on Parser<String>, provided by the RepeatingCharacterParserExtension extension

Returns a parser that accepts the receiver one or more times. The resulting parser returns the consumed input string.
repeat(int min, [int? max]) Parser<List<R>>

Available on Parser<R>, provided by the PossessiveRepeatingParserExtension extension

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<void> limit, int min, int max) Parser<List<R>>

Available on Parser<R>, provided by the GreedyRepeatingParserExtension extension

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 PossessiveRepeatingParserExtension.repeat operator. The limit is not consumed.
repeatLazy(Parser<void> limit, int min, int max) Parser<List<R>>

Available on Parser<R>, provided by the LazyRepeatingParserExtension extension

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 PossessiveRepeatingParserExtension.repeat operator. The limit is not consumed.
repeatSeparated<S>(Parser<S> separator, int min, int max) Parser<SeparatedList<R, S>>

Available on Parser<R>, provided by the SeparatedRepeatingParserExtension extension

Returns a parser that consumes the receiver between min and max times separated by the separator parser. The resulting parser returns a SeparatedList containing collections of both the elements of type R as well as the separators of type S.
repeatString(int min, [int? max, String? message]) Parser<String>

Available on Parser<String>, provided by the RepeatingCharacterParserExtension extension

Returns a parser that accepts the receiver between min and max times. The resulting parser returns the consumed input string.
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 optionalSeparatorAtStart = false, bool optionalSeparatorAtEnd = false}) Parser<List<R>>

Available on Parser<T>, provided by the SeparatedByParserExtension extension

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>

Available on Parser, provided by the SequenceParserExtension extension

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<R>

Available on Parser<R>, provided by the SettableParserExtension extension

Returns a parser that points to the receiver, but can be changed to point to something else at a later point in time.
skip({Parser<void>? before, Parser<void>? after}) Parser<R>

Available on Parser<R>, provided by the SkipParserExtension extension

Returns a parser that consumes input before and after the receiver, but discards the parse results of before and after and only returns the result of the receiver.
star() Parser<List<R>>

Available on Parser<R>, provided by the PossessiveRepeatingParserExtension extension

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<void> limit) Parser<List<R>>

Available on Parser<R>, provided by the GreedyRepeatingParserExtension extension

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 PossessiveRepeatingParserExtension.star operator. The limit is not consumed.
starLazy(Parser<void> limit) Parser<List<R>>

Available on Parser<R>, provided by the LazyRepeatingParserExtension extension

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 PossessiveRepeatingParserExtension.star operator. The limit is not consumed.
starSeparated<S>(Parser<S> separator) Parser<SeparatedList<R, S>>

Available on Parser<R>, provided by the SeparatedRepeatingParserExtension extension

Returns a parser that consumes the receiver zero or more times separated by the separator parser. The resulting parser returns a SeparatedList containing collections of both the elements of type R as well as the separators of type S.
starString([String? message]) Parser<String>

Available on Parser<String>, provided by the RepeatingCharacterParserExtension extension

Returns a parser that accepts the receiver zero or more times. The resulting parser returns the consumed input string.
times(int count) Parser<List<R>>

Available on Parser<R>, provided by the PossessiveRepeatingParserExtension extension

Returns a parser that accepts the receiver exactly count times. The resulting parser returns a list of the parse results of the receiver.
timesSeparated<S>(Parser<S> separator, int count) Parser<SeparatedList<R, S>>

Available on Parser<R>, provided by the SeparatedRepeatingParserExtension extension

Returns a parser that consumes the receiver count times separated by the separator parser. The resulting parser returns a SeparatedList containing collections of both the elements of type R as well as the separators of type S.
timesString(int count, [String? message]) Parser<String>

Available on Parser<String>, provided by the RepeatingCharacterParserExtension extension

Returns a parser that accepts the receiver exactly count times. The resulting parser returns the consumed input string.
token() Parser<Token<R>>

Available on Parser<R>, provided by the TokenParserExtension extension

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.
toPattern() Pattern

Available on Parser<R>, provided by the PatternParserExtension extension

Converts this Parser into a Pattern for basic searches within strings.
toString() String
A string representation of this object.
override
trim([Parser<void>? left, Parser<void>? right]) Parser<R>

Available on Parser<R>, provided by the TrimmingParserExtension extension

Returns a parser that consumes input before and after the receiver, discards the excess input and only 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.
where(Predicate<R> predicate, {String? message, FailureFactory<R>? factory, Callback<R, String>? failureMessage, Callback<R, int>? failurePosition, FailureFactory<R>? failureFactory}) Parser<R>

Available on Parser<R>, provided by the WhereParserExtension extension

Returns a parser that evaluates the predicate with the successful parse result. If the predicate returns true the parser proceeds with the parse result, otherwise a parse failure is created using the optionally specified factory callback, the provided message, or otherwise an automatically created error message.

Operators

operator &(Parser other) Parser<List>

Available on Parser, provided by the SequenceParserExtension extension

Convenience operator returning a parser that accepts the receiver followed by other. See seq for details.
operator ==(Object other) bool
The equality operator.
inherited
operator |(Parser other) ChoiceParser

Available on Parser, provided by the ChoiceParserExtension extension

Convenience operator returning a parser that accepts the receiver or other. See or for details.