Crate kparse

Source
Expand description

Addons for a nom parser.

  • A error code trait.

  • A richer error type ParserError.

  • A thin error type TokenizerError.

  • A tracking/logging system for the parser.

  • A simple framework to test parser functions.

  • Took some inspiration from nom_supreme and implemented a similar subset of postfix functions. They are integrated with the error Code and the error types of this crate.

  • SourceStr and SourceBytes to get context information around a Span. Can retrieve line/column information and context data without burdening every single span.

  • Uses LocatedSpan for debug builds and replaces with plan &str or &[u8] for release builds. Tracking is compiled away completely for release builds.

Re-exports§

pub use crate::parser_error::ParserError;
pub use crate::token_error::TokenizerError;

Modules§

combinators
Provides some extra parser combinators.
examples
Types used in doc tests.
parser_error
Error type, nom::error::Error replacement.
prelude
Prelude for all traits.
provider
source
spans
Additions to LocatedSpan, str and [u8]
test
Test framework for parsers.
token_error
Second, simpler error type. Same size as nom::error::Error.

Macros§

define_span
Defines a type alias for the span type. Switches between ParseSpan<> in debug mode and plain type in release mode.

Structs§

Track
Central struct for tracking.

Traits§

Code
Parser error code.
ErrInto
Analog function for err_into() working on a parser, but working on the Result instead.
ErrOrNomErr
This trait is used for Track.err() where the function wants to accept both E and nom::Err<E>.
KParseError
This trait catches the essentials for an error type within this library.
KParser
Adds some common parser combinators as postfix operators to parser.
TrackResult
This is an extension trait for nom-Results.
TrackedSpan
This trait is implemented for an input type. It takes a tracking event and its raw data, converts if necessary and sends it to the actual tracker.

Type Aliases§

DynTrackProvider
Standard input type. This is a LocatedSpan with a TrackProvider.
ParseSpan
ParserResult
ParserResult for ParserError. Equivalent to nom::IResult<(I, O), ParserError<C, I>>
TokenizerResult
ParserResult for TokenizerError.
Equivalent to nom::IResult<(I, O), TokenizerError<C, I>>