swc_es_parser
swc_es_parser is a bootstrap ECMAScript parser that builds arena-backed nodes from swc_es_ast.
Goals
- Parse source directly into
swc_es_asthandles. - Expose a small parser API (
Lexer,Parser,parse_file_as_*). - Keep parser errors in a crate-local error model while integrating with
swc_commondiagnostics.
Current Status
- Script/module/program entry points are available.
- Core statements and expression parsing are implemented.
import/exportbootstrap parsing is included.- Structured
forhead parsing is available (classic,for..in,for..of). - JSX parsing supports qualified tag names and reports opening/closing tag mismatches.
- TypeScript parsing builds structured type nodes (function/union/intersection/tuple/array/type-literal/type-args) for
typealiases andasassertions.
Fixture Harness
swc_ecma_parserinputs are reused fromcrates/swc_ecma_parser/tests.swc_es_parsersnapshots are stored undercrates/swc_es_parser/tests/fixtures.- Generate or refresh snapshots with:
UPDATE=1
API Sketch
use ;
use ;
let cm = default;
let fm = cm.new_source_file;
let lexer = new;
let mut parser = new_from;
let parsed = parser.parse_program.unwrap;