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>
impl<'a, R: ReadChar> Parser<'a, R>
sourcepub fn new(source: Source<'a, R>) -> Self
pub fn new(source: Source<'a, R>) -> Self
Create a new Parser
with a Source
as the input to parse.
sourcepub fn parse_script(&mut self, interner: &mut Interner) -> ParseResult<Script>
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.
sourcepub fn parse_module(&mut self, interner: &mut Interner) -> ParseResult<Module>where
R: ReadChar,
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.
sourcepub fn parse_eval(
&mut self,
direct: bool,
interner: &mut Interner
) -> ParseResult<Script>
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.
sourcepub fn parse_function_body(
&mut self,
interner: &mut Interner,
allow_yield: bool,
allow_await: bool
) -> ParseResult<FunctionBody>
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.
sourcepub fn parse_formal_parameters(
&mut self,
interner: &mut Interner,
allow_yield: bool,
allow_await: bool
) -> ParseResult<FormalParameterList>
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>
impl<R> Parser<'_, R>
sourcepub fn set_strict(&mut self)where
R: ReadChar,
pub fn set_strict(&mut self)where
R: ReadChar,
Set the parser strict mode to true.
sourcepub fn set_json_parse(&mut self)where
R: ReadChar,
pub fn set_json_parse(&mut self)where
R: ReadChar,
Set the parser JSON mode to true.
sourcepub fn set_identifier(&mut self, identifier: u32)where
R: ReadChar,
pub fn set_identifier(&mut self, identifier: u32)where
R: ReadChar,
Set the unique identifier for the parser.