Skip to main content

Parser

Struct Parser 

Source
pub struct Parser<'a> { /* private fields */ }
Expand description

ECMAScript 2025 parser.

Implementations§

Source§

impl<'a> Parser<'a>

Source

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).

Source

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.

Source

pub fn set_max_depth(&mut self, depth: u32)

Raise or lower the nesting limit.

Source

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>

§

impl<'a> Move for Parser<'a>

§

impl<'a> RefUnwindSafe for Parser<'a>

§

impl<'a> Send for Parser<'a>
where &'a str: Send, &'a [u8]: Send, RawVecInner: Send,

§

impl<'a> Sync for Parser<'a>
where RawVecInner: Sync,

§

impl<'a> Unpin for Parser<'a>
where &'a str: Unpin, &'a [u8]: Unpin, *const u8 is !null: Unpin,

§

impl<'a> UnsafeUnpin for Parser<'a>

§

impl<'a> UnwindSafe for Parser<'a>
where &'a str: UnwindSafe, &'a [u8]: UnwindSafe, RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.