Trait swc_ecma_parser::Tokens[][src]

pub trait Tokens: Clone + Iterator<Item = TokenAndSpan> {
    fn set_ctx(&mut self, ctx: Context);
fn ctx(&self) -> Context;
fn syntax(&self) -> Syntax;
fn target(&self) -> JscTarget;
fn set_expr_allowed(&mut self, allow: bool);
fn token_context(&self) -> &TokenContexts;
fn token_context_mut(&mut self) -> &mut TokenContexts;
fn set_token_context(&mut self, _c: TokenContexts);
fn add_error(&self, error: Error);
fn add_module_mode_error(&self, error: Error);
fn take_errors(&mut self) -> Vec<Error>; }
Expand description

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

Required methods

fn set_ctx(&mut self, ctx: Context)[src]

fn ctx(&self) -> Context[src]

fn syntax(&self) -> Syntax[src]

fn target(&self) -> JscTarget[src]

fn set_expr_allowed(&mut self, allow: bool)[src]

fn token_context(&self) -> &TokenContexts[src]

fn token_context_mut(&mut self) -> &mut TokenContexts[src]

fn set_token_context(&mut self, _c: TokenContexts)[src]

fn add_error(&self, error: Error)[src]

Expand description

Implementors should use Rc<RefCell<Vec>>.

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

fn add_module_mode_error(&self, error: Error)[src]

Expand description

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.

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

Loading content...

Implementors

impl Tokens for TokensInput[src]

fn set_ctx(&mut self, ctx: Context)[src]

fn ctx(&self) -> Context[src]

fn syntax(&self) -> Syntax[src]

fn target(&self) -> JscTarget[src]

fn set_expr_allowed(&mut self, _: bool)[src]

fn token_context(&self) -> &TokenContexts[src]

fn token_context_mut(&mut self) -> &mut TokenContexts[src]

fn set_token_context(&mut self, c: TokenContexts)[src]

fn add_error(&self, error: Error)[src]

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

fn add_module_mode_error(&self, error: Error)[src]

impl<I: Tokens> Tokens for Capturing<I>[src]

fn set_ctx(&mut self, ctx: Context)[src]

fn ctx(&self) -> Context[src]

fn syntax(&self) -> Syntax[src]

fn target(&self) -> JscTarget[src]

fn set_expr_allowed(&mut self, allow: bool)[src]

fn token_context(&self) -> &TokenContexts[src]

fn token_context_mut(&mut self) -> &mut TokenContexts[src]

fn set_token_context(&mut self, c: TokenContexts)[src]

fn add_error(&self, error: Error)[src]

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

fn add_module_mode_error(&self, error: Error)[src]

impl<I: Input> Tokens for Lexer<'_, I>[src]

fn set_ctx(&mut self, ctx: Context)[src]

fn ctx(&self) -> Context[src]

fn syntax(&self) -> Syntax[src]

fn target(&self) -> JscTarget[src]

fn set_expr_allowed(&mut self, allow: bool)[src]

fn token_context(&self) -> &TokenContexts[src]

fn token_context_mut(&mut self) -> &mut TokenContexts[src]

fn set_token_context(&mut self, c: TokenContexts)[src]

fn add_error(&self, error: Error)[src]

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

fn add_module_mode_error(&self, error: Error)[src]

Loading content...