petitparser library
This package exports the core library of PetitParser, a dynamic parser combinator framework.
Classes
-
AndParser<
R> -
The and-predicate, a parser that succeeds whenever its delegate does, but
does not consume the input stream
Parr 1994, 1995
. - AnyParser
- A parser that accepts any input element.
-
CastListParser<
T, R> -
A parser that casts a
Result<List>
to aResult<List<R>>
. -
CastParser<
T, R> -
A parser that casts a
Result
to aResult<R>
. - CharacterParser
- Parser class for individual character classes.
- CharacterPredicate
- Abstract character predicate class.
-
ChoiceParser<
T> - A parser that uses the first parser that succeeds.
- Context
- An immutable parse context.
-
ContinuationParser<
T, R> - Continuation parser that when activated captures a continuation function and passes it together with the current context into the handler.
-
DelegateParser<
T, R> -
An abstract parser that delegates to a parser of type
T
. - DigitCharPredicate
- EndOfInputParser
- A parser that succeeds at the end of input.
-
EpsilonParser<
R> - A parser that consumes nothing and succeeds.
- ExpressionBuilder
- A builder that allows the simple definition of expression grammars with prefix, postfix, and left- and right-associative infix operators.
- ExpressionGroup
- Models a group of operators of the same precedence.
-
Failure<
R> - An immutable parse result in case of a failed parse.
-
FailureParser<
R> - A parser that consumes nothing and fails.
-
FlattenParser<
T> - A parser that discards the result of the delegate and answers the sub-string its delegate consumes.
- GrammarDefinition
- Helper to conveniently define and build complex, recursive grammars using plain Dart code.
-
GrammarParser<
T> - A (now pointless) helper to build a parser from a {@link GrammarDefinition}.
-
GreedyRepeatingParser<
R> - A greedy repeating parser, commonly seen in regular expression implementations. It aggressively consumes as much input as possible and then backtracks to meet the 'limit' condition.
-
LabeledParser<
R> - Interface of a parser that has a debug label.
-
LabelParser<
R> - A parser that always defers to its delegate, but that also holds a label for debugging purposes.
-
LazyRepeatingParser<
R> - A lazy repeating parser, commonly seen in regular expression implementations. It limits its consumption to meet the 'limit' condition as early as possible.
- LetterCharPredicate
-
LimitedRepeatingParser<
R> - An abstract parser that repeatedly parses between 'min' and 'max' instances of its delegate and that requires the input to be completed with a specified parser 'limit'. Subclasses provide repeating behavior as typically seen in regular expression implementations (non-blind).
-
ListParser<
T, R> - Abstract parser that parses a list of things in some way.
- LowercaseCharPredicate
-
MapParser<
T, R> - A parser that performs a transformation with a given function on the successful parse result of the delegate.
-
NotParser<
R> -
The not-predicate, a parser that succeeds whenever its delegate does not,
but consumes no input
Parr 1994, 1995
. -
OptionalParser<
R> -
A parser that optionally parsers its delegate, or answers
null
. -
Parser<
R> -
Abstract base class of all parsers that produce a parse result of type
R
. - PatternParser
- A parser that uses a Pattern matcher for parsing.
-
PermuteParser<
R> - A parser that performs a transformation with a given function on the successful parse result of the delegate.
-
PickParser<
R> - A parser that performs a transformation with a given function on the successful parse result of the delegate.
- PositionParser
- A parser that reports the current input position.
-
PossessiveRepeatingParser<
R> - A greedy parser that repeatedly parses between 'min' and 'max' instances of its delegate.
- PredicateParser
- A parser for a literal satisfying a predicate.
- RangeCharPredicate
-
RepeatingParser<
R> - An abstract parser that repeatedly parses between 'min' and 'max' instances of its delegate.
-
ResolvableParser<
R> - Interface of a parser that can be resolved to another one.
-
Result<
R> - An immutable parse result.
-
SequenceParser<
T> - A parser that parses a sequence of parsers.
-
SettableParser<
R> - A parser that is not defined, but that can be set at a later point in time.
- SingleCharPredicate
-
Success<
R> - An immutable parse result in case of a successful parse.
-
Token<
T> - A token represents a parsed part of the input stream.
-
TokenParser<
R> - A parser that creates a token of the result its delegate parses.
-
TrimmingParser<
R> - A parser that silently consumes input of another parser around its delegate.
- UppercaseCharPredicate
-
WhereParser<
T> - WhitespaceCharPredicate
- WordCharPredicate
Extensions
-
AcceptParser
on Parser<
T> -
AndParserExtension
on Parser<
T> -
CastListParserExtension
on Parser<
T> -
CastParserExtension
on Parser<
T> -
ChoiceIterableExtension
on Iterable<
Parser< T> > - ChoiceParserExtension on Parser
-
ContinuationParserExtension
on Parser<
T> -
EndOfInputParserExtension
on Parser<
T> -
FlattenParserExtension
on Parser<
T> -
GreedyRepeatingParserExtension
on Parser<
T> -
LabelParserExtension
on Parser<
R> -
LazyRepeatingParserExtension
on Parser<
T> -
MapParserExtension
on Parser<
T> -
MatchesParser
on Parser<
T> -
MatchesSkippingParser
on Parser<
T> -
NotParserExtension
on Parser<
T> -
OptionalParserExtension
on Parser<
T> -
PatternParserExtension
on Parser<
T> -
PermuteParserExtension
on Parser<
List< T> > -
PickParserExtension
on Parser<
List< T> > -
PossessiveRepeatingParserExtension
on Parser<
T> - PredicateStringExtension on String
-
SeparatedBy
on Parser<
T> -
SequenceIterableExtension
on Iterable<
Parser< T> > - SequenceParserExtension on Parser
-
SettableParserExtension
on Parser<
T> -
TokenParserExtension
on Parser<
T> -
TrimmingParserExtension
on Parser<
T> -
WhereParserExtension
on Parser<
T>
Functions
-
any(
[String message = 'input expected']) → Parser< String> - Returns a parser that accepts any input element.
-
anyOf(
String chars, [String? message]) → Parser< String> - Returns a parser that accepts any of the specified characters.
-
char(
Object char, [String? message]) → Parser< String> - Returns a parser that accepts a specific character only.
-
digit(
[String message = 'digit expected']) → Parser< String> -
Returns a parser that accepts any digit character. The accepted input is
equivalent to the character-set
0-9
. -
endOfInput(
[String message = 'end of input expected']) → Parser< void> - Returns a parser that succeeds at the end of input.
-
epsilon(
) → Parser< void> - Returns a parser that consumes nothing and succeeds.
-
epsilonWith<
R> (R result) → Parser< R> -
Returns a parser that consumes nothing and succeeds with
result
. -
failure<
R> ([String message = 'unable to parse']) → Parser< R> - Returns a parser that consumes nothing and fails.
-
letter(
[String message = 'letter expected']) → Parser< String> -
Returns a parser that accepts any letter character (lowercase or uppercase).
The accepted input is equivalent to the character-set
a-zA-Z
. -
lowercase(
[String message = 'lowercase letter expected']) → Parser< String> -
Returns a parser that accepts any lowercase character. The accepted input is
equivalent to the character-set
a-z
. -
noneOf(
String chars, [String? message]) → Parser< String> - Returns a parser that accepts none of the specified characters.
-
pattern(
String element, [String? message]) → Parser< String> - Returns a parser that accepts a single character of a given character set provided as a string.
-
patternIgnoreCase(
String element, [String? message]) → Parser< String> - Returns a parser that accepts a single character of a given case-insensitive character set provided as a string.
-
position(
) → Parser - Returns a parser that reports the current input position.
-
predicate(
int length, Predicate< String> predicate, String message) → Parser<String> -
Returns a parser that reads input of the specified
length
, accepts it if the predicate matches, or fails with the givenmessage
. -
range(
Object start, Object stop, [String? message]) → Parser< String> -
Returns a parser that accepts any character in the range
between
start
andstop
. -
ref<
T> (Function function, [dynamic arg1 = undefined, dynamic arg2 = undefined, dynamic arg3 = undefined, dynamic arg4 = undefined, dynamic arg5 = undefined, dynamic arg6 = undefined, dynamic arg7 = undefined, dynamic arg8 = undefined, dynamic arg9 = undefined]) → Parser< T> -
Creates a Parser from a
function
reference, possibly with the given argumentsarg1
,arg2
,arg3
, ... -
ref0<
T> (Parser< T> function()) → Parser<T> -
Creates a Parser from a
function
without arguments. -
ref1<
T, A1> (Parser< T> function(A1), A1 arg1) → Parser<T> -
Reference to a production
function
parametrized with 1 argument. -
ref2<
T, A1, A2> (Parser< T> function(A1, A2), A1 arg1, A2 arg2) → Parser<T> -
Reference to a production
function
parametrized with 2 arguments. -
ref3<
T, A1, A2, A3> (Parser< T> function(A1, A2, A3), A1 arg1, A2 arg2, A3 arg3) → Parser<T> -
Reference to a production
function
parametrized with 3 arguments. -
ref4<
T, A1, A2, A3, A4> (Parser< T> function(A1, A2, A3, A4), A1 arg1, A2 arg2, A3 arg3, A4 arg4) → Parser<T> -
Reference to a production
function
parametrized with 4 arguments. -
ref5<
T, A1, A2, A3, A4, A5> (Parser< T> function(A1, A2, A3, A4, A5), A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5) → Parser<T> -
Reference to a production
function
parametrized with 5 arguments. -
ref6<
T, A1, A2, A3, A4, A5, A6> (Parser< T> function(A1, A2, A3, A4, A5, A6), A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6) → Parser<T> -
Reference to a production
function
parametrized with 6 arguments. -
ref7<
T, A1, A2, A3, A4, A5, A6, A7> (Parser< T> function(A1, A2, A3, A4, A5, A6, A7), A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6, A7 arg7) → Parser<T> -
Reference to a production
function
parametrized with 7 arguments. -
ref8<
T, A1, A2, A3, A4, A5, A6, A7, A8> (Parser< T> function(A1, A2, A3, A4, A5, A6, A7, A8), A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6, A7 arg7, A8 arg8) → Parser<T> -
Reference to a production
function
parametrized with 8 arguments. -
ref9<
T, A1, A2, A3, A4, A5, A6, A7, A8, A9> (Parser< T> function(A1, A2, A3, A4, A5, A6, A7, A8, A9), A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6, A7 arg7, A8 arg8, A9 arg9) → Parser<T> -
Reference to a production
function
parametrized with 9 arguments. -
resolve<
T> (Parser< T> parser) → Parser<T> -
Resolves all parser references reachable through
parser
. Returns an optimized parser graph that inlines all references directly. -
selectFarthest<
T> (Failure< T> first, Failure<T> second) → Failure<T> - Reports the parser failure farthest down in the input string, preferring later failures over earlier ones.
-
selectFarthestJoined<
T> (Failure< T> first, Failure<T> second) → Failure<T> - Reports the parser failure farthest down in the input string, joining error messages at the same position.
-
selectFirst<
T> (Failure< T> first, Failure<T> second) → Failure<T> - Reports the first parse failure observed.
-
selectLast<
T> (Failure< T> first, Failure<T> second) → Failure<T> - Reports the last parse failure observed (default).
-
string(
String element, [String? message]) → Parser< String> -
Returns a parser that accepts the string
element
. -
stringIgnoreCase(
String element, [String? message]) → Parser< String> -
Returns a parser that accepts the string
element
ignoring the case. -
undefined<
R> ([String message = 'undefined parser']) → SettableParser< R> - Returns a parser that is not defined, but that can be set at a later point in time.
-
uppercase(
[String message = 'uppercase letter expected']) → Parser< String> -
Returns a parser that accepts any uppercase character. The accepted input is
equivalent to the character-set
A-Z
. -
whitespace(
[String message = 'whitespace expected']) → Parser< String> - Returns a parser that accepts any whitespace character.
-
word(
[String message = 'letter or digit expected']) → Parser< String> -
Returns a parser that accepts any word character (lowercase, uppercase,
underscore, or digit). The accepted input is equivalent to the character-set
a-zA-Z_0-9
.
Typedefs
-
ContinuationFunction<
T> = Result< T> Function(Context context) - Continuation function of the ContinuationHandler.
-
ContinuationHandler<
T, R> = Result< R> Function(ContinuationFunction<T> continuation, Context context) - Handler function for the ContinuationParser.
-
FailureJoiner<
T> = Failure< T> Function(Failure<T> first, Failure<T> second) - Function definition that joins parse Failure instances.
Exceptions / Errors
- ParserException
- An exception raised in case of a parse error.