macOS (Homebrew):
brew install opam
opam init
eval $(opam env)Ubuntu/Debian:
sudo apt install opam
opam init
eval $(opam env)General: See https://ocaml.org/docs/install.html
opam switch create 4.14.1
eval $(opam env)cd cbl-compiler
opam install . --deps-onlyThis will install:
dune(build system)menhir(parser generator)yojson(JSON library)ppx_deriving(code generation for show/yojson)
dune buildOr use the Makefile:
make buildThe compiled binary will be at: _build/default/bin/cblc.exe
dune installNow cblc command will be in your PATH.
./_build/default/bin/cblc.exe check examples/traffic_basic.cblExpected output:
✓ Specification is well-posed
./_build/default/bin/cblc.exe compile examples/traffic_basic.cbl -o traffic.jsonExpected output:
✓ Compiled examples/traffic_basic.cbl → traffic.json
cat traffic.json | jq . # requires jq for pretty-printingmake watchor
dune build --watchmake testmake fmtcbl-compiler/
├── bin/
│ ├── cblc.ml # Main entry point
│ └── dune # Executable build config
├── lib/
│ ├── ast.ml # AST type definitions
│ ├── lexer.mll # Lexer (ocamllex)
│ ├── parser.mly # Parser (menhir)
│ ├── checker.ml # Well-posedness checker
│ ├── json_emit.ml # JSON IR emission
│ └── dune # Library build config
├── examples/
│ └── traffic_basic.cbl
├── dune-project # Project metadata
├── Makefile # Convenience targets
└── README.md # This file
cblc parse examples/traffic_basic.cbl# This will fail if specification is not well-posed
cblc check bad_example.cbl
echo $? # Non-zero exit code on errorUser/LLM writes spec.cbl → OCaml compiler → .json IR → MATLAB backend
# Compile spec.cbl (assuming you have it ready)
cblc compile spec.cbl -o spec.json
# MATLAB reads JSON and builds Stateflow
matlab -batch "build_from_json('spec.json')"- Make sure
_build/default/bin/cblc.exeexists - Or use full path:
./_build/default/bin/cblc.exe - Or run
dune installto install system-wide
- Run
opam install . --deps-onlyagain - Check
opam listto see installed packages
- Check CBL syntax against
../CBL/cbl_language.md - Use
cblc parseto see where parsing fails - Enable debug output:
OCAMLRUNPARAM=b cblc parse file.cbl
dune clean
dune build- Read the paper:
../docs/cbl_overview.tex - Study examples:
../CBL/prototype/examples/*.cbl - Language reference:
../CBL/cbl_language.md - Compiler spec:
../CBL/cbl_compiler.md - Implementation notes:
IMPLEMENTATION.md
See IMPLEMENTATION.md for architecture details and TODO items.