Skip to content

Domain, Substance, and Style parsers

Wode "Nimo" Ni edited this page Jul 19, 2021 · 1 revision

Domain, Substance, and Style are all independently parsed by their own parser modules, DomainParser.ts, SubstanceParser.ts, and StyleParser.ts. These files don't exist in the repo because they are generated from grammars, encoded in Domain.ne, Substance.ne, and Style.ne, respectively.

We use a parser generator library, nearley.js, to write the grammars and generate parsers for them. To get started on nearley, you can read their very helpful tutorial.

When testing your parsers, yarn start will not re-generate the parsers automatically. You need to run yarn build:parsers to manually trigger re-generation of parsers. Since we need to generate TypeScript modules from the .ne files, yarn build:parsers is usually run before build scripts such as yarn build, yarn start, and yarn test.

Clone this wiki locally