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
- Parsers that recognize bytes + associated combinators
- Generic functions for combining parsers (aka combinators)
- Parsers that recognize strings + associated combinators
Macros
- Creates a list of parsers
Structs
- The default error indicating the parser could not extract a value
Type Aliases
- Type alias for dynamically dispatched parsers.
- The input to a parser. Parser input is always a byte slice
- Calling the parser returns a
Result
. TheOk
variant contains the extracted value along with the rest of the input. TheErr
variant is generic, but it defaults to NoMatch. - Leftover bytes after a parser has extracted a value.