pub struct Lexer { /* private fields */ }
Expand description
Lexes tokens from source code based on JSON-parsed ruleset
§Example:
let mut lexer = Lexer::from(json, source);
while !lexer.done() {
println!("{}", lexer.next_token().unwrap());
}
Implementations§
Source§impl Lexer
impl Lexer
Sourcepub fn from_args(
literals: HashMap<String, String>,
whitespace: String,
source: String,
) -> Self
pub fn from_args( literals: HashMap<String, String>, whitespace: String, source: String, ) -> Self
Initializes lexer without JSON parsing
pub fn done(&self) -> bool
Sourcepub fn next_token(&mut self) -> Result<Token, ParsingError>
pub fn next_token(&mut self) -> Result<Token, ParsingError>
Advances and returns the next token
Sourcepub fn next_token_x(&mut self) -> Token
pub fn next_token_x(&mut self) -> Token
Advances and returns the next token
Sourcepub fn current_token(&self) -> Option<Result<Token, ParsingError>>
pub fn current_token(&self) -> Option<Result<Token, ParsingError>>
Returns the last token lexed
Sourcepub fn current_token_x(&self) -> Token
pub fn current_token_x(&self) -> Token
Returns the last token lexed, can throw exceptions
Sourcepub fn peek_next_token(&mut self) -> Option<Result<Token, ParsingError>>
pub fn peek_next_token(&mut self) -> Option<Result<Token, ParsingError>>
Returns the next token to be lexed
Sourcepub fn peek_next_token_x(&mut self) -> Token
pub fn peek_next_token_x(&mut self) -> Token
Returns the next token to be lexed. can throw exceptions
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Lexer
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