pub struct Parser<I: Tokens> { /* private fields */ }Expand description
EcmaScript parser.
Implementations§
Source§impl<I: Tokens> Parser<I>
impl<I: Tokens> Parser<I>
pub fn parse_module_item(&mut self) -> PResult<ModuleItem>
Sourcepub fn parse_stmt(&mut self) -> PResult<Stmt>
pub fn parse_stmt(&mut self) -> PResult<Stmt>
Parse a statement but not a declaration.
Sourcepub fn parse_stmt_list_item(&mut self) -> PResult<Stmt>
pub fn parse_stmt_list_item(&mut self) -> PResult<Stmt>
Parse a statement and maybe a declaration.
Source§impl<I: Tokens> Parser<I>
impl<I: Tokens> Parser<I>
pub fn new_from(input: I) -> Self
pub fn take_errors(&mut self) -> Vec<Error>
pub fn take_script_module_errors(&mut self) -> Vec<Error>
pub fn parse_script(&mut self) -> PResult<Script>
pub fn parse_commonjs(&mut self) -> PResult<Script>
pub fn parse_typescript_module(&mut self) -> PResult<Module>
Sourcepub fn parse_program(&mut self) -> PResult<Program>
pub fn parse_program(&mut self) -> PResult<Program>
pub fn parse_module(&mut self) -> PResult<Module>
Trait Implementations§
Source§impl<'a, I: Tokens> Parser<'a> for Parser<I>
impl<'a, I: Tokens> Parser<'a> for Parser<I>
type Buffer = Buffer<I>
type I = I
type Lexer = Lexer<'a>
type Next = NextTokenAndSpan
type Token = Token
type TokenAndSpan = TokenAndSpan
fn input(&self) -> &Self::Buffer
fn input_mut(&mut self) -> &mut Self::Buffer
fn state(&self) -> &State
fn state_mut(&mut self) -> &mut State
fn mark_found_module_item(&mut self)
fn parse_unary_expr(&mut self) -> PResult<Box<Expr>>
fn parse_jsx_element( &mut self, in_expr_context: bool, ) -> PResult<Either<JSXFragment, JSXElement>>
fn parse_primary_expr(&mut self) -> PResult<Box<Expr>>
fn ts_in_no_context<T>( &mut self, op: impl FnOnce(&mut Self) -> PResult<T>, ) -> PResult<T>
fn parse_tagged_tpl( &mut self, tag: Box<Expr>, type_params: Option<Box<TsTypeParamInstantiation>>, ) -> PResult<TaggedTpl>
fn parse_tagged_tpl_ty(&mut self) -> PResult<TsLitType>
fn parse_lhs_expr(&mut self) -> PResult<Box<Expr>>
fn with_state<'w>(&'w mut self, state: State) -> WithState<'a, 'w, Self>
fn ctx(&self) -> Context
fn set_ctx(&mut self, ctx: Context)
fn do_inside_of_context<T>( &mut self, context: Context, f: impl FnOnce(&mut Self) -> T, ) -> T
fn do_outside_of_context<T>( &mut self, context: Context, f: impl FnOnce(&mut Self) -> T, ) -> T
fn strict_mode<T>(&mut self, f: impl FnOnce(&mut Self) -> T) -> T
Source§fn in_type<T>(&mut self, f: impl FnOnce(&mut Self) -> T) -> T
fn in_type<T>(&mut self, f: impl FnOnce(&mut Self) -> T) -> T
Original context is restored when returned guard is dropped.
fn allow_in_expr<T>(&mut self, f: impl FnOnce(&mut Self) -> T) -> T
fn disallow_in_expr<T>(&mut self, f: impl FnOnce(&mut Self) -> T) -> T
fn syntax(&self) -> SyntaxFlags
fn emit_err(&mut self, span: Span, error: SyntaxError)
fn emit_error(&mut self, error: Error)
fn emit_strict_mode_err(&self, span: Span, error: SyntaxError)
fn verify_expr(&mut self, expr: Box<Expr>) -> Result<Box<Expr>, Error>
fn cur_pos(&mut self) -> BytePos
fn last_pos(&self) -> BytePos
fn is_general_semi(&mut self) -> bool
fn eat_general_semi(&mut self) -> bool
fn expect_general_semi(&mut self) -> Result<(), Error>
fn expect(&mut self, t: &Self::Token) -> Result<(), Error>
fn expect_without_advance(&mut self, t: &Self::Token) -> Result<(), Error>
fn bump(&mut self) -> Self::Token
fn span(&self, start: BytePos) -> Span
fn assert_and_bump(&mut self, token: &Self::Token)
fn check_assign_target(&mut self, expr: &Expr, deny_call: bool)
fn parse_tpl_element( &mut self, is_tagged_tpl: bool, ) -> Result<TplElement, Error>
Source§fn parse_expr_or_spread(&mut self) -> Result<ExprOrSpread, Error>
fn parse_expr_or_spread(&mut self) -> Result<ExprOrSpread, Error>
AssignmentExpression[+In, ?Yield, ?Await]
…AssignmentExpression[+In, ?Yield, ?Await]
fn parse_expr(&mut self) -> Result<Box<Expr>, Error>
fn is_ident_ref(&mut self) -> bool
fn peek_is_ident_ref(&mut self) -> bool
fn eat_ident_ref(&mut self) -> bool
Auto Trait Implementations§
impl<I> Freeze for Parser<I>where
I: Freeze,
impl<I> RefUnwindSafe for Parser<I>where
I: RefUnwindSafe,
impl<I> Send for Parser<I>where
I: Send,
impl<I> Sync for Parser<I>where
I: Sync,
impl<I> Unpin for Parser<I>where
I: Unpin,
impl<I> UnwindSafe for Parser<I>where
I: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more