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>
impl<'a> ParserState<'a>
pub fn new(data: &'a [u8]) -> Self
Sourcepub fn get_arg_count(&self, name: &NameString) -> Option<u8>
pub fn get_arg_count(&self, name: &NameString) -> Option<u8>
Get the argument count of the named method, if it is declared
Sourcepub 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>,
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.
Sourcepub fn lift<P, O, E>(
parser: P,
) -> impl FnMut(ParserState<'a>) -> AMLParseResult<'a, O, E>
pub fn lift<P, O, E>( parser: P, ) -> impl FnMut(ParserState<'a>) -> AMLParseResult<'a, O, E>
Wraps a byte-oriented parser to work with ParserState
Trait Implementations§
Source§impl AsBytes for ParserState<'_>
impl AsBytes for ParserState<'_>
Source§impl<'a> Clone for ParserState<'a>
impl<'a> Clone for ParserState<'a>
Source§fn clone(&self) -> ParserState<'a>
fn clone(&self) -> ParserState<'a>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a> Debug for ParserState<'a>
impl<'a> Debug for ParserState<'a>
Source§impl<'a> Default for ParserState<'a>
impl<'a> Default for ParserState<'a>
Source§fn default() -> ParserState<'a>
fn default() -> ParserState<'a>
Returns the “default value” for a type. Read more
Source§impl<'a> From<&'a [u8]> for ParserState<'a>
impl<'a> From<&'a [u8]> for ParserState<'a>
Source§impl<'a> InputIter for ParserState<'a>
impl<'a> InputIter for ParserState<'a>
Source§type Item = <&'a [u8] as InputIter>::Item
type Item = <&'a [u8] as InputIter>::Item
The current input type is a sequence of that
Item
type. Read moreSource§type Iter = <&'a [u8] as InputIter>::Iter
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 characterSource§type IterElem = <&'a [u8] as InputIter>::IterElem
type IterElem = <&'a [u8] as InputIter>::IterElem
An iterator over the input type, producing the item
Source§fn iter_indices(&self) -> Self::Iter
fn iter_indices(&self) -> Self::Iter
Returns an iterator over the elements and their byte offsets
Source§fn iter_elements(&self) -> Self::IterElem
fn iter_elements(&self) -> Self::IterElem
Returns an iterator over the elements
Source§impl InputLength for ParserState<'_>
impl InputLength for ParserState<'_>
Source§impl<'a> PartialEq for ParserState<'a>
impl<'a> PartialEq for ParserState<'a>
impl<'a> Eq for ParserState<'a>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more