pub struct Lexer<'a> { /* private fields */ }Expand description
Tokenize an input
Implementations§
Source§impl<'a> Lexer<'a>
impl<'a> Lexer<'a>
Sourcepub fn new(
formula: &str,
mode: LexerMode,
locale: &'a Locale,
language: &'a Language,
) -> Lexer<'a>
pub fn new( formula: &str, mode: LexerMode, locale: &'a Locale, language: &'a Language, ) -> Lexer<'a>
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 set_locale(&mut self, locale: &'a Locale)
pub fn set_locale(&mut self, locale: &'a Locale)
Sets the locale
Sourcepub fn set_language(&mut self, language: &'a Language)
pub fn set_language(&mut self, language: &'a Language)
Sets the language
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<'a> Freeze for Lexer<'a>
impl<'a> RefUnwindSafe for Lexer<'a>
impl<'a> Send for Lexer<'a>
impl<'a> Sync for Lexer<'a>
impl<'a> Unpin for Lexer<'a>
impl<'a> UnsafeUnpin for Lexer<'a>
impl<'a> UnwindSafe for Lexer<'a>
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