petitparser library

This package contains the core library of PetitParser, a dynamic parser combinator framework.

Classes

ActionParser<T, R>
A parser that performs a transformation with a given function on the successful parse result of the delegate.
AndParser<T>
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.
CharacterParser
Parser class for individual character classes.
CharacterPredicate
Abstract character predicate class.
ChoiceParser
A parser that uses the first parser that succeeds.
Context
An immutable parse context.
DelegateParser<R>
A parser that delegates to another one. Normally users do not need to directly use a delegate parser.
DigitCharPredicate
EndOfInputParser
A parser that succeeds at the end of input.
EpsilonParser<T>
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. [...]
Failure<R>
An immutable parse result in case of a failed parse.
FailureParser<T>
A parser that consumes nothing and fails.
FlattenParser
A parser that answers a substring of the range its delegate parses.
GrammarDefinition
Helper to conveniently define and build complex, recursive grammars using plain Dart code. [...]
GrammarParser
A helper to build a parser from a {@link GrammarDefinition}.
GreedyRepeatingParser<T>
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.
LazyRepeatingParser<T>
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<T>
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).
LowercaseCharPredicate
NotParser
The not-predicate, a parser that succeeds whenever its delegate does not, but consumes no input Parr 1994, 1995.
OptionalParser<T>
A parser that optionally parsers its delegate, or answers nil.
Parser<T>
Abstract base class of all parsers.
PositionParser
A parser that reports the current input position.
PossessiveRepeatingParser<T>
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<T>
An abstract parser that repeatedly parses between 'min' and 'max' instances of its delegate.
Result<R>
An immutable parse result.
SequenceParser
A parser that parses a sequence of parsers.
SettableParser<T>
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<T>
A parser that answers a token of the result its delegate parses.
TrimmingParser<T>
A parser that silently consumes input of another parser around its delegate.
UppercaseCharPredicate
WhitespaceCharPredicate
WordCharPredicate

Constants

unbounded → const int
An int used to mark an unbounded maximum repetition.
-1

Properties

pattern_ Parser<CharacterPredicate>
Parser that reads a possibly negated sequecne of predicates.
final
range_ Parser<RangeCharPredicate>
Parser that reads a character range.
final
sequence_ Parser<CharacterPredicate>
Parser that reads a sequence of single characters or ranges.
final
single_ Parser<RangeCharPredicate>
Parser that reads a single character.
final

Functions

any([String message = 'input expected' ]) Parser<String>
Returns a parser that accepts any input element. [...]
anyIn(String elements, [ String message ]) Parser<String>
Returns a parser that accepts any of the elements. [...]
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.
endOfInput([String message = 'end of input expected' ]) Parser
Returns a parser that succeeds at the end of input.
epsilon<T>([T result ]) Parser<T>
Returns a parser that consumes nothing and succeeds. [...]
failure<T>([String message = 'unable to parse' ]) Parser<T>
Returns a parser that consumes nothing and fails. [...]
letter([String message = 'letter expected' ]) Parser<String>
Returns a parser that accepts any letter character.
lowercase([String message = 'lowercase letter expected' ]) Parser<String>
Returns a parser that accepts any lowercase character.
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 the given character class pattern.
position() Parser
Returns a parser that reports the current input position.
predicate(int length, Predicate 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 given message.
range(Object start, Object stop, [ String message ]) Parser<String>
Returns a parser that accepts any character in the range between start and stop.
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<T>([String message = 'undefined parser' ]) SettableParser<T>
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.
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.

Typedefs

ActionCallback<T, R>(T value) → R
Typed action callback.
Predicate(String input) → bool
A generic predicate function returning true or false for a given input argument.

Exceptions / Errors

ParserException
An exception raised in case of a parse error.