LabelParser<R> class
A parser that always defers to its delegate, but that also holds a label for debugging purposes.
- Inheritance
-
- Object
- Parser<
R> - DelegateParser<
R, R> - LabelParser
- Implemented types
- Available extensions
- AcceptParser
- AndParserExtension
- CastListParserExtension
- CastParserExtension
- ChoiceParserExtension
- ContinuationParserExtension
- EndOfInputParserExtension
- FlattenParserExtension
- GreedyRepeatingParserExtension
- LabelParserExtension
- LazyRepeatingParserExtension
- MapParserExtension
- MatchesParser
- MatchesSkippingParser
- NotParserExtension
- OptionalParserExtension
- PatternParserExtension
- PermuteParserExtension
- PickParserExtension
- PossessiveRepeatingParserExtension
- SeparatedBy
- SequenceParserExtension
- SettableParserExtension
- TokenParserExtension
- TrimmingParserExtension
- WhereParserExtension
Constructors
-
LabelParser.new(Parser<
R> delegate, String label)
Properties
-
children
→ List<
Parser> -
Returns a list of directly referenced parsers.
no setterinherited
-
delegate
↔ Parser<
R> -
The parser this parser delegates to.
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- label → String
-
Label of this parser.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
accept(
String input) → bool -
Available on Parser<
Tests if theT> , provided by the AcceptParser extensioninput
can be successfully parsed. -
and(
) → Parser< T> -
Available on Parser<
Returns a parser (logical and-predicate) that succeeds whenever the receiver does, but never consumes input.T> , provided by the AndParserExtension extension -
callCC<
R> (ContinuationHandler< T, R> handler) → Parser<R> -
Available on Parser<
Returns a parser that when activated captures a continuation function and passes it together with the current context into the handler.T> , provided by the ContinuationParserExtension extension -
cast<
R> () → Parser< R> -
Available on Parser<
Returns a parser that casts itself toT> , provided by the CastParserExtension extensionParser<R>
. -
castList<
R> () → Parser< List< R> > -
Available on Parser<
Returns a parser that casts itself toT> , provided by the CastListParserExtension extensionParser<List<R>>
. Assumes this parser to be of typeParser<List>
. -
copy(
) → LabelParser< R> -
Returns a shallow copy of the receiver.
override
-
end(
[String message = 'end of input expected']) → Parser< T> -
Available on Parser<
Returns a parser that succeeds only if the receiver consumes the complete input, otherwise return a failure with the optionalT> , provided by the EndOfInputParserExtension extensionmessage
. -
fastParseOn(
String buffer, int position) → int -
Primitive method doing the actual parsing.
override
-
flatten(
[String? message]) → Parser< String> -
Available on Parser<
Returns a parser that discards the result of the receiver and answers the sub-string its delegate consumes.T> , provided by the FlattenParserExtension extension -
hasEqualChildren(
covariant Parser other, Set< Parser> seen) → bool -
Compare the children of two parsers.
inherited
-
hasEqualProperties(
covariant LabelParser< R> other) → bool -
Compare the properties of two parsers.
override
-
isEqualTo(
Parser other, [Set< Parser> ? seen]) → bool -
Recursively tests for structural equality of two parsers.
inherited
-
labeled(
String label) → LabeledParser< R> -
Available on Parser<
Returns a parser that simply defers to its delegate, but that has aR> , provided by the LabelParserExtension extensionlabel
for debugging purposes. -
map<
R> (Callback< T, R> callback, {bool hasSideEffects = false}) → Parser<R> -
Available on Parser<
Returns a parser that evaluates aT> , provided by the MapParserExtension extensioncallback
as the production action on success of the receiver. -
matches(
String input) → List< T> -
Available on Parser<
Returns a list of all successful overlapping parses of theT> , provided by the MatchesParser extensioninput
. -
matchesSkipping(
String input) → List< T> -
Available on Parser<
Returns a list of all successful non-overlapping parses of the input.T> , provided by the MatchesSkippingParser extension -
neg(
[String message = 'input not expected']) → Parser< String> -
Available on Parser<
Returns a parser that consumes any input token (character), but the receiver.T> , provided by the NotParserExtension extension -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
not(
[String message = 'success not expected']) → Parser< Failure< T> > -
Available on Parser<
Returns a parser (logical not-predicate) that succeeds with the Failure whenever the receiver fails, but never consumes input.T> , provided by the NotParserExtension extension -
optional(
) → Parser< T?> -
Available on Parser<
Returns new parser that accepts the receiver, if possible. The resulting parser returns the result of the receiver, orT> , provided by the OptionalParserExtension extensionnull
if not applicable. -
optionalWith(
T value) → Parser< T> -
Available on Parser<
Returns new parser that accepts the receiver, if possible. The resulting parser returns the result of the receiver, orT> , provided by the OptionalParserExtension extensionvalue
if not applicable. -
or(
Parser other, {FailureJoiner? failureJoiner}) → ChoiceParser -
Available on Parser, provided by the ChoiceParserExtension extension
Returns a parser that accepts the receiver orother
. The resulting parser returns the parse result of the receiver, if the receiver fails it returns the parse result ofother
(exclusive ordered choice). -
parse(
String input) → Result< R> -
Returns the parse result of the
input
.inherited -
parseOn(
Context context) → Result< R> -
Primitive method doing the actual parsing.
override
-
permute(
List< int> indexes) → Parser<List< T> > -
Available on Parser<
Returns a parser that transforms a successful parse result by returning the permuted elements atList< , provided by the PermuteParserExtension extensionT> >indexes
of a list. Negative indexes can be used to access the elements from the back of the list. -
pick(
int index) → Parser< T> -
Available on Parser<
Returns a parser that transforms a successful parse result by returning the element atList< , provided by the PickParserExtension extensionT> >index
of a list. A negative index can be used to access the elements from the back of the list. -
plus(
) → Parser< List< T> > -
Available on Parser<
Returns a parser that accepts the receiver one or more times. The resulting parser returns a list of the parse results of the receiver.T> , provided by the PossessiveRepeatingParserExtension extension -
plusGreedy(
Parser< void> limit) → Parser<List< T> > -
Available on Parser<
Returns a parser that parses the receiver one or more times until it reachesT> , provided by the GreedyRepeatingParserExtension extensionlimit
. This is a greedy non-blind implementation of the plus operator. Thelimit
is not consumed. -
plusLazy(
Parser< void> limit) → Parser<List< T> > -
Available on Parser<
Returns a parser that parses the receiver one or more times until it reaches aT> , provided by the LazyRepeatingParserExtension extensionlimit
. This is a lazy non-blind implementation of the plus operator. Thelimit
is not consumed. -
repeat(
int min, [int? max]) → Parser< List< T> > -
Available on Parser<
Returns a parser that accepts the receiver betweenT> , provided by the PossessiveRepeatingParserExtension extensionmin
andmax
times. The resulting parser returns a list of the parse results of the receiver. -
repeatGreedy(
Parser< void> limit, int min, int max) → Parser<List< T> > -
Available on Parser<
Returns a parser that parses the receiver at leastT> , provided by the GreedyRepeatingParserExtension extensionmin
and at mostmax
times until it reaches alimit
. This is a greedy non-blind implementation of the repeat operator. Thelimit
is not consumed. -
repeatLazy(
Parser< void> limit, int min, int max) → Parser<List< T> > -
Available on Parser<
Returns a parser that parses the receiver at leastT> , provided by the LazyRepeatingParserExtension extensionmin
and at mostmax
times until it reaches alimit
. This is a lazy non-blind implementation of the repeat operator. Thelimit
is not consumed. -
replace(
Parser source, Parser target) → void -
Changes the receiver by replacing
source
withtarget
. Does nothing ifsource
does not exist in Parser.children.inherited -
separatedBy<
R> (Parser separator, {bool includeSeparators = true, bool optionalSeparatorAtEnd = false}) → Parser< List< R> > -
Available on Parser<
Returns a parser that consumes the receiver one or more times separated by theT> , provided by the SeparatedBy extensionseparator
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 parameterR
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 byother
. The resulting parser returns a list of the parse result of the receiver followed by the parse result ofother
. Calling this method on an existing sequence code does not nest this sequence into a new one, but instead augments the existing sequence withother
. -
settable(
) → SettableParser< T> -
Available on Parser<
Returns a parser that points to the receiver, but can be changed to point to something else at a later point in time.T> , provided by the SettableParserExtension extension -
star(
) → Parser< List< T> > -
Available on Parser<
Returns a parser that accepts the receiver zero or more times. The resulting parser returns a list of the parse results of the receiver.T> , provided by the PossessiveRepeatingParserExtension extension -
starGreedy(
Parser< void> limit) → Parser<List< T> > -
Available on Parser<
Returns a parser that parses the receiver zero or more times until it reaches aT> , provided by the GreedyRepeatingParserExtension extensionlimit
. This is a greedy non-blind implementation of the star operator. Thelimit
is not consumed. -
starLazy(
Parser< void> limit) → Parser<List< T> > -
Available on Parser<
Returns a parser that parses the receiver zero or more times until it reaches aT> , provided by the LazyRepeatingParserExtension extensionlimit
. This is a lazy non-blind implementation of the star operator. Thelimit
is not consumed. -
times(
int count) → Parser< List< T> > -
Available on Parser<
Returns a parser that accepts the receiver exactlyT> , provided by the PossessiveRepeatingParserExtension extensioncount
times. The resulting parser returns a list of the parse results of the receiver. -
token(
) → Parser< Token< T> > -
Available on Parser<
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.T> , provided by the TokenParserExtension extension -
toPattern(
) → Pattern -
Available on Parser<
Converts this Parser into a Pattern for basic searches within strings.T> , provided by the PatternParserExtension extension -
toString(
) → String -
A string representation of this object.
override
-
trim(
[Parser< void> ? left, Parser<void> ? right]) → Parser<T> -
Available on Parser<
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 defaultT> , provided by the TrimmingParserExtension extensionwhitespace()
is used. Up to two arguments can be provided to have different parsers on theleft
andright
side. -
where(
Predicate< T> predicate, {Callback<T, String> ? failureMessage, Callback<T, int> ? failurePosition}) → Parser<T> -
Available on Parser<
Returns a parser that evaluates theT> , provided by the WhereParserExtension extensionpredicate
with the successful parse result. If the predicate returnstrue
the parser proceeds with the parse result, otherwise a parse failure is created using the optionally specifiedfailureMessage
andfailurePosition
callbacks.
Operators
-
operator &(
Parser other) → Parser< List> -
Available on Parser, provided by the SequenceParserExtension extension
Convenience operator returning a parser that accepts the receiver followed byother
. 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 orother
. See or for details.