pub struct Context<'i, I: Input + ?Sized> {
pub file: String,
pub input: &'i I,
pub position: usize,
pub range: Range<usize>,
pub location: Location,
pub layout: Option<&'i I>,
pub layout_ahead: Option<&'i I>,
}Expand description
Lexer context is used to keep the lexing state. It provides necessary information to parsers and actions.
Fields§
§file: StringFile path of the parsed content. <str> In case of static string.
input: &'i IThe input being parsed. Should be set when the context is created.
position: usizeAn absolute position in the input sequence
The input must be indexable type.
range: Range<usize>The range of token/non-terminal during shift/reduce operation.
location: LocationSimilar to position but has line/column format for text based inputs.
If this prove to be pricey overhead we might make tracking of this info configurable.
layout: Option<&'i I>Layout before the current token (e.g. whitespaces, comments…)
layout_ahead: Option<&'i I>Layout before the lookahead token (e.g. whitespaces, comments…)
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'i, I: ?Sized> RefUnwindSafe for Context<'i, I>where I: RefUnwindSafe,
impl<'i, I: ?Sized> Send for Context<'i, I>where I: Sync,
impl<'i, I: ?Sized> Sync for Context<'i, I>where I: Sync,
impl<'i, I: ?Sized> Unpin for Context<'i, I>
impl<'i, I: ?Sized> UnwindSafe for Context<'i, I>where I: RefUnwindSafe,
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