pub struct GssHead<'i, I, S, TK>{
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>
impl<'i, I, S, TK> GssHead<'i, I, S, TK>
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
pub fn with_tok_state(&self, token_ahead: Token<'i, I, TK>, state: S) -> Self
pub fn with_tok(&self, token_ahead: Token<'i, I, TK>) -> Self
Trait Implementations§
source§impl<'i, S, I, TK> Context<'i, I, S, TK> for GssHead<'i, I, S, TK>
impl<'i, S, I, TK> Context<'i, I, S, TK> for GssHead<'i, I, S, TK>
fn set_state(&mut self, state: S)
fn set_position(&mut self, position: usize)
fn set_location(&mut self, location: Location)
fn set_range(&mut self, range: Range<usize>)
source§fn token_ahead(&self) -> Option<&Token<'i, I, TK>>
fn token_ahead(&self) -> Option<&Token<'i, I, TK>>
Next token recognized in the input at the current parsing location
fn set_token_ahead(&mut self, token: Token<'i, I, TK>)
source§fn layout_ahead(&self) -> Option<&'i I>
fn layout_ahead(&self) -> Option<&'i I>
A layout before the token ahead
fn set_layout_ahead(&mut self, layout: Option<&'i I>)
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>
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>
type Output = Forest<'i, I, P, TK>
source§fn parse(&self, input: &'i I) -> Result<Self::Output>
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>
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,
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>
impl<'i, I: ?Sized, S, TK> Sync for GssHead<'i, I, S, TK>
impl<'i, I: ?Sized, S, TK> Unpin for GssHead<'i, I, S, TK>
impl<'i, I: ?Sized, S, TK> UnwindSafe for GssHead<'i, I, S, TK>
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