pub struct Parser<'a> { /* private fields */ }Expand description
ECMAScript 2025 parser.
Implementations§
Source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
Sourcepub fn new(src: &'a str, module: bool) -> Result<Parser<'a>>
pub fn new(src: &'a str, module: bool) -> Result<Parser<'a>>
Create a parser over src. A module is always strict.
The program’s own function is an async one for a module, so its top level may
await. That is set here rather than at each await site: Parser::ctx
describes the function currently being parsed, and the reference keys every
await rule off the same thing (fd->func_kind & JS_FUNC_ASYNC).
Sourcepub fn new_suspensible(src: &'a str) -> Result<Parser<'a>>
pub fn new_suspensible(src: &'a str) -> Result<Parser<'a>>
Create a parser whose program is the body of an async function.
This is the reference’s JS_EVAL_FLAG_ASYNC: a script compiled with it may use
top-level await, exactly as a module body may. It is not the same as being inside
a function — return is still an error, new.target is still unavailable — so
in_function stays false.
Sourcepub fn set_max_depth(&mut self, depth: u32)
pub fn set_max_depth(&mut self, depth: u32)
Raise or lower the nesting limit.
Sourcepub fn parse_program(&mut self) -> Result<Program>
pub fn parse_program(&mut self) -> Result<Program>
Parse the whole source.
Auto Trait Implementations§
impl<'a> Forget for Parser<'a>
impl<'a> Freeze for Parser<'a>where
&'a str: Freeze,
&'a [u8]: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<Label>: Freeze,
PhantomData<PrivateEnv>: Freeze,
PhantomData<Span>: Freeze,
PhantomData<(String, Span)>: Freeze,
PhantomData<Scope>: Freeze,
impl<'a> Move for Parser<'a>
impl<'a> RefUnwindSafe for Parser<'a>
impl<'a> Send for Parser<'a>
impl<'a> Sync for Parser<'a>where
RawVecInner: Sync,
impl<'a> Unpin for Parser<'a>
impl<'a> UnsafeUnpin for Parser<'a>where
&'a str: UnsafeUnpin,
&'a [u8]: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Label>: UnsafeUnpin,
PhantomData<PrivateEnv>: UnsafeUnpin,
PhantomData<Span>: UnsafeUnpin,
PhantomData<(String, Span)>: UnsafeUnpin,
PhantomData<Scope>: UnsafeUnpin,
impl<'a> UnwindSafe for Parser<'a>
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