Expand description
JavaScript parser: token stream → AST.
Recursive descent with precedence climbing for binary operators. Automatic
Semicolon Insertion is applied at statement boundaries using the
newline_before flag the lexer records on every token. Arrow functions are
detected at assignment level by looking ahead for => after a parameter
list. Template-literal ${...} fields are re-parsed here from the raw source
the lexer captured.
Functions§
- note_
error_ span - Record a SyntaxError found after parsing — an early error such as a
redeclaration — at the source span
[pos, end), fortake_error_pos. - parse
- Parse a complete JS program into a statement list. Inline
rust { ... }FFI blocks are desugared to__rust_compile(...)calls before lexing. - parse_
eval - Parse the source text of an
eval/vmscript. Identical toparseexcept thatsuperis accepted at the top level whenallow_supersays the code runs inside a method (a directevalthere may use it). - parse_
module - Parse
srcwith the Module goal (ECMA-262 16.2.1): the code is strict,awaitis an operator at the top level,returnthere is an error, and the top level may holdimport/exportdeclarations. A hashbang line is a comment only at the very start of the text. - take_
error_ end - One past the last character V8 underlines for that SyntaxError — the end
of the offending token (
0: underline the one character at the position). Taken byhost::note_syntax_erroralongsidetake_error_pos. - take_
error_ pos - The
Posof the token the last failedparse/parse_modulestopped at (0: none, or none since the last call), which is where V8 puts a SyntaxError’s caret.