Struct ParserState

Source
pub struct ParserState<'a> {
    pub data: &'a [u8],
    pub current_scope: Vec<NameSeg>,
    pub method_signatures: Vec<MethodSignature>,
}
Expand description

Input data plus context needed to disambiguate grammar

Fields§

§data: &'a [u8]§current_scope: Vec<NameSeg>§method_signatures: Vec<MethodSignature>

Implementations§

Source§

impl<'a> ParserState<'a>

Source

pub fn new(data: &'a [u8]) -> Self

Source

pub fn get_arg_count(&self, name: &NameString) -> Option<u8>

Get the argument count of the named method, if it is declared

Source

pub fn in_scope<P, O, E>( self, new_scope: &NameString, parser: P, ) -> AMLParseResult<'a, O, E>
where P: Parser<ParserState<'a>, O, E>, E: AMLParseError<'a>,

Execute a parser in a new scope relative to the current scope, then restore the original scope.

§Errors

Fails if the given scope is invalid when resolved against the current scope (because it falls outside the namespace root), or when the inner parser fails.

Source

pub fn lift<P, O, E>( parser: P, ) -> impl FnMut(ParserState<'a>) -> AMLParseResult<'a, O, E>
where P: Parser<&'a [u8], O, E::From>, E: AMLParseError<'a>,

Wraps a byte-oriented parser to work with ParserState

Trait Implementations§

Source§

impl AsBytes for ParserState<'_>

Source§

fn as_bytes(&self) -> &[u8]

Casts the input type to a byte slice
Source§

impl<'a> Clone for ParserState<'a>

Source§

fn clone(&self) -> ParserState<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for ParserState<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for ParserState<'a>

Source§

fn default() -> ParserState<'a>

Returns the “default value” for a type. Read more
Source§

impl<'a> From<&'a [u8]> for ParserState<'a>

Source§

fn from(data: &'a [u8]) -> Self

Converts to this type from the input type.
Source§

impl<'a> InputIter for ParserState<'a>

Source§

type Item = <&'a [u8] as InputIter>::Item

The current input type is a sequence of that Item type. Read more
Source§

type Iter = <&'a [u8] as InputIter>::Iter

An iterator over the input type, producing the item and its position for use with [Slice]. If we’re iterating over &str, the position corresponds to the byte index of the character
Source§

type IterElem = <&'a [u8] as InputIter>::IterElem

An iterator over the input type, producing the item
Source§

fn iter_indices(&self) -> Self::Iter

Returns an iterator over the elements and their byte offsets
Source§

fn iter_elements(&self) -> Self::IterElem

Returns an iterator over the elements
Source§

fn position<P: Fn(Self::Item) -> bool>(&self, pred: P) -> Option<usize>

Finds the byte position of the element
Source§

fn slice_index(&self, i: usize) -> Result<usize, Needed>

Get the byte offset from the element’s position in the stream
Source§

impl InputLength for ParserState<'_>

Source§

fn input_len(&self) -> usize

Calculates the input length, as indicated by its name, and the name of the trait itself
Source§

impl<'a> PartialEq for ParserState<'a>

Source§

fn eq(&self, other: &ParserState<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for ParserState<'a>

Source§

impl<'a> StructuralPartialEq for ParserState<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for ParserState<'a>

§

impl<'a> RefUnwindSafe for ParserState<'a>

§

impl<'a> Send for ParserState<'a>

§

impl<'a> Sync for ParserState<'a>

§

impl<'a> Unpin for ParserState<'a>

§

impl<'a> UnwindSafe for ParserState<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.