pub struct GssHead<'i, I, S, TK>{
pub frontier: usize,
/* 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
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, 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, S, TK> Freeze for GssHead<'i, I, S, TK>
impl<'i, I, S, TK> RefUnwindSafe for GssHead<'i, I, S, TK>
impl<'i, I, S, TK> Send for GssHead<'i, I, S, TK>
impl<'i, I, S, TK> Sync for GssHead<'i, I, S, TK>
impl<'i, I, S, TK> Unpin for GssHead<'i, I, S, TK>
impl<'i, I, 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