src/bin
contains binary tools:- encode JS source to Binary AST;
- decode Binary AST back to JS source;
- dump information on a file;
src/source
contains tools for manipulating JS source:- parsing;
- pretty-printing;
spec
contains the specifications for the JS language, as webidl;examples
contains few additional tools/examples- compare compression between several algorithms;
- generate random ASTs for testing;
- test roundtrip encoding/decoding of a file.
Most of this project is contained in subcrates.
crates/binjs_shared
contains shared utilities, used both at build-time and run-time. Features:- tools for dealing with JSON;
- tools for dealing with ASTs
crates/binjs_meta
is used mostly at build-time, to generate eg. the ES6 grammar or, in Firefox, to generate the SpiderMonkey parser. It may also be used at runtime. Features:- read a grammar specification from a webidl;
- reflection of the grammar;
- sanity tests on the grammar;
- deanonymization of anonymous grammar nodes;
- ...
crates/binjs_generate_library
usescrates/binjs_meta
to generate a strongly-typed AST and tools for a specific grammar, e.g. the ES6 grammar ofspec/es6.webidl
;crates/binjs_io
contains tools for manipulating the container format. It is entirely independent of the language being manipulated.- encoding/decoding specific low-level data structures from/to bytes;
- token readers, token writers for these formats;
crates/binjs_generic
offers generic tools to manipulate actual ASTs. These tools are not specialized to any grammar (hence the name generic), but rely upon the reflection of the grammar ofcrates/binjs_meta
. These tools are slower and less safe than those ofcrates/binjs_es6
but offer a second implementation for testing purposes. Features:- generating random JSON ASTs for a grammar;
- comparing two JSON ASTs in a grammar;
- encoding/decoding entire JSON ASTs from/to bytes using a format defined in
crates/binjs_io
.
crates/binjs_es6
offers specialized tools to manipulate ES6 ASTs. Some of these tools are generated bycrates/binjs_generate_library
. Features:- a strongly-typed AST guaranteed to match the specs of
spec/es6.webidl
; - annotating scopes,
eval
, ... - serialization and deserialization of strongly-typed ES6 ASTs from/to bytes using a format defined in
crates/binjs_io
.
- a strongly-typed AST guaranteed to match the specs of