Skip to content

yeslogic/fathom-experiments

Repository files navigation

Fathom related experiments

A repository of Fathom-related binary parsing experiments.

Language projects

  • ll1-combinators: Linear-time parser combinators based on Neel Krishnaswami’s blog post.
  • ll1-dsl: Linear-time parser combinators implemented as an external DSL.
  • ll1-dsl2: Linear-time parser combinators implemented as an external DSL, using a more traditional elaborator.
  • llk-simple: LL(k) parser DSL.
  • simple-ddl: A simply typed binary format DSL that compiles to a recursive descent parser.

Development setup

With Nix

Using Nix is not required, but can be useful for setting up a development shell with the required packages and tools used in this project. If you choose to use Nix, ensure you have it installed, with the Nix flakes feature enabled.

nix-direnv can be used to load development tools into your shell automatically. Once it’s installed, run the following commands to enable it in the project directory:

echo "use flake" > .envrc
direnv allow

The .envrc.sample file contains some additional commands to watch opam files and load compiled executables onto the PATH. To use it instead, run the following commands in your shell:

echo "source_env .envrc.sample" > .envrc
direnv allow

You’ll want to locally exclude the .envrc, or add it to your global gitignore.

After that, dune can be used to build, test, and run the projects:

dune build --display=short
dune test --display=short

VS Code

To enable IDE support with the OCaml Platform extension, add the following to your ./.vscode/settings.json file:

{
    // https://github.com/ocamllabs/vscode-ocaml-platform/issues/984
    "ocaml.sandbox": {
        "kind": "custom",
        "template": "nix develop ${firstWorkspaceFolder} --command $prog $args",
    },
}

With opam

Alternatively, opam package definitions are provided in the ./opam directory. They drive the Nix flake, so should be up to date. I don’t use opam however, so I’m not sure what the workflow is.