Struct antlr_rust::lexer::BaseLexer
source · [−]pub struct BaseLexer<'input, T: LexerRecog<'input, Self> + 'static, Input: CharStream<TF::From>, TF: TokenFactory<'input> = CommonTokenFactory> {
pub interpreter: Option<Box<LexerATNSimulator>>,
pub input: Option<Input>,
pub token_start_char_index: isize,
pub token_start_line: isize,
pub token_start_column: isize,
pub token_type: isize,
pub token: Option<TF::Tok>,
pub channel: isize,
pub mode_stack: Vec<usize>,
pub mode: usize,
pub text: Option<<TF::Data as ToOwned>::Owned>,
/* private fields */
}
Expand description
Default implementation of Lexer
Public fields in this struct are intended to be used by embedded actions
Fields
interpreter: Option<Box<LexerATNSimulator>>
LexerATNSimulator
instance of this lexer
input: Option<Input>
CharStream
used by this lexer
token_start_char_index: isize
token_start_line: isize
token_start_column: isize
token_type: isize
Overrides token type emitted by lexer for current token
token: Option<TF::Tok>
Make it Some
to override token that is currently being generated by lexer
channel: isize
Channel lexer is currently assigning tokens to
mode_stack: Vec<usize>
stack of modes, which is used for pushMode,popMode lexer actions
mode: usize
Mode lexer is currently in
text: Option<<TF::Data as ToOwned>::Owned>
Make it Some
to override text for token that is currently being generated by lexer
Implementations
sourceimpl<'input, T, Input, TF> BaseLexer<'input, T, Input, TF> where
T: LexerRecog<'input, Self> + 'static,
Input: CharStream<TF::From>,
TF: TokenFactory<'input>,
impl<'input, T, Input, TF> BaseLexer<'input, T, Input, TF> where
T: LexerRecog<'input, Self> + 'static,
Input: CharStream<TF::From>,
TF: TokenFactory<'input>,
sourcepub fn get_char_index(&self) -> isize
pub fn get_char_index(&self) -> isize
Current position in input stream
sourcepub fn set_text(&mut self, _text: <TF::Data as ToOwned>::Owned)
pub fn set_text(&mut self, _text: <TF::Data as ToOwned>::Owned)
Used from lexer actions to override text of the token that will be emitted next
sourcepub fn add_error_listener(
&mut self,
listener: Box<dyn ErrorListener<'input, Self>>
)
pub fn add_error_listener(
&mut self,
listener: Box<dyn ErrorListener<'input, Self>>
)
Add error listener
sourcepub fn remove_error_listeners(&mut self)
pub fn remove_error_listeners(&mut self)
Remove and drop all error listeners
sourcepub fn new_base_lexer(
input: Input,
interpreter: LexerATNSimulator,
recog: T,
factory: &'input TF
) -> Self
pub fn new_base_lexer(
input: Input,
interpreter: LexerATNSimulator,
recog: T,
factory: &'input TF
) -> Self
Creates new lexer instance
Trait Implementations
sourceimpl<'input, T, Input, TF> Deref for BaseLexer<'input, T, Input, TF> where
T: LexerRecog<'input, Self> + 'static,
Input: CharStream<TF::From>,
TF: TokenFactory<'input>,
impl<'input, T, Input, TF> Deref for BaseLexer<'input, T, Input, TF> where
T: LexerRecog<'input, Self> + 'static,
Input: CharStream<TF::From>,
TF: TokenFactory<'input>,
sourceimpl<'input, T, Input, TF> DerefMut for BaseLexer<'input, T, Input, TF> where
T: LexerRecog<'input, Self> + 'static,
Input: CharStream<TF::From>,
TF: TokenFactory<'input>,
impl<'input, T, Input, TF> DerefMut for BaseLexer<'input, T, Input, TF> where
T: LexerRecog<'input, Self> + 'static,
Input: CharStream<TF::From>,
TF: TokenFactory<'input>,
sourceimpl<'input, T, Input, TF> Lexer<'input> for BaseLexer<'input, T, Input, TF> where
T: LexerRecog<'input, Self> + 'static,
Input: CharStream<TF::From>,
TF: TokenFactory<'input>,
impl<'input, T, Input, TF> Lexer<'input> for BaseLexer<'input, T, Input, TF> where
T: LexerRecog<'input, Self> + 'static,
Input: CharStream<TF::From>,
TF: TokenFactory<'input>,
type Input = Input
type Input = Input
Concrete input stream used by this parser
sourcefn input(&mut self) -> &mut Self::Input
fn input(&mut self) -> &mut Self::Input
Same as TokenStream::get_input_stream
but returns concrete type instance
important for proper inlining in hot code of LexerATNSimulator
Read more
sourcefn set_channel(&mut self, v: isize)
fn set_channel(&mut self, v: isize)
Sets channel where current token will be pushed Read more
sourcefn push_mode(&mut self, m: usize)
fn push_mode(&mut self, m: usize)
Pushes current mode to internal mode stack and sets m
as current lexer mode
`pop_mode should be used to recover previous mode Read more
sourcefn set_type(&mut self, t: isize)
fn set_type(&mut self, t: isize)
Sets type of the current token Called from action to override token that will be emitted by lexer Read more
sourceimpl<'input, T, Input, TF> TokenSource<'input> for BaseLexer<'input, T, Input, TF> where
T: LexerRecog<'input, Self> + 'static,
Input: CharStream<TF::From>,
TF: TokenFactory<'input>,
impl<'input, T, Input, TF> TokenSource<'input> for BaseLexer<'input, T, Input, TF> where
T: LexerRecog<'input, Self> + 'static,
Input: CharStream<TF::From>,
TF: TokenFactory<'input>,
type TF = TF
type TF = TF
TokenFactory this token source produce tokens with
sourcefn next_token(&mut self) -> <Self::TF as TokenFactory<'input>>::Tok
fn next_token(&mut self) -> <Self::TF as TokenFactory<'input>>::Tok
Return a {@link Token} object from your input stream (usually a {@link CharStream}). Do not fail/return upon lexing error; keep chewing on the characters until you get a good one; errors are not passed through to the parser. Read more
sourcefn get_line(&self) -> isize
fn get_line(&self) -> isize
Get the line number for the current position in the input stream. The first line in the input is line 1. Read more
sourcefn get_char_position_in_line(&self) -> isize
fn get_char_position_in_line(&self) -> isize
Get the index into the current line for the current position in the input stream. The first character on a line has position 0. Read more
sourcefn get_input_stream(&mut self) -> Option<&mut dyn IntStream>
fn get_input_stream(&mut self) -> Option<&mut dyn IntStream>
Returns underlying input stream
sourcefn get_source_name(&self) -> String
fn get_source_name(&self) -> String
Returns string identifier of underlying input e.g. file name
sourcefn get_token_factory(&self) -> &'input TF
fn get_token_factory(&self) -> &'input TF
Gets the TokenFactory
this token source is currently using for
creating Token
objects from the input. Read more
Auto Trait Implementations
impl<'input, T, Input, TF = CommonTokenFactory> !RefUnwindSafe for BaseLexer<'input, T, Input, TF>
impl<'input, T, Input, TF = CommonTokenFactory> !Send for BaseLexer<'input, T, Input, TF>
impl<'input, T, Input, TF = CommonTokenFactory> !Sync for BaseLexer<'input, T, Input, TF>
impl<'input, T, Input, TF> Unpin for BaseLexer<'input, T, Input, TF> where
Input: Unpin,
T: Unpin,
<<TF as TokenFactory<'input>>::Data as ToOwned>::Owned: Unpin,
<TF as TokenFactory<'input>>::Tok: Unpin,
impl<'input, T, Input, TF = CommonTokenFactory> !UnwindSafe for BaseLexer<'input, T, Input, TF>
Blanket Implementations
sourceimpl<T> AnyExt for T where
T: Any + ?Sized,
impl<T> AnyExt for T where
T: Any + ?Sized,
sourcefn downcast_ref<T>(this: &Self) -> Option<&T> where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T> where
T: Any,
Attempts to downcast this to T
behind reference
sourcefn downcast_mut<T>(this: &mut Self) -> Option<&mut T> where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T> where
T: Any,
Attempts to downcast this to T
behind mutable reference
sourcefn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>> where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>> where
T: Any,
Attempts to downcast this to T
behind Rc
pointer
sourcefn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>> where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>> where
T: Any,
Attempts to downcast this to T
behind Arc
pointer
sourcefn downcast_box<T>(
this: Box<Self, Global>
) -> Result<Box<T, Global>, Box<Self, Global>> where
T: Any,
fn downcast_box<T>(
this: Box<Self, Global>
) -> Result<Box<T, Global>, Box<Self, Global>> where
T: Any,
Attempts to downcast this to T
behind Box
pointer
sourcefn downcast_move<T>(this: Self) -> Option<T> where
T: Any,
fn downcast_move<T>(this: Self) -> Option<T> where
T: Any,
Attempts to downcast owned Self
to T
,
useful only in generic context as a workaround for specialization Read more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T, X> CoerceTo<T> for X where
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for X where
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X, Global>) -> Box<T, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;