Module container

Module container 

Source
Expand description

This module provides parsers for types that contain possibly multiple values. This includes stdlib types like Option, Vec, Box, Rc, RefCell and types for delimited and repeated values with numbered repeats.

Modules§

TrailingDelimiter
Policy for the delimiter of the last element in a sequence. Note that delimiters are after some element, for cases where you have leading delimiters you need to define grammars that start with Delimiter or Option<Delimiter>.

Structs§

DelimitedVec
Since the delimiter in Delimited<T,D> is optional a Vec<Delimited<T,D>> would parse consecutive values even without delimiters. DelimitedVec<T, D, MIN, MAX, P> will stop parsing by MIN/MAX number of elements and depending on the policy defined by P which can be one of TrailingDelimiter.
LazyVec
A Vec<T> that is filled up to the first appearance of an terminating S. This S may be a subset of T, thus parsing become lazy. This is the same as Cons<Vec<Cons<Except<S>,T>>,S> but more convenient and efficient.
LazyVecUntil
A Vec<T> that is filled up to the first appearance of an terminating S. This S may be a subset of T, thus parsing become lazy. Unlike LazyVec this variant does not consume the final terminator. This is the same as Vec<Cons<Except<S>,T>>> but more convenient.
NonEmptyOption
NonEmptyOption<T> prevents Option from matching when T can succeed with empty input. It ensures None is returned when no tokens remain, regardless of whether T could succeed on an empty stream. This is crucial when parsing optional trailing content that should only match if tokens are actually available to consume.

Traits§

RangedRepeats
A trait for parsing a repeating T with a minimum and maximum limit. Sometimes the number of elements to be parsed is determined at runtime eg. a number of header items needs a matching number of values.

Type Aliases§

Any
Any number of T delimited by D or Nothing
AtLeast
At least N of T delimited by D or Nothing
AtMost
At most N of T delimited by D or Nothing
ColonDelimitedVec
DelimitedVec of T delimited by : with P as policy for the last delimiter.
CommaDelimitedVec
DelimitedVec of T delimited by , with P as policy for the last delimiter.
DotDelimitedVec
DelimitedVec of T delimited by . with P as policy for the last delimiter.
Exactly
Exactly N of T delimited by D or Nothing
Many
One or more of T delimited by D or Nothing
Optional
Zero or one of T delimited by D or Nothing
PathSepDelimitedVec
DelimitedVec of T delimited by :: with P as policy for the last delimiter.
Repeats
DelimitedVec<T,D> with a minimum and maximum (inclusive) number of elements at first without defaults. Parsing will succeed when at least the minimum number of elements is reached and stop at the maximum number. The delimiter D defaults to Nothing to parse sequences which don’t have delimiters.
SemicolonDelimitedVec
DelimitedVec of T delimited by ; with P as policy for the last delimiter.