Trait swc_ecma_parser::input::Tokens
source · [−]pub trait Tokens: Clone + Iterator<Item = TokenAndSpan> {
Show 13 methods
fn set_ctx(&mut self, ctx: Context);
fn ctx(&self) -> Context;
fn syntax(&self) -> Syntax;
fn target(&self) -> EsVersion;
fn set_expr_allowed(&mut self, allow: bool);
fn set_next_regexp(&mut self, start: Option<BytePos>);
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>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
;
fn start_pos(&self) -> BytePos { ... }
}
Expand description
Clone should be cheap if you are parsing typescript because typescript syntax requires backtracking.
Required Methods
source
fn set_expr_allowed(&mut self, allow: bool)
source
fn set_next_regexp(&mut self, start: Option<BytePos>)
source
fn token_context(&self) -> &TokenContexts
source
fn token_context_mut(&mut self) -> &mut TokenContexts
source
fn set_token_context(&mut self, _c: TokenContexts)
Implementors should use Rc<RefCell<Vec
It is required because parser should backtrack while parsing typescript code.
sourcefn add_module_mode_error(&self, error: Error)
fn add_module_mode_error(&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.