pub trait ParserExtra<'a, I>: Sealedwhere
I: Input<'a>,{
type Error: Error<'a, I>;
type State: Inspector<'a, I>;
type Context: 'a;
}Expand description
A trait for extra types on a Parser that control the behavior of certain combinators and output.
Currently, this consists of the error type emitted, the state type used in the *_state combinators,
and the context type used in the *_ctx and *configure parsers.
This trait is sealed and so cannot be implemented by other crates because all uses should instead go through the types defined in this module.
Required Associated Types§
Sourcetype Error: Error<'a, I>
type Error: Error<'a, I>
Error type to use for the parser. This type must implement Error, and when it fails,
the parser will return a set of this type to describe why the failure occurred.
Sourcetype State: Inspector<'a, I>
type State: Inspector<'a, I>
State type to use for the parser. This is used to provide stateful output of the parser,
such as interned identifiers or position-dependent name resolution, however cannot influence
the actual progress of the parser - for that, use Self::Context.
For examples of using this type, see Parser::map_with or Parser::foldl_with.
Sourcetype Context: 'a
type Context: 'a
Context used for parser configuration. This is used to provide context-sensitive parsing of input.
Context-sensitive parsing in chumsky is always left-hand sensitive - context for the parse must originate
from an earlier point in the stream than the parser relying on it. This can affect the output of a parser,
but for things that don’t wish to alter the actual rules of parsing, one should instead prefer Self::State.
For examples of using this type, see Parser::ignore_with_ctx, Parser::then_with_ctx and ConfigParser::configure.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".