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,
scope: &Scope,
interner: &mut Interner,
) -> ParseResult<Script>
pub fn parse_script( &mut self, scope: &Scope, interner: &mut Interner, ) -> ParseResult<Script>
Parse the full input as a ECMAScript Script into the boa AST representation without source text.
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_script_with_source(
&mut self,
scope: &Scope,
interner: &mut Interner,
) -> ParseResult<(Script, SourceText)>
pub fn parse_script_with_source( &mut self, scope: &Scope, interner: &mut Interner, ) -> ParseResult<(Script, SourceText)>
Parse the full input as a ECMAScript Script into the boa AST representation with source text.
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,
scope: &Scope,
interner: &mut Interner,
) -> ParseResult<Module>where
R: ReadChar,
pub fn parse_module(
&mut self,
scope: &Scope,
interner: &mut Interner,
) -> ParseResult<Module>where
R: ReadChar,
Parse the full input as an ECMAScript Module into the boa AST representation without source text.
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_module_with_source(
&mut self,
scope: &Scope,
interner: &mut Interner,
) -> ParseResult<(Module, SourceText)>where
R: ReadChar,
pub fn parse_module_with_source(
&mut self,
scope: &Scope,
interner: &mut Interner,
) -> ParseResult<(Module, SourceText)>where
R: ReadChar,
Parse the full input as an ECMAScript Module into the boa AST representation with source text.
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, SourceText)>
pub fn parse_eval( &mut self, direct: bool, interner: &mut Interner, ) -> ParseResult<(Script, SourceText)>
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.