-
Notifications
You must be signed in to change notification settings - Fork 0
Building and Integration
A Zig toolchain at 0.17.0-dev.607+456b2ec07 or later (build.zig.zon:10,
README.md:40). The es-parser library module has no dependencies (the repo's default zig build
fetches one dev tool, zbc, for static analysis); the conformance corpora are
optional git submodules, needed only to run those suites.
Fetch it into your build.zig.zon with zig fetch, which records the URL and
hash:
zig fetch --save git+https://github.com/ericsssan/es-parser
# or pin a tag:
zig fetch --save https://github.com/ericsssan/es-parser/archive/refs/tags/v0.2.13.tar.gzThat writes an .es_parser dependency. Mind the name skew: the dependency is
es_parser, and it exposes a module named es-parser (build.zig:16). Wire it
up in build.zig:
const es_parser = b.dependency("es_parser", .{ .target = target, .optimize = optimize });
my_module.addImport("es_parser", es_parser.module("es-parser"));In code it is then const es = @import("es_parser");. The minimal lex → parse →
analyze sequence is on the Home page; the full surface is in the
API Reference.
One integration obligation worth repeating: the semantic analyzer requires a
zero-filling allocator (an arena over page_allocator, or
semantic.ZeroingAllocator). See
Semantic Analysis.
zig build testThat step (build.zig:95) runs the embedded unit tests plus four file-based suites
— tests/parser_test.zig, tests/lexer_test.zig, tests/semantic_test.zig,
tests/fuzz_test.zig (replaying its corpora) — and the bundled
test262-parser-tests runner, whose submodule ships with the package. So a plain
checkout runs the parser-tests conformance suite with no extra setup.
The other conformance suites are external submodules; initialize the one you want first:
git submodule update --init tests/conformance/typescript
zig build conformance-typescriptThe full list of steps, what each measures, and the current numbers are in Conformance and Testing.
es-parser — MIT licensed. This wiki documents the implementation under src/; when a detail matters, the source is authoritative.