Struct ironcalc_base::expressions::lexer::Lexer
source · pub struct Lexer { /* private fields */ }Expand description
Tokenize an input
Implementations§
source§impl Lexer
impl Lexer
sourcepub fn new(
formula: &str,
mode: LexerMode,
locale: &Locale,
language: &Language
) -> Lexer
pub fn new( formula: &str, mode: LexerMode, locale: &Locale, language: &Language ) -> Lexer
Creates a new Lexer that returns the tokens of a formula.
sourcepub fn set_lexer_mode(&mut self, mode: LexerMode)
pub fn set_lexer_mode(&mut self, mode: LexerMode)
Changes the lexer mode
sourcepub fn is_a1_mode(&self) -> bool
pub fn is_a1_mode(&self) -> bool
Returns true if mode is A1
sourcepub fn get_formula(&self) -> String
pub fn get_formula(&self) -> String
Returns the formula
sourcepub fn get_position(&self) -> i32
pub fn get_position(&self) -> i32
Returns the position of the lexer
sourcepub fn set_formula(&mut self, content: &str)
pub fn set_formula(&mut self, content: &str)
Resets the formula
sourcepub fn expect(&mut self, tk: TokenType) -> Result<(), LexerError>
pub fn expect(&mut self, tk: TokenType) -> Result<(), LexerError>
Returns an error if the token is not the expected one.
sourcepub fn peek_token(&mut self) -> TokenType
pub fn peek_token(&mut self) -> TokenType
Checks the next token without advancing position See also advance_token
sourcepub fn advance_token(&mut self)
pub fn advance_token(&mut self)
Advances position. This is used in conjunction with peek_token
It is a noop if the has not been a previous peek_token
sourcepub fn next_token(&mut self) -> TokenType
pub fn next_token(&mut self) -> TokenType
Returns the next token
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Lexer
impl Send for Lexer
impl Sync for Lexer
impl Unpin for Lexer
impl UnwindSafe for Lexer
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