Struct Scanner

Source
pub struct Scanner { /* private fields */ }

Implementations§

Source§

impl Scanner

Source

pub fn new(string: &str) -> Scanner

Source

pub fn iter_at_pos(&mut self) -> LineIterator<'_>

Source

pub fn set_pos<T: Into<usize>>(&mut self, position: T)

Source

pub fn get_pos(&self) -> ScannerPos

Source

pub fn get_cursor(&self) -> usize

Source

pub fn get_error_context( &self, start_pos: usize, end_pos: Option<usize>, ) -> ErrorContext

Source

pub fn get_from_to<S: Into<usize>, E: Into<usize>>( &self, start: S, end: E, ) -> String

Source

pub fn peek(&self) -> Option<&char>

Source

pub fn peek_n(&self, num: usize) -> Option<Vec<char>>

Source

pub fn is_done(&self) -> bool

Source

pub fn next_char(&mut self) -> Option<&char>

Source

pub fn take(&mut self, character: &char) -> bool

Source

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

Source

pub fn skip_ws(&mut self)

Skip whitespace characters which are not new lines. Following characters are skipped: space, tab, form feed, carriage return

Source

pub fn skip_empty_lines(&mut self)

Source

pub fn skip_empty_lines_and_ws(&mut self)

Source

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.

Source

pub fn seek_return(&mut self, character: &char) -> Result<String, ScanError>

Source

pub fn match_regex_forward( &mut self, user_regex_str: &str, ) -> Result<Option<Vec<String>>, ScanError>

Source

pub fn get_line_and_advance(&mut self) -> Option<String>

Get the current line (excluding the new line character) and advance to the next.

Source

pub fn peek_line(&mut self) -> Option<String>

Source

pub fn skip_to_next_line(&mut self)

Source

pub fn get_tokens(&self) -> Vec<String>

Source

pub fn get_prev_line(&self) -> Option<String>

Return the previous line without moving the cursor position

Source

pub fn step_to_previous_line_start(&mut self)

Change the position to the start of the new line if exists, otherwise do nothing

Source§

impl Scanner

Source

pub fn debug_string(&self) -> String

Trait Implementations§

Source§

impl Debug for Scanner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Scanner

Source§

fn eq(&self, other: &Scanner) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Scanner

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T