Skip to main content

Scanner

Struct Scanner 

Source
struct Scanner {
    frames: Vec<Frame>,
    recent: Vec<Token>,
    last: Option<Token>,
    last_name: Option<String>,
    name_before_last: Option<String>,
    newline_after_last: bool,
    pending: Option<(BlockKind, usize, bool)>,
    closed_call_block: Option<BlockKind>,
    closed_if: bool,
}

Fields§

§frames: Vec<Frame>§recent: Vec<Token>

Tokens other than line breaks, most recent last, up to LOOK_BACK.

§last: Option<Token>§last_name: Option<String>§name_before_last: Option<String>

The name scanned before last_name, which is an element’s when the two are a top-level element and its name, as in window settings(.

§newline_after_last: bool§pending: Option<(BlockKind, usize, bool)>

The block the next { at this depth opens, set by fn, if and the like.

§closed_call_block: Option<BlockKind>

What a { right after the call just closed would open.

§closed_if: bool

Implementations§

Source§

impl Scanner

Source

fn new() -> Self

Source

fn token(&mut self, text: &str, token: Token)

Source

fn pop(&mut self) -> Option<Frame>

Closes the innermost frame. The top level is never closed, so a stray closing bracket leaves the cursor at the top level.

Source

fn expect_block(&mut self, kind: BlockKind, from_if: bool)

Source

fn open_block(&mut self, closed_call_block: Option<BlockKind>)

Source

fn open_paren(&mut self)

Source

fn label_argument(&mut self)

Source

fn enclosing_block(&self) -> BlockKind

Source

fn kinds(&self) -> Vec<TokenKind>

Source

fn last_name(&self) -> Option<String>

The name just scanned; callers check the last token is a name.

Source

fn in_string(&self) -> bool

Source

fn innermost_call(&self) -> Option<Call>

Source

fn slot(&self) -> Slot

Source

fn block_slot(&self, kind: BlockKind, kinds: &[TokenKind]) -> Slot

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.