Crate parser_compose
source ·Expand description
See the README.md for a crash course in parser combinators.
The crate is logically organized into three parts
Parsers
Any rust item that implements the Parser trait can parse input by calling try_parse()
Additionally the Parser
trait is implemented for all function with a particular signature.
Parser combinators
The associated methods on the Parser trait are used to combine with other parsers.
The sequence combinator is so common that it has a special form. Tuples of parsers implement
Parser
such that the tuple parser succeeds if all its parsers succeed.
Errors
parser-compose
take a simple approach to error handling: Builtin parsers report errors by
appendding to a Failurelog
. If the top level parser fails, the result
will contain an instance of this structure.
Examples
Checkout the integration test directory for concrete parsing examples.
Structs
- See
and_then()
- A log of parser failures sorted by input position in descending order.
- See
fold()
- See
map()
. - See
optional()
- See
or()
- Container for input into parsers
- A parsing error
- See
peek()
- See
when()
- See
utf8_str
Enums
- The reason parsing failed
Traits
- A trait for parsers
- Trait used to specify how many times a parser should run.
Functions
- A parser that recognizes the first item in a slice.
- A parser that recognizes the first unicode scalar value at the start of a string slice.
- A parser that succeeds if there is no more input to consume.
- Returns a parser that recognizes the first unicode scalar value in a string slice if its value is in the specified range