Struct boa_parser::parser::Parser

source ·
pub struct Parser<'a, R> { /* private fields */ }
Expand description

Parser for the ECMAScript language.

This parser implementation tries to be conformant to the most recent [ECMAScript language specification], and it also implements some legacy features like labelled functions or duplicated block-level function definitions.

Implementations§

source§

impl<'a, R: ReadChar> Parser<'a, R>

source

pub fn new(source: Source<'a, R>) -> Self

Create a new Parser with a Source as the input to parse.

source

pub fn parse_script(&mut self, interner: &mut Interner) -> ParseResult<Script>

Parse the full input as a ECMAScript Script into the boa AST representation. The resulting Script can be compiled into boa bytecode and executed in the boa vm.

§Errors

Will return Err on any parsing error, including invalid reads of the bytes being parsed.

source

pub fn parse_module(&mut self, interner: &mut Interner) -> ParseResult<Module>
where R: ReadChar,

Parse the full input as an ECMAScript Module into the boa AST representation. The resulting ModuleItemList can be compiled into boa bytecode and executed in the boa vm.

§Errors

Will return Err on any parsing error, including invalid reads of the bytes being parsed.

source

pub fn parse_eval( &mut self, direct: bool, interner: &mut Interner ) -> ParseResult<Script>

19.2.1.1 PerformEval ( x, strictCaller, direct )

Parses the source text input of an eval call.

§Errors

Will return Err on any parsing error, including invalid reads of the bytes being parsed.

source

pub fn parse_function_body( &mut self, interner: &mut Interner, allow_yield: bool, allow_await: bool ) -> ParseResult<FunctionBody>

Parses the full input as an ECMAScript FunctionBody into the boa AST representation.

§Errors

Will return Err on any parsing error, including invalid reads of the bytes being parsed.

source

pub fn parse_formal_parameters( &mut self, interner: &mut Interner, allow_yield: bool, allow_await: bool ) -> ParseResult<FormalParameterList>

Parses the full input as an ECMAScript FormalParameterList into the boa AST representation.

§Errors

Will return Err on any parsing error, including invalid reads of the bytes being parsed.

source§

impl<R> Parser<'_, R>

source

pub fn set_strict(&mut self)
where R: ReadChar,

Set the parser strict mode to true.

source

pub fn set_json_parse(&mut self)
where R: ReadChar,

Set the parser JSON mode to true.

source

pub fn set_identifier(&mut self, identifier: u32)
where R: ReadChar,

Set the unique identifier for the parser.

Trait Implementations§

source§

impl<'a, R: Debug> Debug for Parser<'a, R>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, R> RefUnwindSafe for Parser<'a, R>
where R: RefUnwindSafe,

§

impl<'a, R> Send for Parser<'a, R>
where R: Send,

§

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

§

impl<'a, R> Unpin for Parser<'a, R>
where R: Unpin,

§

impl<'a, R> UnwindSafe for Parser<'a, R>
where R: 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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T