Struct rustemo::GssHead

source ·
pub struct GssHead<'i, I, S, TK>
where I: Input + ?Sized,
{ pub frontier: usize, pub position_ahead: usize, pub position_before: usize, pub location_pos_ahead: Position, pub location_pos_before: Position, /* private fields */ }
Expand description

A node/head in the Graph Structured Stack (GSS). Implements Context for GLR parsing.

Each head is related to a LR parser state and a single token ahead. Lexical ambiguity, where a head may be followed by multiple different tokens, is handled by splitting the head and using the same GLR mechanics for syntax ambiguity handling. Effectively, we have per-token sub-frontiers.

Fields§

§frontier: usize

A frontier this node belongs to

§position_ahead: usize

The start of the first token ahead (after the layout)

§position_before: usize

The end position of the last token before this head

§location_pos_ahead: Position

The start of the first token ahead as input-specific position

§location_pos_before: Position

The end position of the last token before this head as an input-specific position

Implementations§

source§

impl<'i, I, S, TK> GssHead<'i, I, S, TK>
where I: Input + ?Sized, S: State, TK: Copy,

source

pub fn new( state: S, frontier: usize, position: usize, range: Range<usize>, location: Location, position_ahead: usize, position_before: usize, location_pos_ahead: Position, location_pos_before: Position, layout_ahead: Option<&'i I>, token_ahead: Option<Token<'i, I, TK>> ) -> Self

source

pub fn with_tok_state(&self, token_ahead: Token<'i, I, TK>, state: S) -> Self

source

pub fn with_tok(&self, token_ahead: Token<'i, I, TK>) -> Self

Trait Implementations§

source§

impl<'i, I, S, TK> Clone for GssHead<'i, I, S, TK>
where I: Input + ?Sized, S: State, TK: Copy,

source§

fn clone(&self) -> Self

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<'i, S, I, TK> Context<'i, I, S, TK> for GssHead<'i, I, S, TK>
where I: Input + ?Sized, S: State,

source§

fn state(&self) -> S

The current parser state.
source§

fn set_state(&mut self, state: S)

source§

fn position(&self) -> usize

An absolute position in the input sequence Read more
source§

fn set_position(&mut self, position: usize)

source§

fn location(&self) -> Location

A span in the input sequence, possibly in line-column style.
source§

fn set_location(&mut self, location: Location)

source§

fn range(&self) -> Range<usize>

A span in the input sequence
source§

fn set_range(&mut self, range: Range<usize>)

source§

fn token_ahead(&self) -> Option<&Token<'i, I, TK>>

Next token recognized in the input at the current parsing location
source§

fn set_token_ahead(&mut self, token: Token<'i, I, TK>)

source§

fn layout_ahead(&self) -> Option<&'i I>

A layout before the token ahead
source§

fn set_layout_ahead(&mut self, layout: Option<&'i I>)

source§

impl<'i, I, S: Debug, TK: Debug> Debug for GssHead<'i, I, S, TK>
where I: Input + ?Sized + Debug,

source§

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

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

impl<'i, I: Input + ?Sized, S: Default, TK> Default for GssHead<'i, I, S, TK>

source§

fn default() -> Self

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

impl<'i, I, S, TK, NTK, L, P, D, B> Parser<'i, I, GssHead<'i, I, S, TK>, S, TK> for GlrParser<'i, S, L, P, TK, NTK, D, I, B>
where I: Input + ?Sized + Debug, L: Lexer<'i, GssHead<'i, I, S, TK>, S, TK, Input = I>, S: State + Debug + Ord, P: Copy + Debug + Into<NTK> + PartialEq, TK: Copy + Debug + Ord + Default + 'i, D: ParserDefinition<S, P, TK, NTK>,

§

type Output = Forest<'i, I, P, TK>

source§

fn parse(&self, input: &'i I) -> Result<Self::Output>

Parse the given input and produce the result. The output type is set by the parser implementers and it is usually defined by the builder if the building is done during the parse process.
source§

fn parse_with_context( &self, context: &mut GssHead<'i, I, S, TK>, input: &'i I ) -> Result<Self::Output>

Parse with the given context which has information about the current parsing state (e.g. position, location). Used in situation when we need to continue parsing from a specific state, like in parsing the layout from the current location.
source§

fn parse_file<'a, F: AsRef<Path>>(&'a mut self, file: F) -> Result<Self::Output>
where 'a: 'i,

A convenience method for loading the content from the given file and calling parse. The parser will own the content being parsed and thus has to outlive Self::Output if it borrows from the content loaded from the file.

Auto Trait Implementations§

§

impl<'i, I: ?Sized, S, TK> RefUnwindSafe for GssHead<'i, I, S, TK>

§

impl<'i, I: ?Sized, S, TK> Send for GssHead<'i, I, S, TK>
where I: Sync, S: Send, TK: Send,

§

impl<'i, I: ?Sized, S, TK> Sync for GssHead<'i, I, S, TK>
where I: Sync, S: Sync, TK: Sync,

§

impl<'i, I: ?Sized, S, TK> Unpin for GssHead<'i, I, S, TK>
where S: Unpin, TK: Unpin,

§

impl<'i, I: ?Sized, S, TK> UnwindSafe for GssHead<'i, I, S, TK>

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> 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,

§

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>,

§

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>,

§

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.