Trait Tokens

Source
pub trait Tokens: Clone + Iterator<Item = TokenAndSpan> {
    type Checkpoint;

Show 28 methods // Required methods fn set_ctx(&mut self, ctx: Context); fn ctx(&self) -> Context; fn ctx_mut(&mut self) -> &mut Context; fn syntax(&self) -> SyntaxFlags; fn target(&self) -> EsVersion; fn checkpoint_save(&self) -> Self::Checkpoint; fn checkpoint_load(&mut self, checkpoint: Self::Checkpoint); fn set_expr_allowed(&mut self, allow: bool); fn set_next_regexp(&mut self, start: Option<BytePos>); fn add_error(&mut self, error: Error); fn add_module_mode_error(&mut self, error: Error); fn end_pos(&self) -> BytePos; fn take_errors(&mut self) -> Vec<Error>; fn take_script_module_errors(&mut self) -> Vec<Error>; fn update_token_flags(&mut self, f: impl FnOnce(&mut TokenFlags)); fn token_flags(&self) -> TokenFlags; fn clone_token_value(&self) -> Option<TokenValue>; fn take_token_value(&mut self) -> Option<TokenValue>; fn get_token_value(&self) -> Option<&TokenValue>; fn set_token_value(&mut self, token_value: Option<TokenValue>); fn scan_jsx_token(&mut self, allow_multiline_jsx_text: bool) -> TokenAndSpan; fn scan_jsx_open_el_terminal_token(&mut self) -> TokenAndSpan; fn rescan_jsx_open_el_terminal_token( &mut self, reset: BytePos, ) -> TokenAndSpan; fn rescan_jsx_token( &mut self, allow_multiline_jsx_text: bool, reset: BytePos, ) -> TokenAndSpan; fn scan_jsx_identifier(&mut self, start: BytePos) -> TokenAndSpan; fn scan_jsx_attribute_value(&mut self) -> TokenAndSpan; fn rescan_template_token( &mut self, start: BytePos, start_with_back_tick: bool, ) -> TokenAndSpan; // Provided method fn start_pos(&self) -> BytePos { ... }
}
Expand description

Clone should be cheap if you are parsing typescript because typescript syntax requires backtracking.

Required Associated Types§

Required Methods§

Source

fn set_ctx(&mut self, ctx: Context)

Source

fn ctx(&self) -> Context

Source

fn ctx_mut(&mut self) -> &mut Context

Source

fn syntax(&self) -> SyntaxFlags

Source

fn target(&self) -> EsVersion

Source

fn checkpoint_save(&self) -> Self::Checkpoint

Source

fn checkpoint_load(&mut self, checkpoint: Self::Checkpoint)

Source

fn set_expr_allowed(&mut self, allow: bool)

Source

fn set_next_regexp(&mut self, start: Option<BytePos>)

Source

fn add_error(&mut self, error: Error)

Implementors should use Rc<RefCell<Vec>>.

It is required because parser should backtrack while parsing typescript code.

Source

fn add_module_mode_error(&mut self, error: Error)

Add an error which is valid syntax in script mode.

This errors should be dropped if it’s not a module.

Implementor should check for if Context.module, and buffer errors if module is false. Also, implementors should move errors to the error buffer on set_ctx if the parser mode become module mode.

Source

fn end_pos(&self) -> BytePos

Source

fn take_errors(&mut self) -> Vec<Error>

Source

fn take_script_module_errors(&mut self) -> Vec<Error>

If the program was parsed as a script, this contains the module errors should the program be identified as a module in the future.

Source

fn update_token_flags(&mut self, f: impl FnOnce(&mut TokenFlags))

Source

fn token_flags(&self) -> TokenFlags

Source

fn clone_token_value(&self) -> Option<TokenValue>

Source

fn take_token_value(&mut self) -> Option<TokenValue>

Source

fn get_token_value(&self) -> Option<&TokenValue>

Source

fn set_token_value(&mut self, token_value: Option<TokenValue>)

Source

fn scan_jsx_token(&mut self, allow_multiline_jsx_text: bool) -> TokenAndSpan

Source

fn scan_jsx_open_el_terminal_token(&mut self) -> TokenAndSpan

Source

fn rescan_jsx_open_el_terminal_token(&mut self, reset: BytePos) -> TokenAndSpan

Source

fn rescan_jsx_token( &mut self, allow_multiline_jsx_text: bool, reset: BytePos, ) -> TokenAndSpan

Source

fn scan_jsx_identifier(&mut self, start: BytePos) -> TokenAndSpan

Source

fn scan_jsx_attribute_value(&mut self) -> TokenAndSpan

Source

fn rescan_template_token( &mut self, start: BytePos, start_with_back_tick: bool, ) -> TokenAndSpan

Provided Methods§

Source

fn start_pos(&self) -> BytePos

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Tokens for Lexer<'_>

Source§

type Checkpoint = LexerCheckpoint

Source§

impl<I: Tokens> Tokens for Capturing<I>

Source§

type Checkpoint = CapturingCheckpoint<I>