Trait ParserTrait

pub trait ParserTrait<'a>: Sized + Clone {
    type Token: Debug + Clone + TokenFactory<'a, Self::TokenAndSpan, Self::I, Buffer = Self::Buffer>;
    type Next: NextTokenAndSpan<Token = Self::Token>;
    type TokenAndSpan: TokenAndSpan<Token = Self::Token>;
    type I: Tokens<Self::TokenAndSpan>;
    type Buffer: Buffer<'a, Token = Self::Token, TokenAndSpan = Self::TokenAndSpan, I = Self::I>;
    type Checkpoint;

Show 46 methods // Required methods 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 checkpoint_save(&self) -> Self::Checkpoint; fn checkpoint_load(&mut self, checkpoint: Self::Checkpoint); fn mark_found_module_item(&mut self); fn ts_in_no_context<T>( &mut self, op: impl FnOnce(&mut Self) -> Result<T, Error>, ) -> Result<T, Error>; fn parse_jsx_element( &mut self, in_expr_context: bool, ) -> Result<Either<JSXFragment, JSXElement>, Error>; fn parse_primary_expr(&mut self) -> Result<Box<Expr>, Error>; fn parse_unary_expr(&mut self) -> Result<Box<Expr>, Error>; fn parse_tagged_tpl( &mut self, tag: Box<Expr>, type_params: Option<Box<TsTypeParamInstantiation>>, ) -> Result<TaggedTpl, Error>; fn parse_tagged_tpl_ty(&mut self) -> Result<TsLitType, Error>; fn parse_lhs_expr(&mut self) -> Result<Box<Expr>, Error>; // Provided methods 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 { ... } fn in_type<T>(&mut self, f: impl FnOnce(&mut Self) -> T) -> T { ... } 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(&mut self, span: Span, error: SyntaxError) { ... } fn verify_expr(&mut self, expr: Box<Expr>) -> Result<Box<Expr>, Error> { ... } fn cur_pos(&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) { ... } 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> { ... } fn parse_prop_name(&mut self) -> Result<PropName, Error> { ... } fn parse_expr_or_spread(&mut self) -> Result<ExprOrSpread, Error> { ... } 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 { ... }
}

Required Associated Types§

type Token: Debug + Clone + TokenFactory<'a, Self::TokenAndSpan, Self::I, Buffer = Self::Buffer>

type Next: NextTokenAndSpan<Token = Self::Token>

type TokenAndSpan: TokenAndSpan<Token = Self::Token>

type I: Tokens<Self::TokenAndSpan>

type Buffer: Buffer<'a, Token = Self::Token, TokenAndSpan = Self::TokenAndSpan, I = Self::I>

type Checkpoint

Required Methods§

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 checkpoint_save(&self) -> Self::Checkpoint

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

fn mark_found_module_item(&mut self)

fn ts_in_no_context<T>( &mut self, op: impl FnOnce(&mut Self) -> Result<T, Error>, ) -> Result<T, Error>

fn parse_jsx_element( &mut self, in_expr_context: bool, ) -> Result<Either<JSXFragment, JSXElement>, Error>

fn parse_primary_expr(&mut self) -> Result<Box<Expr>, Error>

fn parse_unary_expr(&mut self) -> Result<Box<Expr>, Error>

fn parse_tagged_tpl( &mut self, tag: Box<Expr>, type_params: Option<Box<TsTypeParamInstantiation>>, ) -> Result<TaggedTpl, Error>

fn parse_tagged_tpl_ty(&mut self) -> Result<TsLitType, Error>

fn parse_lhs_expr(&mut self) -> Result<Box<Expr>, Error>

Provided Methods§

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

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(&mut self, span: Span, error: SyntaxError)

fn verify_expr(&mut self, expr: Box<Expr>) -> Result<Box<Expr>, Error>

fn cur_pos(&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)

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>

fn parse_prop_name(&mut self) -> Result<PropName, Error>

spec: ‘PropertyName’

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

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§

§

impl<'a, I> Parser<'a> for Parser<I>
where I: Tokens<TokenAndSpan>,

§

type Buffer = Buffer<I>

§

type Checkpoint = Parser<I>

§

type I = I

§

type Next = TokenAndSpan

§

type Token = Token

§

type TokenAndSpan = TokenAndSpan

Source§

impl<'a, I: Tokens> Parser<'a> for swc_ecma_parser::Parser<I>