Trait nommy::Parse [−][src]
An interface for creating and composing parsers
Takes in a Buffer
iterator and consumes a subset of it,
Returning Self if it managed to parse ok, otherwise returning a meaningful error
Parse can be derived for some types
use nommy::{Parse, IntoBuf, text::Tag}; let mut buffer = ".".chars().into_buf(); Tag::<".">::parse(&mut buffer).unwrap();
Required methods
fn parse(input: &mut impl Buffer<T>) -> Result<Self>
[src]
Parse the input buffer, returning Ok if the value could be parsed, Otherwise, returns a meaningful error
Errors
Will return an error if the parser fails to interpret the input at any point
Provided methods
fn peek(input: &mut impl Buffer<T>) -> bool
[src]
Peek reads the input buffer, returning true if the value could be found, Otherwise, returns false. Not required, but usually provides better performance if implemented
Implementations on Foreign Types
impl<P: Parse<T>, T> Parse<T> for Option<P>
[src]
Result is None
if parsing P
fails, otherwise, result is Some(p)
fn parse(input: &mut impl Buffer<T>) -> Result<Self>
[src]
fn peek(input: &mut impl Buffer<T>) -> bool
[src]
impl<P: Parse<T>, T> Parse<T> for Vec<P>
[src]
Repeatedly attempts to parse P
, Result is all successful attempts
fn parse(input: &mut impl Buffer<T>) -> Result<Self>
[src]
Panics
If P
is able to parse 0 tokens successfully, it would result in an infinite loop.
In debug builds, we detect this and panic
use nommy::{IntoBuf, Parse, text::Tag}; let mut input = "...".chars().into_buf(); Vec::<Option<Tag<".">>>::parse(&mut input);
fn peek(input: &mut impl Buffer<T>) -> bool
[src]
impl<P: Parse<T>, T, const N: usize> Parse<T> for [P; N]
[src]
Parse P
N
times into [P; N]
, fails if any step fails
use nommy::{parse_terminated, text::Tag}; let _: [Tag<".">; 3] = parse_terminated("...".chars()).unwrap();
fn parse(input: &mut impl Buffer<T>) -> Result<Self>
[src]
fn peek(input: &mut impl Buffer<T>) -> bool
[src]
Implementors
impl Parse<char> for LineEnding
[src]
fn parse(input: &mut impl Buffer<char>) -> Result<Self>
[src]
fn peek(input: &mut impl Buffer<char>) -> bool
[src]
impl Parse<char> for Space
[src]
fn parse(input: &mut impl Buffer<char>) -> Result<Self>
[src]
fn peek(input: &mut impl Buffer<char>) -> bool
[src]
impl Parse<char> for WhiteSpace
[src]
fn parse(input: &mut impl Buffer<char>) -> Result<Self>
[src]
fn peek(input: &mut impl Buffer<char>) -> bool
[src]
impl<P: Parse<T>, T> Parse<T> for Vec1<P>
[src]
Repeatedly attempt to parse P
, Result is all successful attempts
Must parse P
at least once