[][src]Struct ress::Scanner

pub struct Scanner<'a> {
    pub stream: Tokenizer<'a>,
    pub eof: bool,
    pub pending_new_line: bool,
    // some fields omitted
}

The primary interface of this crate used to tokenize any JS text into a stream of Items.

Fields

stream: Tokenizer<'a>eof: boolpending_new_line: bool

Methods

impl<'a> Scanner<'a>[src]

pub fn new(text: &'a str) -> Self[src]

Create a new Scanner by providing the JS text

impl<'b> Scanner<'b>[src]

pub fn look_ahead(&mut self) -> Option<Result<Item<Token<&'b str>>, Error>>[src]

Attempts to look ahead 1 token

Similar to how Peekable::peek works however the returned value will not be a borrowed Item. Since there isn't a borrow happening this essentially duplicates the cost of calling next.

pub fn skip_comments(&mut self) -> Result<(), Error>[src]

Skip any upcoming comments to get the next valid js token

pub fn get_state(&self) -> ScannerState[src]

Get a copy of the scanner's current state

pub fn set_state(&mut self, state: ScannerState)[src]

Set the scanner's current state to the state provided

pub fn string_for(&self, span: &Span) -> Option<String>[src]

Get a string for any given span

pub fn str_for(&self, span: &Span) -> Option<&'b str>[src]

Get a &str for any given span

pub fn position_for(&self, idx: usize) -> (usize, usize)[src]

Get the line/column pair for any given byte index

Trait Implementations

impl<'a> Iterator for Scanner<'a>[src]

type Item = Result<Item<Token<&'a str>>, Error>

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a> RefUnwindSafe for Scanner<'a>

impl<'a> Send for Scanner<'a>

impl<'a> Sync for Scanner<'a>

impl<'a> Unpin for Scanner<'a>

impl<'a> UnwindSafe for Scanner<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.