Enum makepad_live_tokenizer::tokenizer::State
source · pub enum State {
Initial(InitialState),
BlockCommentTail(BlockCommentTailState),
DoubleQuotedStringTail(DoubleQuotedStringTailState),
RawDoubleQuotedStringTail(RawDoubleQuotedStringTailState),
}
Expand description
The state of the tokenizer.
Variants§
Initial(InitialState)
BlockCommentTail(BlockCommentTailState)
DoubleQuotedStringTail(DoubleQuotedStringTailState)
RawDoubleQuotedStringTail(RawDoubleQuotedStringTailState)
Implementations§
source§impl State
impl State
sourcepub fn next(self, cursor: &mut Cursor<'_>) -> (State, Option<TokenWithLen>)
pub fn next(self, cursor: &mut Cursor<'_>) -> (State, Option<TokenWithLen>)
Given the current state of the tokenizer and a cursor over a slice of chars, finds the next
token in in that string, and moves the cursor forward by the number of characters in the
token. Returns the new state of the tokenizer and the token recognised, or None
if there
are no more tokens in the string.
Examples
use makepad_live_tokenizer::{
full_token::{FullToken, TokenWithLen},
tokenizer::{Cursor, InitialState, State}
};
let mut state = State::default();
let mut scratch = String::new();
let mut cursor = Cursor::new(&['1', '2', '3'], &mut scratch);
assert_eq!(
state.next(&mut cursor),
(
State::Initial(InitialState),
Some(TokenWithLen {
len: 3,
token: FullToken::Int(123),
})
)
);
Trait Implementations§
source§impl PartialEq<State> for State
impl PartialEq<State> for State
impl Copy for State
impl Eq for State
impl StructuralEq for State
impl StructuralPartialEq for State
Auto Trait Implementations§
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
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