Module base

Module base 

Source
Expand description

Common functions to drop in instead of reinventing the wheel.

Modules§

lang
Common patterns in programming languages.
precedence
Operator-precedence parsing, e.g. for infix math.

Structs§

AnySeq
Match any of a set of sequences of options. Set represented as a binary tree for efficient lookup.
Anything
Match any single item and return a reference to it.
End
Make sure we’ve reached exactly the end of the stream of input; don’t advance to it.
ExactSeq
Match exactly this sequence of items.
Optional
Parse if possible; otherwise, don’t move.
ParseWhile
Continue parsing while a predicate holds. Return a contiguous slice referencing the section of input that held.
Punctuated
Parse a punctuated (e.g. comma-separated) list of elements determined by the parsers passed in here.
PunctuatedMeaningfully
Parse a punctuated (e.g. by mathematical operators) list of elements determined by the parsers passed in here.
Runaway
Continue parsing as long as we can. Return a contiguous slice referencing the section of input that successfully parsed.

Functions§

any
Match any of a set of options. Set represented as a binary tree for efficient lookup.
any_seq
Match any of a set of sequences of options, preferring the longest applicable. Set represented as a binary tree for efficient lookup.
anything
Match any single item and return a reference to it.
comma_separated
Match any of a set of sequences of options. Set represented as a binary tree for efficient lookup.
digit
Match a single digit.
end
Make sure we’ve reached exactly the end of the stream of input; don’t advance to it.
exact
Match exactly this item and return a reference to the original (not the parsed one).
exact_seq
Match exactly this sequence of items.
lowercase
Match any lowercase letter and return a reference to it.
maybe_space
Match zero or more whitespace characters and return a reference to their contiguous slice.
need_space
Match one or more whitespace characters and return a reference to their contiguous slice.
not
Return anything that does not satisfy this predicate.
optional
Parse if possible; otherwise, don’t move.
parse_while
Match any of a set of sequences of options. Set represented as a binary tree for efficient lookup.
punctuated
Match any of a set of sequences of options. Set represented as a binary tree for efficient lookup.
punctuated_meaningfully
Match any of a set of sequences of options. Set represented as a binary tree for efficient lookup.
runaway
Match any of a set of sequences of options. Set represented as a binary tree for efficient lookup.
satisfy
Skip zero or more items while this predicate holds on them.
satisfy_result
Skip zero or more items while this predicate holds on them.
screaming_case
Match a SCREAMING_CASE term.
signed_integer
Match a base-ten signed integer.
snake_case
Match a snake_case term.
unsigned_integer
Match a base-ten unsigned integer.
uppercase
Match any uppercase letter and return a reference to it.