Crate ruminant

Source
Expand description

§ruminant, a parser combinator library

Deprecated See my latest stab at this: parser-compose

⚠️ Warning ☣️
Homemade, hand-rolled code ahead. Experimental. May not function as advertised.

This is an introduction by example. For a first-principles introduction to parser combinators see here.

  • A parser is a function that takes some input in, extracts some information and returns the result of this extraction. In order to make any progress, the result contains the leftover input after consuming some part of it, or in the case of error returns some value indicating failure.

  • A combinator takes one or more parsers as input and returns a different parser. They are useful for uhh…combining multiple parsers together or even changing what parsers do.

With only these two ideas the world becomes your oyster.

Examples coming sooon

Modules§

byte
Parsers that recognize bytes + associated combinators
combinator
Generic functions for combining parsers (aka combinators)
str
Parsers that recognize strings + associated combinators

Macros§

parsers
Creates a list of parsers

Structs§

NoMatch
The default error indicating the parser could not extract a value

Type Aliases§

BoxedParser
Type alias for dynamically dispatched parsers.
Input
The input to a parser. Parser input is always a byte slice
ParseResult
Calling the parser returns a Result. The Ok variant contains the extracted value along with the rest of the input. The Err variant is generic, but it defaults to NoMatch.
Rest
Leftover bytes after a parser has extracted a value.