This program is a tool similar to ocamlyacc that generates LALR(1) parsers. However, unlike ocamlyacc, it uses the continuation-passing style, which allows for better type inference and better optimization by the compiler.
To generate parser from .mly
grammar definition, run:
dune exec -- cpspg [-o OUTPUT] INPUT
To use this tool as a part of dune build process, add following rule to dune
file:
(rule
(deps Parser.mly)
(target Parser.cpspg.ml)
(action
(chdir %{workspace_root} (run cpspg -o %{target} %{deps}))))
This project is managed using dune
. To build it, run:
dune build
Note that lib/Parser.ml
is bootstrapped from lib/Parser.mly
. When code generation changes, it can be promoted to new version:
dune build @bootstrap
dune promote