Trait nommy::Parse[][src]

pub trait Parse<T>: Sized {
    fn parse(input: &mut impl Buffer<T>) -> Result<Self>;

    fn peek(input: &mut impl Buffer<T>) -> bool { ... }
}

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

Loading content...

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

Loading content...

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)

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);

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();
Loading content...

Implementors

impl Parse<char> for LineEnding[src]

impl Parse<char> for Space[src]

impl Parse<char> for WhiteSpace[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

impl<const BYTES: &'static [u8]> Parse<u8> for nommy::bytes::AnyOf1<BYTES>[src]

impl<const BYTES: &'static [u8]> Parse<u8> for nommy::bytes::OneOf<BYTES>[src]

impl<const CHARS: &'static str> Parse<char> for nommy::text::AnyOf1<CHARS>[src]

impl<const CHARS: &'static str> Parse<char> for AnyOf<CHARS>[src]

impl<const CHARS: &'static str> Parse<char> for nommy::text::OneOf<CHARS>[src]

impl<const CHARS: &'static str> Parse<char> for WhileNot1<CHARS>[src]

impl<const TAG: &'static str> Parse<char> for nommy::text::Tag<TAG>[src]

impl<const TAG: &'static [u8]> Parse<u8> for nommy::bytes::Tag<TAG>[src]

Loading content...