diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index d769ab27..f9b50928 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -9,11 +9,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: ocaml/setup-ocaml@v2 - with: - ocaml-compiler: 5.1.1 - - run: opam install dune - - run: opam exec -- dune build - - run: opam exec -- dune install - - run: eval $(opam env) && ./test.sh dbl ./test/test_suite - + - name: Install Nix + uses: cachix/install-nix-action@v17 + - run: nix shell . --command ./test.sh dbl ./test/test_suite diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..de1b9d0f --- /dev/null +++ b/flake.lock @@ -0,0 +1,267 @@ +{ + "nodes": { + "cpspg": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "cpspg", + "opam-nix", + "nixpkgs" + ], + "opam-nix": [ + "opam-nix" + ] + }, + "locked": { + "lastModified": 1734182177, + "narHash": "sha256-b2pWUouugPrt8Ra5QoB+jhVwZeIgNTjfVRFv9Im7G2Q=", + "owner": "Brychlikov", + "repo": "cpspg", + "rev": "ab0a8575683e4eb75100c137ea76a3e01962b365", + "type": "github" + }, + "original": { + "owner": "Brychlikov", + "repo": "cpspg", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "mirage-opam-overlays": { + "flake": false, + "locked": { + "lastModified": 1710922379, + "narHash": "sha256-j4QREQDUf8oHOX7qg6wAOupgsNQoYlufxoPrgagD+pY=", + "owner": "dune-universe", + "repo": "mirage-opam-overlays", + "rev": "797cb363df3ff763c43c8fbec5cd44de2878757e", + "type": "github" + }, + "original": { + "owner": "dune-universe", + "repo": "mirage-opam-overlays", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1730785428, + "narHash": "sha256-Zwl8YgTVJTEum+L+0zVAWvXAGbWAuXHax3KzuejaDyo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4aa36568d413aca0ea84a1684d2d46f55dbabad7", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "opam-nix": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_3", + "mirage-opam-overlays": "mirage-opam-overlays", + "nixpkgs": "nixpkgs", + "opam-overlays": "opam-overlays", + "opam-repository": "opam-repository", + "opam2json": "opam2json" + }, + "locked": { + "lastModified": 1733921344, + "narHash": "sha256-D4BFlu5VQCugO6wlze3BxDz5fkxoZishQTIwITLdSw8=", + "owner": "tweag", + "repo": "opam-nix", + "rev": "43ec9805677c7ca3decd57f034c9a148bad5215c", + "type": "github" + }, + "original": { + "owner": "tweag", + "repo": "opam-nix", + "type": "github" + } + }, + "opam-overlays": { + "flake": false, + "locked": { + "lastModified": 1726822209, + "narHash": "sha256-bwM18ydNT9fYq91xfn4gmS21q322NYrKwfq0ldG9GYw=", + "owner": "dune-universe", + "repo": "opam-overlays", + "rev": "f2bec38beca4aea9e481f2fd3ee319c519124649", + "type": "github" + }, + "original": { + "owner": "dune-universe", + "repo": "opam-overlays", + "type": "github" + } + }, + "opam-repository": { + "flake": false, + "locked": { + "lastModified": 1732612513, + "narHash": "sha256-kju4NWEQo4xTxnKeBIsmqnyxIcCg6sNZYJ1FmG/gCDw=", + "owner": "ocaml", + "repo": "opam-repository", + "rev": "3d52b66b04788999a23f22f0d59c2dfc831c4f32", + "type": "github" + }, + "original": { + "owner": "ocaml", + "repo": "opam-repository", + "type": "github" + } + }, + "opam2json": { + "inputs": { + "nixpkgs": [ + "opam-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1671540003, + "narHash": "sha256-5pXfbUfpVABtKbii6aaI2EdAZTjHJ2QntEf0QD2O5AM=", + "owner": "tweag", + "repo": "opam2json", + "rev": "819d291ea95e271b0e6027679de6abb4d4f7f680", + "type": "github" + }, + "original": { + "owner": "tweag", + "repo": "opam2json", + "type": "github" + } + }, + "root": { + "inputs": { + "cpspg": "cpspg", + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "opam-nix", + "nixpkgs" + ], + "opam-nix": "opam-nix" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..78607624 --- /dev/null +++ b/flake.nix @@ -0,0 +1,45 @@ +{ + inputs = { + opam-nix.url = "github:tweag/opam-nix"; + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.follows = "opam-nix/nixpkgs"; + cpspg.url = "github:adampsz/cpspg"; + cpspg.inputs.opam-nix.follows = "opam-nix"; + }; + outputs = { self, flake-utils, opam-nix, nixpkgs, cpspg }@inputs: + let package = "dbl"; + in flake-utils.lib.eachSystem ["x86_64-linux"] (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + on = opam-nix.lib.${system}; + scope = + on.buildDuneProject { } package ./. { ocaml-system = "*"; }; + overlay = final: prev: + { + ${package} = prev.${package}.overrideAttrs + (oa: { nativeBuildInputs = oa.nativeBuildInputs ++ [ cpspg.packages.${system}.default ]; }); + }; + in rec { + legacyPackages = scope.overrideScope overlay; + + packages.default = self.legacyPackages.${system}.${package}; + devShells.default = with pkgs; pkgs.mkShell { + buildInputs = [ + cpspg.packages.${system}.default + # Source file formatting + nixpkgs-fmt + ocamlformat + # For `dune build --watch ...` + fswatch + # For `dune build @doc` + ocamlPackages.odoc + # OCaml editor support + ocamlPackages.ocaml-lsp + # Nicely formatted types on hover + ocamlPackages.ocamlformat-rpc-lib + # Fancy REPL thing + ocamlPackages.utop + ]; + }; + }); +} diff --git a/src/DblParser/YaccParser.mly b/src/DblParser/YaccParser.mly index 834432f0..dcd59bf2 100644 --- a/src/DblParser/YaccParser.mly +++ b/src/DblParser/YaccParser.mly @@ -145,7 +145,7 @@ op | op_80 { $1 } | op_90 { $1 } | op_100 { $1 } -; +; /* ========================================================================= */ @@ -391,7 +391,7 @@ expr_90 ; // exp1 ** exp2 -expr_100 +expr_100 : expr_150 op_100 expr_100 { make (EBOp($1, $2, $3)) } | expr_150 { $1 } ; @@ -417,6 +417,7 @@ expr_select : UID DOT expr_ctor { (NPName $1, $3) } | UID DOT expr_300 { (NPName $1, $3) } | UID DOT expr_select { let (p, e) = $3 in (NPSel($1, p), e) } +; expr_250 : expr_300 { $1 } diff --git a/src/DblParser/dune b/src/DblParser/dune index 852ef18b..c43de9a1 100644 --- a/src/DblParser/dune +++ b/src/DblParser/dune @@ -1,5 +1,10 @@ -(ocamlyacc (modules YaccParser)) (ocamllex (modules Lexer)) +;(ocamlyacc (modules YaccParser)); + +(rule + (deps YaccParser.mly) + (targets YaccParser.ml YaccParser.mli) + (action (chdir %{workspace_root} (run cpspg --compat %{deps} %{targets})))) (library (name dblParser) diff --git a/test.sh b/test.sh index 4a01e654..721cf6ed 100755 --- a/test.sh +++ b/test.sh @@ -1,18 +1,18 @@ #!/usr/bin/env bash if ! [ -n "$1" ] || ! [ -n "$2" ]; then - echo "USAGE: ./test.sh PROGRAM TEST_SUITE" + echo "USAGE: ./test.sh BINARY TEST_SUITE" exit 1 fi -if ! dune build; then - exit 1 -fi +# if ! dune build; then +# exit 1 +# fi export DBL_LIB="lib/" TIMEOUT=1.0 -binary="_build/default/src/$1.exe" +binary=$1 flags="" RED='\033[0;31m'