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.

  • SpanLines, SpanBytes, SpanStr to get context information around a Span. Can also retrieve line/column information.

All of the extras can be easily cfg’ed away for a release build. Usually it’s just cfg(debug_assertions) vs cfg(not(debug_assertions)) to change the Input type from TrackSpan to plain &str.

Re-exports

Modules

  • Provides some extra parser combinators.
  • Error type, nom::error::Error replacement.
  • Struct definitions for the postfix parsers.
  • Prelude, import the traits.
  • Additions to LocatedSpan, str and [u8]
  • Test framework for parsers.
  • Second, simpler error type. Same size as nom::error::Error.
  • Everything related to tracking in a parser.

Traits

  • Parser error code.
  • Analog function for err_into() working on a parser, but working on the Result instead.
  • This trait is used in a few places where the function wants to accept both E and nom::Err<E>.
  • This trait catches the essentials for an error type within this library.
  • Adds some common parser combinators as postfix operators to parser.

Type Definitions