pub struct Scanner { /* private fields */ }
Implementations§
Source§impl Scanner
impl Scanner
pub fn new(string: &str) -> Scanner
pub fn iter_at_pos(&mut self) -> LineIterator<'_>
pub fn set_pos<T: Into<usize>>(&mut self, position: T)
pub fn get_pos(&self) -> ScannerPos
pub fn get_cursor(&self) -> usize
pub fn get_error_context( &self, start_pos: usize, end_pos: Option<usize>, ) -> ErrorContext
pub fn get_from_to<S: Into<usize>, E: Into<usize>>( &self, start: S, end: E, ) -> String
pub fn peek(&self) -> Option<&char>
pub fn peek_n(&self, num: usize) -> Option<Vec<char>>
pub fn is_done(&self) -> bool
pub fn next_char(&mut self) -> Option<&char>
pub fn take(&mut self, character: &char) -> bool
Sourcepub fn peek_skip_ws(&self) -> Option<char>
pub fn peek_skip_ws(&self) -> Option<char>
Get the next non whitespace character under the cursor without advancing. Following characters are skipped: space, tab, form feed, carriage return
Sourcepub fn skip_ws(&mut self)
pub fn skip_ws(&mut self)
Skip whitespace characters which are not new lines. Following characters are skipped: space, tab, form feed, carriage return
pub fn skip_empty_lines(&mut self)
pub fn skip_empty_lines_and_ws(&mut self)
Sourcepub fn match_str_forward(&mut self, str: &str) -> bool
pub fn match_str_forward(&mut self, str: &str) -> bool
Tries to match the given string and if successful moves the cursor to the next position after the strings and returns if matched or not If cursor is at the end of the file, nothing can be matched and always false will be returned. matching the empty string “” will always return in a match without moving the cursor forward.
pub fn seek_return(&mut self, character: &char) -> Result<String, ScanError>
pub fn match_regex_forward( &mut self, user_regex_str: &str, ) -> Result<Option<Vec<String>>, ScanError>
Sourcepub fn get_line_and_advance(&mut self) -> Option<String>
pub fn get_line_and_advance(&mut self) -> Option<String>
Get the current line (excluding the new line character) and advance to the next.
pub fn peek_line(&mut self) -> Option<String>
pub fn skip_to_next_line(&mut self)
pub fn get_tokens(&self) -> Vec<String>
Sourcepub fn get_prev_line(&self) -> Option<String>
pub fn get_prev_line(&self) -> Option<String>
Return the previous line without moving the cursor position
Sourcepub fn step_to_previous_line_start(&mut self)
pub fn step_to_previous_line_start(&mut self)
Change the position to the start of the new line if exists, otherwise do nothing