PatternParser class

A parser that uses a Pattern matcher for parsing.

This parser wraps Pattern.matchAsPrefix in a Parser. This works for any implementation of Pattern, but can lead to very inefficient parsers when not used carefully.

Inheritance

Constructors

PatternParser(Pattern pattern, String message)

Properties

children List<Parser>
Returns a list of directly referenced parsers.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
message String
Error message to annotate parse failures with.
final
pattern Pattern
The Pattern matcher this parser uses.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

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.
inherited
copy() PatternParser
Returns a shallow copy of the receiver.
override
fastParseOn(String buffer, int position) int
Primitive method doing the actual parsing.
override
hasEqualChildren(covariant Parser other, Set<Parser> seen) bool
Compare the children of two parsers.
inherited
hasEqualProperties(covariant PatternParser 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
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse(String input, {int start = 0}) Result<Match>
Returns the parse result of the input.
inherited
parseOn(Context context) Result<Match>
Primitive method doing the actual parsing.
override
replace(Parser source, Parser target) → void
Changes the receiver by replacing source with target. Does nothing if source does not exist in Parser.children.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited