[][src]Trait swc_ecma_parser::input::Tokens

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

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

Required methods

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

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

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

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

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

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

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

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

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

Implementors should use Rc<RefCell<Vec>>.

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

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

Add an error which is valid syntax in script mode.

This errors should be dropped if it's not a moduloe.

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.

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

Loading content...

Implementors

impl Tokens for TokensInput[src]

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

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

Loading content...