From 977e4d34a1609f872b64e4ba68ef669241197b91 Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Sat, 7 Sep 2024 15:29:14 +0200 Subject: [PATCH] Upgrade to cmdlang.0.0.4 --- .github/workflows/ci.yml | 2 +- CHANGES.md | 8 +- Makefile | 2 +- bin/dune | 2 +- bin/main.ml | 4 +- bopkit-tests.opam | 20 +-- bopkit.opam | 18 +-- doc/dune | 3 +- doc/reference/dune | 2 + dune-project | 129 +++++++++--------- editor/README.md | 23 +++- editor/dune | 1 + lib/bopkit/src/comments.ml | 9 +- lib/bopkit/src/control_structure.ml | 11 +- lib/bopkit/src/dune | 13 +- lib/bopkit_bdd/src/block.ml | 2 +- lib/bopkit_bdd/src/dune | 13 +- lib/bopkit_bdd_command/src/dune | 4 +- lib/bopkit_block/src/bopkit_block.ml | 2 +- lib/bopkit_block/src/dune | 6 +- lib/bopkit_circuit/src/cds.ml | 2 +- lib/bopkit_circuit/src/circuit.ml | 2 +- lib/bopkit_circuit/src/circuit.mli | 4 +- lib/bopkit_circuit/src/dune | 17 +-- lib/bopkit_command/src/cmd_bop2c.ml | 2 +- lib/bopkit_command/src/cmd_check.ml | 6 +- lib/bopkit_command/src/cmd_simu.ml | 2 +- lib/bopkit_command/src/dune | 12 +- lib/bopkit_compiler/src/bopkit_compiler.ml | 47 ++++--- lib/bopkit_compiler/src/dune | 12 +- .../src/pass_expanded_block.ml | 2 +- .../src/pass_expanded_netlist.ml | 4 +- .../src/pass_expanded_nodes.ml | 2 +- lib/bopkit_compiler/src/pass_includes.ml | 4 +- lib/bopkit_compiler/src/pass_memories.ml | 39 +++--- lib/bopkit_compiler/src/pass_parameters.ml | 2 +- lib/bopkit_process/src/dune | 13 +- lib/bopkit_process/src/program.ml | 20 +-- lib/bopkit_process/src/program.mli | 10 +- .../src/bopkit_process_command.ml | 2 +- lib/bopkit_process_command/src/dune | 12 +- lib/bopkit_process_interpreter/src/dune | 8 +- .../src/interpreted_code.ml | 18 +-- lib/bopkit_process_pp/src/dune | 13 +- lib/bopkit_process_pp/src/program.ml | 8 +- lib/bopkit_process_syntax/src/dune | 13 +- lib/bopkit_process_syntax/src/parser.mly | 4 +- lib/bopkit_simulator/src/circuit_simulator.ml | 25 ++-- lib/bopkit_simulator/src/config.ml | 6 +- lib/bopkit_simulator/src/dune | 12 +- lib/bopkit_syntax/src/bopkit_syntax.ml | 2 +- lib/bopkit_syntax/src/dune | 13 +- lib/bopkit_syntax/src/lexer.mll | 4 +- lib/bopkit_to_c/src/bopkit_to_c.ml | 19 +-- lib/bopkit_to_c/src/dune | 14 +- lib/bopkit_topological_sort/test/dune | 7 +- .../test/test__bopkit_topological_sort.ml | 2 +- project/digital-watch/dune | 13 +- project/digital-watch/remove_duplicates.ml | 2 +- project/subleq/bin/dune | 2 +- project/subleq/bin/main.ml | 4 +- project/subleq/circuit/dune | 5 +- project/subleq/dune | 1 + project/subleq/lib/subleq_command/src/dune | 6 +- project/subleq/test/simulator/dune | 1 + project/visa/bin/dune | 2 +- project/visa/bin/main.ml | 2 +- project/visa/circuit/dune | 5 +- project/visa/circuit/get_date.ml | 2 +- project/visa/doc/dune | 2 + .../visa/lib/visa/src/assembly_instruction.ml | 4 +- .../lib/visa/src/assembly_instruction.mli | 2 +- project/visa/lib/visa/src/dune | 10 +- project/visa/lib/visa/src/executable.ml | 2 +- project/visa/lib/visa/src/instruction.ml | 4 +- project/visa/lib/visa/src/machine_code.ml | 12 +- project/visa/lib/visa/src/program.ml | 6 +- project/visa/lib/visa/src/program.mli | 6 +- project/visa/lib/visa_assembler/src/dune | 15 +- .../lib/visa_assembler/src/visa_assembler.ml | 86 ++++++------ .../lib/visa_assembler/src/visa_assembler.mli | 16 +-- project/visa/lib/visa_command/src/dune | 12 +- .../visa/lib/visa_command/src/visa_command.ml | 10 +- project/visa/lib/visa_dsl/src/dune | 14 +- project/visa/lib/visa_dsl/src/visa_dsl.ml | 21 ++- project/visa/lib/visa_dsl/test/dune | 7 +- .../visa/lib/visa_dsl/test/test__visa_dsl.ml | 6 +- project/visa/lib/visa_pp/src/program.ml | 6 +- project/visa/lib/visa_simulator/src/code.ml | 4 +- project/visa/lib/visa_simulator/src/code.mli | 2 +- project/visa/lib/visa_simulator/src/dune | 16 +-- .../lib/visa_simulator/src/execution_stack.ml | 4 +- .../visa_simulator/src/execution_stack.mli | 4 +- .../lib/visa_simulator/src/visa_simulator.ml | 8 +- .../lib/visa_simulator/src/visa_simulator.mli | 2 +- project/visa/lib/visa_syntax/src/dune | 4 +- project/visa/lib/visa_syntax/src/parser.mly | 8 +- project/visa/test/assembler/error/dune | 1 + project/visa/test/assembler/syntax/dune | 1 + project/visa/test/assembler/syntax/run.t | 15 +- project/visa/test/disassembler/check/dune | 1 + project/visa/test/disassembler/error/dune | 1 + .../test/disassembler/error/invalid-code.t | 4 +- .../test/disassembler/error/missing-byte.t | 4 +- project/visa/test/runtime/dune | 2 + stdlib/7-segment/bin/digital_calendar.ml | 2 +- .../7-segment/bin/digital_calendar_display.ml | 2 +- stdlib/7-segment/bin/digital_watch.ml | 2 +- stdlib/7-segment/bin/digital_watch_display.ml | 2 +- stdlib/7-segment/bin/dune | 2 +- stdlib/7-segment/dune | 2 + stdlib/7-segment/src/dune | 4 +- stdlib/bopboard/bin/dune | 2 +- stdlib/bopboard/bin/main.ml | 2 +- stdlib/bopboard/example/dune | 2 + stdlib/bopboard/images/dune | 1 + stdlib/bopboard/src/dune | 4 +- stdlib/counter/bin/counter.ml | 2 +- stdlib/counter/bin/dune | 2 +- stdlib/counter/dune | 1 + stdlib/counter/src/dune | 2 +- stdlib/counter/test/dune | 1 + stdlib/memories/bin/dune | 4 +- stdlib/pulse/bin/dune | 2 +- stdlib/pulse/bin/pulse.ml | 2 +- stdlib/pulse/dune | 2 + stdlib/pulse/src/dune | 4 +- stdlib/pulse/test/dune | 1 + stdlib/stdlib/dune | 2 + stdlib/stdlib/test/dune | 1 + subleq.opam | 17 ++- test/bdd/dune | 1 + test/bop2c/dune | 1 + test/bop2c/gen-dune/dune | 6 +- test/bop2c/gen-dune/main.ml | 2 +- test/netlist/check/dune | 1 + test/netlist/error/dune | 1 + test/netlist/runtime/dune | 1 + test/netlist/syntax/dune | 1 + test/netlist/syntax/run.t | 15 +- test/process/error/dune | 1 + test/process/runtime/dune | 1 + test/process/syntax/dune | 1 + test/process/syntax/run.t | 10 +- tutorial/bdd/division/dune | 6 +- tutorial/bdd/dune | 2 + tutorial/functional-args/dune | 1 + tutorial/hello-world/dune | 2 + tutorial/misc/dune | 2 + tutorial/parametrized-blocks/dune | 1 + visa.opam | 17 ++- 151 files changed, 570 insertions(+), 598 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2786b931..5a373f3b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: # janestreet-bleeding-external: https://github.com/janestreet/opam-repository.git#external-packages - name: Install dependencies - run: opam install . --deps-only --with-doc --with-test + run: opam install . --deps-only --with-doc --with-test --with-dev-setup - name: Build run: opam exec -- dune build @all @lint diff --git a/CHANGES.md b/CHANGES.md index 37fdd5f0..941439b7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +## 0.3.1 (2024-09-07) + +### Changed + +- Upgrade to latest `cmdlang`. + ## 0.3.0 (2024-08-23) ### Changed @@ -5,7 +11,7 @@ - Switch from `Error_log` to `Err` for error handling. - Internal refactors, switch from `Core` to `Base` in assorted places. - Split main packages into separate smaller ones. -- Switch to `commandlang` with `cmdliner` as a backend for all commands. Breaking changes: +- Switch to `cmdlang` with `cmdliner` as a backend for all commands. Breaking changes: - Flags and named command line arguments now have 2 '--' instead of 1. - Exit code changes, using now cmdliner default conventions (123, 124, 125). diff --git a/Makefile b/Makefile index 55239e39..f37bffd2 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ lint: .PHONY: deps deps: - opam install . --deps-only --with-doc --with-test + opam install . --deps-only --with-doc --with-test --with-dev-setup .PHONY: doc doc: diff --git a/bin/dune b/bin/dune index de4efb64..aa8dfc9c 100644 --- a/bin/dune +++ b/bin/dune @@ -2,5 +2,5 @@ (name main) (package bopkit) (public_name bopkit) - (libraries bopkit_command commandlang-to-cmdliner) + (libraries bopkit_command cmdlang-to-cmdliner) (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a)) diff --git a/bin/main.ml b/bin/main.ml index c8edd061..1ee06ecc 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -1,3 +1 @@ -let () = - Commandlang_to_cmdliner.run Bopkit_command.main ~name:"bopkit" ~version:"%%VERSION%%" -;; +let () = Cmdlang_to_cmdliner.run Bopkit_command.main ~name:"bopkit" ~version:"%%VERSION%%" diff --git a/bopkit-tests.opam b/bopkit-tests.opam index 45c4f3e9..b3d3861c 100644 --- a/bopkit-tests.opam +++ b/bopkit-tests.opam @@ -10,27 +10,29 @@ bug-reports: "https://github.com/mbarbin/bopkit/issues" depends: [ "dune" {>= "3.16"} "ocaml" {>= "5.2"} + "ocamlformat" {with-dev-setup & = "0.26.2"} "ANSITerminal" {>= "0.8.3"} "appendable-list" {>= "v0.17" & < "v0.18"} - "auto-format" {>= "0.0.11"} + "auto-format" {>= "0.0.12"} "base" {>= "v0.17" & < "v0.18"} "base_quickcheck" {>= "v0.17" & < "v0.18"} + "cmdlang" {>= "0.0.4"} + "cmdlang-to-cmdliner" {>= "0.0.4"} "cmdliner" {= "1.3.0"} - "commandlang" {>= "0.0.2"} - "commandlang-to-cmdliner" {>= "0.0.2"} + "comments-parser" {>= "0.2.0"} "core" {>= "v0.17" & < "v0.18"} "core_unix" {>= "v0.17" & < "v0.18"} "dune-site" {>= "3.16"} - "err0" {>= "0.0.2"} - "err0-handler" {>= "0.0.2"} + "err" {>= "0.0.4"} + "err-cli" {>= "0.0.4"} "expect_test_helpers_core" {>= "v0.17" & < "v0.18"} "fpath" {>= "0.7.3"} - "fpath-base" {>= "0.0.9"} + "fpath-base" {>= "0.2.0"} "graphics" {>= "5.1.2"} - "loc0" {>= "0.1.0"} + "loc" {>= "0.2.0"} "mdx" {>= "2.4"} "menhir" {>= "20220210"} - "parsing-utils" {>= "0.0.8"} + "parsing-utils" {>= "0.2.0"} "pp" {>= "1.2.0"} "pp-extended" {>= "0.0.2"} "ppx_compare" {>= "v0.17" & < "v0.18"} @@ -39,7 +41,7 @@ depends: [ "ppx_fields_conv" {>= "v0.17" & < "v0.18"} "ppx_hash" {>= "v0.17" & < "v0.18"} "ppx_here" {>= "v0.17" & < "v0.18"} - "ppx_js_style" {dev & >= "v0.17" & < "v0.18"} + "ppx_js_style" {with-dev-setup & >= "v0.17" & < "v0.18"} "ppx_let" {>= "v0.17" & < "v0.18"} "ppx_sexp_conv" {>= "v0.17" & < "v0.18"} "ppx_sexp_value" {>= "v0.17" & < "v0.18"} diff --git a/bopkit.opam b/bopkit.opam index 34b5dcf9..cdcf4767 100644 --- a/bopkit.opam +++ b/bopkit.opam @@ -12,24 +12,25 @@ depends: [ "ocaml" {>= "5.2"} "ANSITerminal" {>= "0.8.3"} "appendable-list" {>= "v0.17" & < "v0.18"} - "auto-format" {>= "0.0.11"} + "auto-format" {>= "0.0.12"} "base" {>= "v0.17" & < "v0.18"} "base_quickcheck" {>= "v0.17" & < "v0.18"} + "cmdlang" {>= "0.0.4"} + "cmdlang-to-cmdliner" {>= "0.0.4"} "cmdliner" {= "1.3.0"} - "commandlang" {>= "0.0.2"} - "commandlang-to-cmdliner" {>= "0.0.2"} + "comments-parser" {>= "0.2.0"} "core" {>= "v0.17" & < "v0.18"} "core_unix" {>= "v0.17" & < "v0.18"} "dune-site" {>= "3.16"} - "err0" {>= "0.0.2"} - "err0-handler" {>= "0.0.2"} + "err" {>= "0.0.4"} + "err-cli" {>= "0.0.4"} "fpath" {>= "0.7.3"} - "fpath-base" {>= "0.0.9"} + "fpath-base" {>= "0.2.0"} "graphics" {>= "5.1.2"} - "loc0" {>= "0.1.0"} + "loc" {>= "0.2.0"} "mdx" {>= "2.4"} "menhir" {>= "20220210"} - "parsing-utils" {>= "0.0.8"} + "parsing-utils" {>= "0.2.0"} "pp" {>= "1.2.0"} "pp-extended" {>= "0.0.2"} "ppx_compare" {>= "v0.17" & < "v0.18"} @@ -37,7 +38,6 @@ depends: [ "ppx_fields_conv" {>= "v0.17" & < "v0.18"} "ppx_hash" {>= "v0.17" & < "v0.18"} "ppx_here" {>= "v0.17" & < "v0.18"} - "ppx_js_style" {dev & >= "v0.17" & < "v0.18"} "ppx_let" {>= "v0.17" & < "v0.18"} "ppx_sexp_conv" {>= "v0.17" & < "v0.18"} "ppx_sexp_value" {>= "v0.17" & < "v0.18"} diff --git a/doc/dune b/doc/dune index b2542175..4e0d182a 100644 --- a/doc/dune +++ b/doc/dune @@ -1 +1,2 @@ -(mdx) +(mdx + (package bopkit-tests)) diff --git a/doc/reference/dune b/doc/reference/dune index c7eb9fde..b8f897e9 100644 --- a/doc/reference/dune +++ b/doc/reference/dune @@ -1,4 +1,5 @@ (mdx + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) @@ -19,6 +20,7 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (package bopkit) %{bin:bopkit} diff --git a/dune-project b/dune-project index cc267a65..7196c38e 100644 --- a/dune-project +++ b/dune-project @@ -40,7 +40,7 @@ (>= v0.17) (< v0.18))) (auto-format - (>= 0.0.11)) + (>= 0.0.12)) (base (and (>= v0.17) @@ -49,12 +49,14 @@ (and (>= v0.17) (< v0.18))) + (cmdlang + (>= 0.0.4)) + (cmdlang-to-cmdliner + (>= 0.0.4)) (cmdliner (= 1.3.0)) - (commandlang - (>= 0.0.2)) - (commandlang-to-cmdliner - (>= 0.0.2)) + (comments-parser + (>= 0.2.0)) (core (and (>= v0.17) @@ -65,24 +67,24 @@ (< v0.18))) (dune-site (>= 3.16)) - (err0 - (>= 0.0.2)) - (err0-handler - (>= 0.0.2)) + (err + (>= 0.0.4)) + (err-cli + (>= 0.0.4)) (fpath (>= 0.7.3)) (fpath-base - (>= 0.0.9)) + (>= 0.2.0)) (graphics (>= 5.1.2)) - (loc0 - (>= 0.1.0)) + (loc + (>= 0.2.0)) (mdx (>= 2.4)) (menhir (>= 20220210)) (parsing-utils - (>= 0.0.8)) + (>= 0.2.0)) (pp (>= 1.2.0)) (pp-extended @@ -107,11 +109,6 @@ (and (>= v0.17) (< v0.18))) - (ppx_js_style - (and - :dev - (>= v0.17) - (< v0.18))) (ppx_let (and (>= v0.17) @@ -150,7 +147,7 @@ (>= v0.17) (< v0.18))) (auto-format - (>= 0.0.11)) + (>= 0.0.12)) (base (and (>= v0.17) @@ -161,12 +158,12 @@ (< v0.18))) (bopkit (= :version)) + (cmdlang + (>= 0.0.4)) + (cmdlang-to-cmdliner + (>= 0.0.4)) (cmdliner (= 1.3.0)) - (commandlang - (>= 0.0.2)) - (commandlang-to-cmdliner - (>= 0.0.2)) (core (and (>= v0.17) @@ -177,24 +174,24 @@ (< v0.18))) (dune-site (>= 3.16)) - (err0 - (>= 0.0.2)) - (err0-handler - (>= 0.0.2)) + (err + (>= 0.0.4)) + (err-cli + (>= 0.0.4)) (fpath (>= 0.7.3)) (fpath-base - (>= 0.0.9)) + (>= 0.2.0)) (graphics (>= 5.1.2)) - (loc0 - (>= 0.1.0)) + (loc + (>= 0.2.0)) (mdx (>= 2.4)) (menhir (>= 20220210)) (parsing-utils - (>= 0.0.8)) + (>= 0.2.0)) (pp (>= 1.2.0)) (pp-extended @@ -219,11 +216,6 @@ (and (>= v0.17) (< v0.18))) - (ppx_js_style - (and - :dev - (>= v0.17) - (< v0.18))) (ppx_let (and (>= v0.17) @@ -258,7 +250,7 @@ (>= v0.17) (< v0.18))) (auto-format - (>= 0.0.11)) + (>= 0.0.12)) (base (and (>= v0.17) @@ -269,12 +261,12 @@ (< v0.18))) (bopkit (= :version)) + (cmdlang + (>= 0.0.4)) + (cmdlang-to-cmdliner + (>= 0.0.4)) (cmdliner (= 1.3.0)) - (commandlang - (>= 0.0.2)) - (commandlang-to-cmdliner - (>= 0.0.2)) (core (and (>= v0.17) @@ -285,24 +277,24 @@ (< v0.18))) (dune-site (>= 3.16)) - (err0 - (>= 0.0.2)) - (err0-handler - (>= 0.0.2)) + (err + (>= 0.0.4)) + (err-cli + (>= 0.0.4)) (fpath (>= 0.7.3)) (fpath-base - (>= 0.0.9)) + (>= 0.2.0)) (graphics (>= 5.1.2)) - (loc0 - (>= 0.1.0)) + (loc + (>= 0.2.0)) (mdx (>= 2.4)) (menhir (>= 20220210)) (parsing-utils - (>= 0.0.8)) + (>= 0.2.0)) (pp (>= 1.2.0)) (pp-extended @@ -327,11 +319,6 @@ (and (>= v0.17) (< v0.18))) - (ppx_js_style - (and - :dev - (>= v0.17) - (< v0.18))) (ppx_let (and (>= v0.17) @@ -359,6 +346,10 @@ (depends (ocaml (>= 5.2)) + (ocamlformat + (and + :with-dev-setup + (= 0.26.2))) (ANSITerminal (>= 0.8.3)) (appendable-list @@ -366,7 +357,7 @@ (>= v0.17) (< v0.18))) (auto-format - (>= 0.0.11)) + (>= 0.0.12)) (base (and (>= v0.17) @@ -375,12 +366,14 @@ (and (>= v0.17) (< v0.18))) + (cmdlang + (>= 0.0.4)) + (cmdlang-to-cmdliner + (>= 0.0.4)) (cmdliner (= 1.3.0)) - (commandlang - (>= 0.0.2)) - (commandlang-to-cmdliner - (>= 0.0.2)) + (comments-parser + (>= 0.2.0)) (core (and (>= v0.17) @@ -391,10 +384,10 @@ (< v0.18))) (dune-site (>= 3.16)) - (err0 - (>= 0.0.2)) - (err0-handler - (>= 0.0.2)) + (err + (>= 0.0.4)) + (err-cli + (>= 0.0.4)) (expect_test_helpers_core (and (>= v0.17) @@ -402,17 +395,17 @@ (fpath (>= 0.7.3)) (fpath-base - (>= 0.0.9)) + (>= 0.2.0)) (graphics (>= 5.1.2)) - (loc0 - (>= 0.1.0)) + (loc + (>= 0.2.0)) (mdx (>= 2.4)) (menhir (>= 20220210)) (parsing-utils - (>= 0.0.8)) + (>= 0.2.0)) (pp (>= 1.2.0)) (pp-extended @@ -443,7 +436,7 @@ (< v0.18))) (ppx_js_style (and - :dev + :with-dev-setup (>= v0.17) (< v0.18))) (ppx_let diff --git a/editor/README.md b/editor/README.md index c60a1d0a..5df9ebda 100644 --- a/editor/README.md +++ b/editor/README.md @@ -30,8 +30,7 @@ NAME bopkit-fmt-file - autoformat bopkit files SYNOPSIS - bopkit fmt file [--add-extra-blank-line] [--read-contents-from-stdin] - [OPTION]… FILE + bopkit fmt file [OPTION]… FILE @@ -44,7 +43,7 @@ SYNOPSIS - If [-read-contents-from-stdin] is supplied, then the contents of the + If [--read-contents-from-stdin] is supplied, then the contents of the file is read from stdin. In this case the filename must still be supplied, and will be used for located error messages only. @@ -74,9 +73,27 @@ OPTIONS --add-extra-blank-line add an extra blank line at the end. + --color=WHEN (absent=auto) + Colorize the output. WHEN must be one of 'auto', 'always' or + 'never'. + + -q, --quiet + Be quiet. Takes over v and --verbosity. + --read-contents-from-stdin read contents from stdin rather than from the file. + -v, --verbose + Increase verbosity. Repeatable, but more than twice does not bring + more. + + --verbosity=LEVEL + Be more or less verbose. Takes over v.. LEVEL must be one of + 'quiet', 'error', 'warning', 'info' or 'debug'. + + --warn-error + treat warnings as errors. + COMMON OPTIONS --help[=FMT] (default=auto) Show this help in format FMT. The value FMT must be one of auto, diff --git a/editor/dune b/editor/dune index 08f10e2a..ebc39beb 100644 --- a/editor/dune +++ b/editor/dune @@ -1,3 +1,4 @@ (mdx + (package bopkit-tests) (deps (package bopkit))) diff --git a/lib/bopkit/src/comments.ml b/lib/bopkit/src/comments.ml index 7a0fc9a3..38037147 100644 --- a/lib/bopkit/src/comments.ml +++ b/lib/bopkit/src/comments.ml @@ -1,12 +1,11 @@ -type t = Comment.t list Parsing_utils.Comments_state.Comment_node.t -[@@deriving equal, sexp_of] +type t = Comment.t list Comments_parser.Comment_node.t [@@deriving equal, sexp_of] -let value t = Parsing_utils.Comments_state.Comment_node.value_exn t +let value t = Comments_parser.Comment_node.value_exn t let is_empty t = List.is_empty (value t) let make ~attached_to = - Parsing_utils.Comments_state.comment_node ~attached_to ~f:(fun comments -> + Comments_parser.comment_node ~attached_to ~f:(fun comments -> List.map comments ~f:Comment.parse_exn) ;; -let none = Parsing_utils.Comments_state.Comment_node.return [] +let none = Comments_parser.Comment_node.return [] diff --git a/lib/bopkit/src/control_structure.ml b/lib/bopkit/src/control_structure.ml index 3970f89a..7bc1f3eb 100644 --- a/lib/bopkit/src/control_structure.ml +++ b/lib/bopkit/src/control_structure.ml @@ -70,11 +70,12 @@ let expand t ~parameters ~f = Option.iter (Parameters.find parameters ~parameter_name:j) ~f:(fun previous_value -> Err.debug ~loc - [ Pp.textf - "This shadows the previous value of '%s' (=> %s)." - j - (Parameter.Value.to_syntax previous_value) - ]); + (lazy + [ Pp.textf + "This shadows the previous value of '%s' (=> %s)." + j + (Parameter.Value.to_syntax previous_value) + ])); let inf, sup = ( Arithmetic_expression.eval exp_inf ~parameters |> ok_eval_exn ~loc , Arithmetic_expression.eval exp_sup ~parameters |> ok_eval_exn ~loc ) diff --git a/lib/bopkit/src/dune b/lib/bopkit/src/dune index c108e962..9d972e8d 100644 --- a/lib/bopkit/src/dune +++ b/lib/bopkit/src/dune @@ -10,22 +10,19 @@ -open Base -open - Loc0 - -open - Err0 - -open Fpath_base -open - Commandlang) + Cmdlang) (libraries appendable-list base bit_utils - commandlang - err0 + cmdlang + comments-parser + err fpath fpath-base - loc0 + loc parsing-utils pp) (lint diff --git a/lib/bopkit_bdd/src/block.ml b/lib/bopkit_bdd/src/block.ml index d5a07c7d..bd7cf029 100644 --- a/lib/bopkit_bdd/src/block.ml +++ b/lib/bopkit_bdd/src/block.ml @@ -59,7 +59,7 @@ let unused_variables t = let last = List.last_exn tl in Bopkit.Netlist.Interval (CST first, CST last) in - Bopkit.Netlist.Bus { loc = Loc.dummy_pos; name = Name.input; indexes = [ index ] }) + Bopkit.Netlist.Bus { loc = Loc.none; name = Name.input; indexes = [ index ] }) ;; let pp_ident ident = diff --git a/lib/bopkit_bdd/src/dune b/lib/bopkit_bdd/src/dune index c18c9ee3..06b6c73d 100644 --- a/lib/bopkit_bdd/src/dune +++ b/lib/bopkit_bdd/src/dune @@ -1,17 +1,8 @@ (library (name bopkit_bdd) (public_name bopkit.bdd) - (flags - :standard - -w - +a-4-40-41-42-44-45-48-66 - -warn-error - +a - -open - Base - -open - Loc0) - (libraries base bit_utils bopkit bopkit_pp loc0 pp) + (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a -open Base) + (libraries base bit_utils bopkit bopkit_pp loc pp) (lint (pps ppx_js_style -check-doc-comments)) (preprocess diff --git a/lib/bopkit_bdd_command/src/dune b/lib/bopkit_bdd_command/src/dune index 35936f04..62b5114a 100644 --- a/lib/bopkit_bdd_command/src/dune +++ b/lib/bopkit_bdd_command/src/dune @@ -16,13 +16,13 @@ -open Or_error.Let_syntax -open - Commandlang) + Cmdlang) (libraries base bit_utils bopkit_bdd bopkit_block - commandlang + cmdlang core fpath fpath-base diff --git a/lib/bopkit_block/src/bopkit_block.ml b/lib/bopkit_block/src/bopkit_block.ml index d0f1bea5..0da88a27 100644 --- a/lib/bopkit_block/src/bopkit_block.ml +++ b/lib/bopkit_block/src/bopkit_block.ml @@ -341,7 +341,7 @@ let main ?readme t_param = ;; let run ?readme t_param = - Commandlang_to_cmdliner.run + Cmdlang_to_cmdliner.run (main ?readme t_param) ~name:"bopkit.block" ~version:"%%VERSION%%" diff --git a/lib/bopkit_block/src/dune b/lib/bopkit_block/src/dune index 3189d5b9..c8dd7bbd 100644 --- a/lib/bopkit_block/src/dune +++ b/lib/bopkit_block/src/dune @@ -15,12 +15,12 @@ -open Stdio -open - Commandlang) + Cmdlang) (libraries bit_utils + cmdlang + cmdlang-to-cmdliner cmdliner - commandlang - commandlang-to-cmdliner core core_unix stdio) diff --git a/lib/bopkit_circuit/src/cds.ml b/lib/bopkit_circuit/src/cds.ml index e3c97542..88623871 100644 --- a/lib/bopkit_circuit/src/cds.ml +++ b/lib/bopkit_circuit/src/cds.ml @@ -43,7 +43,7 @@ let topological_sort (cds : t) = let reorder_cds () = Array.init ncds ~f:(fun i -> update_output_wires cds.(order.(i))) in - Err.debug [ Pp.text "Running topological sort of circuit" ]; + Err.debug (lazy [ Pp.text "Running topological sort of circuit" ]); (match cds.(0).gate_kind with | Input -> () | gate_kind -> diff --git a/lib/bopkit_circuit/src/circuit.ml b/lib/bopkit_circuit/src/circuit.ml index cc635bc0..0a6231ec 100644 --- a/lib/bopkit_circuit/src/circuit.ml +++ b/lib/bopkit_circuit/src/circuit.ml @@ -1,6 +1,6 @@ type t = { path : Fpath.t - ; main : string + ; main : string Loc.Txt.t ; rom_memories : Bit_matrix.t array ; external_blocks : Bopkit.Expanded_netlist.external_block array ; cds : Cds.t diff --git a/lib/bopkit_circuit/src/circuit.mli b/lib/bopkit_circuit/src/circuit.mli index d5f94e78..e4a2e2bd 100644 --- a/lib/bopkit_circuit/src/circuit.mli +++ b/lib/bopkit_circuit/src/circuit.mli @@ -9,7 +9,7 @@ type t = private { path : Fpath.t - ; main : string + ; main : string Loc.Txt.t ; rom_memories : Bit_matrix.t array ; external_blocks : Bopkit.Expanded_netlist.external_block array ; cds : Cds.t @@ -19,7 +19,7 @@ type t = private val create_exn : path:Fpath.t - -> main:string + -> main:string Loc.Txt.t -> rom_memories:Bit_matrix.t array -> external_blocks:Bopkit.Expanded_netlist.external_block array -> cds:Cds.t diff --git a/lib/bopkit_circuit/src/dune b/lib/bopkit_circuit/src/dune index e33fe980..6568b434 100644 --- a/lib/bopkit_circuit/src/dune +++ b/lib/bopkit_circuit/src/dune @@ -1,26 +1,15 @@ (library (name bopkit_circuit) (public_name bopkit.circuit) - (flags - :standard - -w - +a-4-40-41-42-44-45-48-66 - -warn-error - +a - -open - Base - -open - Loc0 - -open - Err0) + (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a -open Base) (libraries base bit_utils bopkit bopkit_sites core ;; For [Core.Set_once] - err0 - loc0) + err + loc) (lint (pps ppx_js_style -check-doc-comments)) (preprocess diff --git a/lib/bopkit_command/src/cmd_bop2c.ml b/lib/bopkit_command/src/cmd_bop2c.ml index af14fd8b..267abf94 100644 --- a/lib/bopkit_command/src/cmd_bop2c.ml +++ b/lib/bopkit_command/src/cmd_bop2c.ml @@ -7,7 +7,7 @@ let main = (Param.validated_string (module Fpath)) ~docv:"FILE" ~doc:"target file" - and () = Err_handler.set_config () + and () = Err_cli.set_config () and bopkit_compiler_config = Bopkit_compiler.Config.arg in let circuit = Bopkit_compiler.circuit_of_netlist ~path ~config:bopkit_compiler_config diff --git a/lib/bopkit_command/src/cmd_check.ml b/lib/bopkit_command/src/cmd_check.ml index c8973f94..7fba3273 100644 --- a/lib/bopkit_command/src/cmd_check.ml +++ b/lib/bopkit_command/src/cmd_check.ml @@ -7,13 +7,15 @@ let main = (Param.validated_string (module Fpath)) ~docv:"FILE" ~doc:"file to check" - and () = Err_handler.set_config () + and () = Err_cli.set_config () and print_cds = Arg.flag [ "print-cds" ] ~doc:"print the cds out stdout in case of success" and bopkit_compiler_config = Bopkit_compiler.Config.arg in let circuit = Bopkit_compiler.circuit_of_netlist ~path ~config:bopkit_compiler_config in - Err.info [ Pp.textf "Check of %S complete." (circuit.path |> Fpath.to_string) ]; + Err.info + ~loc:circuit.main.loc + [ Pp.textf "Check of '%s' complete." circuit.main.txt ]; if print_cds then print_s [%sexp (circuit.cds : Bopkit_circuit.Cds.t)]) ;; diff --git a/lib/bopkit_command/src/cmd_simu.ml b/lib/bopkit_command/src/cmd_simu.ml index 4cb54c2b..2b043e4b 100644 --- a/lib/bopkit_command/src/cmd_simu.ml +++ b/lib/bopkit_command/src/cmd_simu.ml @@ -7,7 +7,7 @@ let main = (Param.validated_string (module Fpath)) ~docv:"FILE" ~doc:"file to simulate" - and () = Err_handler.set_config () + and () = Err_cli.set_config () and bopkit_compiler_config = Bopkit_compiler.Config.arg and bopkit_simulator_config = Bopkit_simulator.Config.arg in let circuit = diff --git a/lib/bopkit_command/src/dune b/lib/bopkit_command/src/dune index 460a07a9..3e84ea6f 100644 --- a/lib/bopkit_command/src/dune +++ b/lib/bopkit_command/src/dune @@ -10,17 +10,13 @@ -open Base -open - Err0 - -open - Err0_handler - -open Fpath_base -open Stdio -open Or_error.Let_syntax -open - Commandlang) + Cmdlang) (libraries base bopkit_bdd_command @@ -34,10 +30,10 @@ bopkit_sleeper bopkit_syntax bopkit_to_c - commandlang + cmdlang core - err0 - err0-handler + err + err-cli fpath fpath-base seven_segment_display diff --git a/lib/bopkit_compiler/src/bopkit_compiler.ml b/lib/bopkit_compiler/src/bopkit_compiler.ml index 07b6e0bb..1442387f 100644 --- a/lib/bopkit_compiler/src/bopkit_compiler.ml +++ b/lib/bopkit_compiler/src/bopkit_compiler.ml @@ -37,7 +37,7 @@ let expand_netlist ~path ~config = let parameters = parameters @ List.map (Config.parameters_overrides config) ~f:(fun { name; value } -> - { Bopkit.Netlist.loc = Loc.dummy_pos + { Bopkit.Netlist.loc = Loc.none ; comments = Bopkit.Comments.none ; name ; parameter_value = @@ -77,17 +77,20 @@ let expand_netlist ~path ~config = in Err.debug ~loc - [ Pp.textf - "Returning the blocks in this order:\n%s" - (Sexp.to_string_hum [%sexp (List.map blocks ~f:(fun t -> t.name) : string list)]) - ]; + (lazy + [ Pp.textf + "Returning the blocks in this order:\n%s" + (Sexp.to_string_hum + [%sexp (List.map blocks ~f:(fun t -> t.name) : string list)]) + ]); if Config.print_pass_output config ~pass_name:Expanded_netlist then Err.debug ~loc - [ Pp.textf "Result of Pass_expanded_netlist:" - ; Pp.concat_map blocks ~sep:Pp.newline ~f:Bopkit_pp.Expanded_netlist.pp_block - ]; + (lazy + [ Pp.textf "Result of Pass_expanded_netlist:" + ; Pp.concat_map blocks ~sep:Pp.newline ~f:Bopkit_pp.Expanded_netlist.pp_block + ]); ( primitives , Bopkit.Expanded_netlist. { paths @@ -105,24 +108,26 @@ let circuit_of_netlist ~path ~config = let primitives, expanded_netlist = expand_netlist ~path ~config in let main_block_name = expanded_netlist.main_block_name in let env = Pass_expanded_block.create_env expanded_netlist.blocks ~primitives in - let () = if Err.State.had_errors Err.the_state then Err.exit Some_error in + let () = if Err.had_errors () then Err.exit Err.Exit_code.some_error in let expanded_nodes = Pass_expanded_nodes.pass ~env ~main_block_name ~config in if Config.print_pass_output config ~pass_name:Expanded_nodes then Err.debug ~loc - [ Pp.textf "Result of Pass_expanded_nodes:" - ; Expanded_nodes.pp_debug expanded_nodes - ]; + (lazy + [ Pp.textf "Result of Pass_expanded_nodes:" + ; Expanded_nodes.pp_debug expanded_nodes + ]); let cds = Pass_cds.pass expanded_nodes in let cds = Bopkit_circuit.Cds.split_registers cds in if Config.print_pass_output config ~pass_name:Cds_split_registers then Err.debug ~loc - [ Pp.textf "Result of Pass_cds+split-registers:" - ; Pp.text (Sexp.to_string_hum [%sexp (cds : Bopkit_circuit.Cds.t)]) - ]; + (lazy + [ Pp.textf "Result of Pass_cds+split-registers:" + ; Pp.text (Sexp.to_string_hum [%sexp (cds : Bopkit_circuit.Cds.t)]) + ]); let () = if Bopkit_circuit.Cds.detect_cycle cds then ( @@ -136,16 +141,18 @@ let circuit_of_netlist ~path ~config = (Pp.text "In this block, these variables may create a dependency cycle:" :: Pp.cut :: List.map lines ~f:Pp.verbatim)); - if Err.State.had_errors Err.the_state then Err.exit Some_error) + let () = if Err.had_errors () then Err.exit Err.Exit_code.some_error in + ()) in Bopkit_circuit.Cds.topological_sort cds; if Config.print_pass_output config ~pass_name:Cds_topological_sort then Err.debug ~loc - [ Pp.textf "Result of Pass_cds+topological-sort:" - ; Pp.text (Sexp.to_string_hum [%sexp (cds : Bopkit_circuit.Cds.t)]) - ]; + (lazy + [ Pp.textf "Result of Pass_cds+topological-sort:" + ; Pp.text (Sexp.to_string_hum [%sexp (cds : Bopkit_circuit.Cds.t)]) + ]); let cds = if Config.optimize_cds config then Bopkit_cds_optimizer.optimize cds else cds in @@ -159,7 +166,7 @@ let circuit_of_netlist ~path ~config = ]; Bopkit_circuit.Circuit.create_exn ~path - ~main:main.name + ~main:{ Loc.Txt.txt = main.name; loc = main.loc } ~cds ~rom_memories:expanded_netlist.rom_memories ~external_blocks:(expanded_netlist.external_blocks |> Array.of_list) diff --git a/lib/bopkit_compiler/src/dune b/lib/bopkit_compiler/src/dune index cb6ab040..7f90d087 100644 --- a/lib/bopkit_compiler/src/dune +++ b/lib/bopkit_compiler/src/dune @@ -10,15 +10,11 @@ -open Base -open - Loc0 - -open - Err0 - -open Fpath_base -open Or_error.Let_syntax -open - Commandlang) + Cmdlang) (libraries appendable-list base @@ -30,13 +26,13 @@ bopkit_sites bopkit_syntax bopkit_topological_sort - commandlang + cmdlang core - err0 + err fpath fpath-base graphics - loc0 + loc parsing-utils unix) (lint diff --git a/lib/bopkit_compiler/src/pass_expanded_block.ml b/lib/bopkit_compiler/src/pass_expanded_block.ml index 32541fdb..b394173a 100644 --- a/lib/bopkit_compiler/src/pass_expanded_block.ml +++ b/lib/bopkit_compiler/src/pass_expanded_block.ml @@ -393,7 +393,7 @@ let create_block ;; let create_env list ~primitives = - Err.debug [ Pp.text "Analyzing circuit's blocks." ]; + Err.debug (lazy [ Pp.text "Analyzing circuit's blocks." ]); List.fold_left list ~init:(Map.empty (module String)) diff --git a/lib/bopkit_compiler/src/pass_expanded_netlist.ml b/lib/bopkit_compiler/src/pass_expanded_netlist.ml index aaf5ae37..e1dea52c 100644 --- a/lib/bopkit_compiler/src/pass_expanded_netlist.ml +++ b/lib/bopkit_compiler/src/pass_expanded_netlist.ml @@ -571,8 +571,8 @@ let pass blocks ~primitives ~parameters = match block.name with | Parametrized _ -> () | Standard { name } -> - Err.debug [ Pp.textf "requesting expansion of %s." name ]; - ignore (request_expansion t ~name ~loc:Loc.dummy_pos : Expanded_interface.t)); + Err.debug (lazy [ Pp.textf "requesting expansion of %s." name ]); + ignore (request_expansion t ~name ~loc:Loc.none : Expanded_interface.t)); work_until_finished t; let blocks = Queue.to_list t.resulting_blocks in let blocks = Expanded_block_sort.sort blocks in diff --git a/lib/bopkit_compiler/src/pass_expanded_nodes.ml b/lib/bopkit_compiler/src/pass_expanded_nodes.ml index 74c8c2fb..c213d652 100644 --- a/lib/bopkit_compiler/src/pass_expanded_nodes.ml +++ b/lib/bopkit_compiler/src/pass_expanded_nodes.ml @@ -101,7 +101,7 @@ let pass ~(env : Expanded_block.env) ~main_block_name ~config : Expanded_nodes.t aux_node node; aux_nodes tl in - Err.debug [ Pp.text "Inlining blocks." ]; + Err.debug (lazy [ Pp.text "Inlining blocks." ]); aux_nodes main.nodes; Map.iteri env ~f:(fun ~key:name ~data:fd -> if (not (String.equal name main_block_name)) diff --git a/lib/bopkit_compiler/src/pass_includes.ml b/lib/bopkit_compiler/src/pass_includes.ml index c82f083c..c49c4d61 100644 --- a/lib/bopkit_compiler/src/pass_includes.ml +++ b/lib/bopkit_compiler/src/pass_includes.ml @@ -34,7 +34,9 @@ let pass ~path = let module_name = module_name_of_path ~path in if not (Hash_set.mem included_modules module_name) then ( - Err.debug ~loc [ Pp.textf "--> #include file = %S" (path |> Fpath.to_string) ]; + Err.debug + ~loc + (lazy [ Pp.textf "--> #include file = %S" (path |> Fpath.to_string) ]); let { Bopkit.Netlist.include_files ; parameters ; memories diff --git a/lib/bopkit_compiler/src/pass_memories.ml b/lib/bopkit_compiler/src/pass_memories.ml index a31b0631..5200e53b 100644 --- a/lib/bopkit_compiler/src/pass_memories.ml +++ b/lib/bopkit_compiler/src/pass_memories.ml @@ -39,12 +39,13 @@ let tab_bits_of_code_brut ~loc name taille lg_mot code = let ff i = if i < len_donnee then code.(i) else false in Err.debug ~loc - [ Pp.textf - "Memory '%s' specification: ( %d / %d ) bits specified" - name - len_donnee - len_attendue - ]; + (lazy + [ Pp.textf + "Memory '%s' specification: ( %d / %d ) bits specified" + name + len_donnee + len_attendue + ]); Bit_matrix.init_matrix_linear ~dimx:taille ~dimy:lg_mot ~f:ff) ;; @@ -92,12 +93,13 @@ let pass memories ~parameters = else ( Err.debug ~loc - [ Pp.textf - "Definition of a new memory 'rom_%s(%d, %d)'." - name - address_width - data_width - ]; + (lazy + [ Pp.textf + "Definition of a new memory 'rom_%s(%d, %d)'." + name + address_width + data_width + ]); let code_brut_rom = read_code_brut_memoire ~loc code in let taille_adr = Int.pow 2 address_width in let code_complet = @@ -135,12 +137,13 @@ let pass memories ~parameters = let code_complet, description_code = Err.debug ~loc - [ Pp.textf - "Definition of a new memory 'ram_%s(%d, %d)'." - name - address_width - data_width - ]; + (lazy + [ Pp.textf + "Definition of a new memory 'ram_%s(%d, %d)'." + name + address_width + data_width + ]); match code with | Zero -> ( Bit_matrix.init_matrix_linear ~dimx:taille_adr ~dimy:data_width ~f:(fun _ -> diff --git a/lib/bopkit_compiler/src/pass_parameters.ml b/lib/bopkit_compiler/src/pass_parameters.ml index 9c6ea313..ad78ee4b 100644 --- a/lib/bopkit_compiler/src/pass_parameters.ml +++ b/lib/bopkit_compiler/src/pass_parameters.ml @@ -40,7 +40,7 @@ let pass parameters = let parameters = (* We add a variable to allow the user to know on which OS it is executing. *) let current_os = - { Bopkit.Netlist.loc = Loc.dummy_pos + { Bopkit.Netlist.loc = Loc.none ; comments = Bopkit.Comments.none ; name = "CURRENT_OS" ; parameter_value = diff --git a/lib/bopkit_process/src/dune b/lib/bopkit_process/src/dune index 99256f75..5083f4fc 100644 --- a/lib/bopkit_process/src/dune +++ b/lib/bopkit_process/src/dune @@ -1,17 +1,8 @@ (library (name bopkit_process) (public_name bopkit.process) - (flags - :standard - -w - +a-4-40-41-42-44-45-48-66 - -warn-error - +a - -open - Base - -open - Loc0) - (libraries base core loc0 parsing-utils) + (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a -open Base) + (libraries base core loc parsing-utils) (lint (pps ppx_js_style -check-doc-comments)) (preprocess diff --git a/lib/bopkit_process/src/program.ml b/lib/bopkit_process/src/program.ml index 4858ee50..05898870 100644 --- a/lib/bopkit_process/src/program.ml +++ b/lib/bopkit_process/src/program.ml @@ -1,18 +1,18 @@ module T = struct type argument = - | Ident of { ident : Ident.t With_loc.t } + | Ident of { ident : Ident.t Loc.Txt.t } | Constant of { value : int } and assignment = { comments : string list - ; result : Ident.t With_loc.t - ; operator_name : Operator_name.t With_loc.t + ; result : Ident.t Loc.Txt.t + ; operator_name : Operator_name.t Loc.Txt.t ; arguments : argument array } and t = - { input : Ident.t With_loc.t array - ; output : Ident.t With_loc.t array + { input : Ident.t Loc.Txt.t array + ; output : Ident.t Loc.Txt.t array ; assignments : assignment list ; head_comments : string list ; tail_comments : string list @@ -21,7 +21,7 @@ end module Argument = struct type t = T.argument = - | Ident of { ident : Ident.t With_loc.t } + | Ident of { ident : Ident.t Loc.Txt.t } | Constant of { value : int } [@@deriving equal, sexp_of] end @@ -29,16 +29,16 @@ end module Assignment = struct type t = T.assignment = { comments : string list - ; result : Ident.t With_loc.t - ; operator_name : Operator_name.t With_loc.t + ; result : Ident.t Loc.Txt.t + ; operator_name : Operator_name.t Loc.Txt.t ; arguments : Argument.t array } [@@deriving equal, sexp_of] end type t = T.t = - { input : Ident.t With_loc.t array - ; output : Ident.t With_loc.t array + { input : Ident.t Loc.Txt.t array + ; output : Ident.t Loc.Txt.t array ; assignments : Assignment.t list ; head_comments : string list ; tail_comments : string list diff --git a/lib/bopkit_process/src/program.mli b/lib/bopkit_process/src/program.mli index e08f34b9..85b2959c 100644 --- a/lib/bopkit_process/src/program.mli +++ b/lib/bopkit_process/src/program.mli @@ -2,7 +2,7 @@ module Argument : sig type t = - | Ident of { ident : Ident.t With_loc.t } + | Ident of { ident : Ident.t Loc.Txt.t } | Constant of { value : int } [@@deriving equal, sexp_of] end @@ -10,16 +10,16 @@ end module Assignment : sig type t = { comments : string list - ; result : Ident.t With_loc.t - ; operator_name : Operator_name.t With_loc.t + ; result : Ident.t Loc.Txt.t + ; operator_name : Operator_name.t Loc.Txt.t ; arguments : Argument.t array } [@@deriving equal, sexp_of] end type t = - { input : Ident.t With_loc.t array - ; output : Ident.t With_loc.t array + { input : Ident.t Loc.Txt.t array + ; output : Ident.t Loc.Txt.t array ; assignments : Assignment.t list ; head_comments : string list ; tail_comments : string list diff --git a/lib/bopkit_process_command/src/bopkit_process_command.ml b/lib/bopkit_process_command/src/bopkit_process_command.ml index c5135857..fa5565b9 100644 --- a/lib/bopkit_process_command/src/bopkit_process_command.ml +++ b/lib/bopkit_process_command/src/bopkit_process_command.ml @@ -8,7 +8,7 @@ let exec_cmd = (Param.validated_string (module Fpath)) ~docv:"FILE" ~doc:"input process file" - and () = Err_handler.set_config () in + and () = Err_cli.set_config () in let program = Parsing_utils.parse_file_exn (module Bopkit_process_syntax) ~path in match Bopkit_process_interpreter.run_program ~architecture:n ~program with | Ok () -> () diff --git a/lib/bopkit_process_command/src/dune b/lib/bopkit_process_command/src/dune index e830f071..5cd7373c 100644 --- a/lib/bopkit_process_command/src/dune +++ b/lib/bopkit_process_command/src/dune @@ -10,13 +10,9 @@ -open Base -open - Err0 - -open - Err0_handler - -open Fpath_base -open - Commandlang) + Cmdlang) (libraries auto-format base @@ -24,9 +20,9 @@ bopkit_process_interpreter bopkit_process_pp bopkit_process_syntax - commandlang - err0 - err0-handler + cmdlang + err + err-cli fpath fpath-base pp) diff --git a/lib/bopkit_process_interpreter/src/dune b/lib/bopkit_process_interpreter/src/dune index b9276b7e..faf33485 100644 --- a/lib/bopkit_process_interpreter/src/dune +++ b/lib/bopkit_process_interpreter/src/dune @@ -10,18 +10,14 @@ -open Base -open - Loc0 - -open - Err0 - -open Stdio) (libraries base bit_utils bopkit_process bopkit_process_syntax - err0 - loc0 + err + loc stdio) (lint (pps ppx_js_style -check-doc-comments)) diff --git a/lib/bopkit_process_interpreter/src/interpreted_code.ml b/lib/bopkit_process_interpreter/src/interpreted_code.ml index 29ce669e..f267ea1e 100644 --- a/lib/bopkit_process_interpreter/src/interpreted_code.ml +++ b/lib/bopkit_process_interpreter/src/interpreted_code.ml @@ -28,17 +28,17 @@ type t = } [@@deriving sexp_of] -let unknown_operator_error ~(operator_name : Bopkit_process.Operator_name.t With_loc.t) = +let unknown_operator_error ~(operator_name : Bopkit_process.Operator_name.t Loc.Txt.t) = Err.error ~loc:operator_name.loc [ Pp.textf "operator '%s' is not defined" - (Bopkit_process.Operator_name.to_string operator_name.symbol) + (Bopkit_process.Operator_name.to_string operator_name.txt) ] ;; let operator_arity_error - ~(operator_name : Bopkit_process.Operator_name.t With_loc.t) + ~(operator_name : Bopkit_process.Operator_name.t Loc.Txt.t) ~arity ~number_of_arguments = @@ -46,7 +46,7 @@ let operator_arity_error ~loc:operator_name.loc [ Pp.textf "Operator '%s' has arity %d but is applied to %d argument%s" - (Bopkit_process.Operator_name.to_string operator_name.symbol) + (Bopkit_process.Operator_name.to_string operator_name.txt) arity number_of_arguments (if number_of_arguments > 1 then "s" else "") @@ -73,7 +73,7 @@ let of_program ~architecture ~(program : Bopkit_process.Program.t) = Hashtbl.set memory ~key:memory_index ~data:value; { Address.memory_index } | Ident { ident } -> - (match Hashtbl.find addresses ident.symbol with + (match Hashtbl.find addresses ident.txt with | Some v -> v | None -> if not is_assigned @@ -82,12 +82,12 @@ let of_program ~architecture ~(program : Bopkit_process.Program.t) = ~loc:ident.loc [ Pp.textf "Variable '%s' is read before assignment" - (Bopkit_process.Ident.to_string ident.symbol) + (Bopkit_process.Ident.to_string ident.txt) ]; let memory_index = next_memory_index () in let address = { Address.memory_index } in let value = Array.create ~len:architecture false in - Hashtbl.set addresses ~key:ident.symbol ~data:address; + Hashtbl.set addresses ~key:ident.txt ~data:address; Hashtbl.set memory ~key:memory_index ~data:value; address) in @@ -107,7 +107,7 @@ let of_program ~architecture ~(program : Bopkit_process.Program.t) = [ [| Bopkit_process.Program.Argument.Ident { ident = result } |]; arguments ] |> Array.mapi ~f:(fun i operand -> var_map ~is_assigned:(i = 0) operand) in - match Map.find (force Operator.primitives) operator_name.symbol with + match Map.find (force Operator.primitives) operator_name.txt with | None -> unknown_operator_error ~operator_name | Some operator -> let arity = Operator.arity operator in @@ -128,6 +128,6 @@ let of_program ~architecture ~(program : Bopkit_process.Program.t) = Array.init num_addresses ~f:(fun i -> Hashtbl.find memory i |> Option.value_exn ~here:[%here]) in - let () = if Err.State.had_errors Err.the_state then Err.exit Some_error in + let () = if Err.had_errors () then Err.exit Err.Exit_code.some_error in { architecture; memory; code } ;; diff --git a/lib/bopkit_process_pp/src/dune b/lib/bopkit_process_pp/src/dune index cb7d883e..e97b09dd 100644 --- a/lib/bopkit_process_pp/src/dune +++ b/lib/bopkit_process_pp/src/dune @@ -1,17 +1,8 @@ (library (name bopkit_process_pp) (public_name bopkit.process-pp) - (flags - :standard - -w - +a-4-40-41-42-44-45-48-66 - -warn-error - +a - -open - Base - -open - Loc0) - (libraries base bopkit_process loc0 pp) + (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a -open Base) + (libraries base bopkit_process loc pp) (lint (pps ppx_js_style -check-doc-comments)) (preprocess diff --git a/lib/bopkit_process_pp/src/program.ml b/lib/bopkit_process_pp/src/program.ml index d96c4760..41c3c32f 100644 --- a/lib/bopkit_process_pp/src/program.ml +++ b/lib/bopkit_process_pp/src/program.ml @@ -1,11 +1,11 @@ type t = Bopkit_process.Program.t -let pp_ident (ident : Bopkit_process.Ident.t With_loc.t) = - Pp.verbatim (ident.symbol |> Bopkit_process.Ident.to_string) +let pp_ident (ident : Bopkit_process.Ident.t Loc.Txt.t) = + Pp.verbatim (ident.txt |> Bopkit_process.Ident.to_string) ;; -let pp_operator_name (operator_name : Bopkit_process.Operator_name.t With_loc.t) = - Pp.verbatim (operator_name.symbol |> Bopkit_process.Operator_name.to_string) +let pp_operator_name (operator_name : Bopkit_process.Operator_name.t Loc.Txt.t) = + Pp.verbatim (operator_name.txt |> Bopkit_process.Operator_name.to_string) ;; let pp_argument (argument : Bopkit_process.Program.Argument.t) = diff --git a/lib/bopkit_process_syntax/src/dune b/lib/bopkit_process_syntax/src/dune index 782a4dd0..188eff45 100644 --- a/lib/bopkit_process_syntax/src/dune +++ b/lib/bopkit_process_syntax/src/dune @@ -6,14 +6,5 @@ (library (name bopkit_process_syntax) (public_name bopkit.process-syntax) - (flags - :standard - -w - +a-4-40-41-42-44-45-48-66 - -warn-error - +a - -open - Core - -open - Loc0) - (libraries bopkit_process core loc0 parsing-utils)) + (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a -open Core) + (libraries bopkit_process core loc parsing-utils)) diff --git a/lib/bopkit_process_syntax/src/parser.mly b/lib/bopkit_process_syntax/src/parser.mly index 32222ae8..5677460f 100644 --- a/lib/bopkit_process_syntax/src/parser.mly +++ b/lib/bopkit_process_syntax/src/parser.mly @@ -5,7 +5,7 @@ match argument with | Constant { value = _ } -> failwith "An operator is expected, not a constant" | Ident { ident } -> - With_loc.map ident ~f:(fun ident -> + Loc.Txt.map ident ~f:(fun ident -> ident |> Ident.to_string |> Operator_name.of_string) ;; %} @@ -74,6 +74,6 @@ ident_list : ; ident : - | ident=IDENT { With_loc.create $loc ident } + | ident=IDENT { Loc.Txt.create $loc ident } ; diff --git a/lib/bopkit_simulator/src/circuit_simulator.ml b/lib/bopkit_simulator/src/circuit_simulator.ml index 82c73b42..081326ab 100644 --- a/lib/bopkit_simulator/src/circuit_simulator.ml +++ b/lib/bopkit_simulator/src/circuit_simulator.ml @@ -180,7 +180,9 @@ let init t = in (match Hashtbl.find external_blocks_table name with | Some block_index -> - Err.debug ~loc [ Pp.textf "External process[%d] already started." block_index ]; + Err.debug + ~loc + (lazy [ Pp.textf "External process[%d] already started." block_index ]); (* Even though this gate is unique in the cds, it is possible that its gate_kind has been shared between several gates. This happens when a block is called multiple times at different part of the program. @@ -193,7 +195,7 @@ let init t = Int.incr external_index; Err.debug ~loc - [ Pp.textf "Starting external process[%d] = '%s'." this_index command ]; + (lazy [ Pp.textf "Starting external process[%d] = '%s'." this_index command ]); Hashtbl.set external_blocks_table ~key:name ~data:this_index; let output_pipe, input_pipe = Core_unix.open_process command in let external_process = @@ -233,7 +235,7 @@ let init t = if (not (Hashtbl.mem external_blocks_table a)) && false then Err.warning ~loc [ Pp.textf "Unused external block '%s'" a ]); t.external_process <- Queue.to_array external_processes; - Err.info [ Pp.textf " Simulation <'%s'>" (main t) ] + Err.info [ Pp.textf " Simulation <'%s'>" (main t).txt ] ;; let or_exit_error e = @@ -251,7 +253,7 @@ let quit t = let process = t.external_process.(i) in Err.debug ~loc:process.loc - [ Pp.textf "Closing external process[%d] = '%s'." i process.command ]; + (lazy [ Pp.textf "Closing external process[%d] = '%s'." i process.command ]); match Core_unix.close_process (process.output_pipe, process.input_pipe) |> or_exit_error with @@ -275,13 +277,14 @@ let quit t = | exception End_of_file -> Err.debug ~loc:process.loc - [ Pp.textf - "Closing external process[%d] = '%s'. (status : %s [%d])" - i - process.command - "broken pipe" - (-1) - ] + (lazy + [ Pp.textf + "Closing external process[%d] = '%s'. (status : %s [%d])" + i + process.command + "broken pipe" + (-1) + ]) | exception e -> prerr_endline "Circuit#quit error"; Queue.enqueue uncaught_exceptions e diff --git a/lib/bopkit_simulator/src/config.ml b/lib/bopkit_simulator/src/config.ml index 50892516..3248c4d5 100644 --- a/lib/bopkit_simulator/src/config.ml +++ b/lib/bopkit_simulator/src/config.ml @@ -41,7 +41,7 @@ let arg = | [ a ] -> a | _ :: _ :: _ -> Err.raise - ~exit_code:Cli_error + ~exit_code:Err.Exit_code.cli_error [ Pp.text "Cannot specify both --num-cycles and --num-counter-cycles" ] and counter_input = Arg.flag [ "counter-input" ] ~doc:"use a counter as circuit inputs" and output_kind = @@ -69,7 +69,9 @@ let arg = | [] -> default.output_kind | [ a ] -> a | _ :: _ :: _ -> - Err.raise ~exit_code:Cli_error [ Pp.text "Cannot specify multiple output kinds" ] + Err.raise + ~exit_code:Err.Exit_code.cli_error + [ Pp.text "Cannot specify multiple output kinds" ] in { num_cycles ; counter_input = diff --git a/lib/bopkit_simulator/src/dune b/lib/bopkit_simulator/src/dune index c0f3e4f2..0df85e37 100644 --- a/lib/bopkit_simulator/src/dune +++ b/lib/bopkit_simulator/src/dune @@ -10,25 +10,21 @@ -open Base -open - Loc0 - -open - Err0 - -open Stdio -open Or_error.Let_syntax -open - Commandlang) + Cmdlang) (libraries base bopkit_circuit - commandlang + cmdlang core core_unix core_unix.sys_unix - err0 + err fpath - loc0 + loc stdio) (lint (pps ppx_js_style -check-doc-comments)) diff --git a/lib/bopkit_syntax/src/bopkit_syntax.ml b/lib/bopkit_syntax/src/bopkit_syntax.ml index 52f2a5c1..c0d1cbd1 100644 --- a/lib/bopkit_syntax/src/bopkit_syntax.ml +++ b/lib/bopkit_syntax/src/bopkit_syntax.ml @@ -2,4 +2,4 @@ type t = Bopkit.Netlist.t type token = Parser.token let lexer = Lexer.read -let parser = Parser.netlist +let parser lexer lexbuf = Comments_parser.wrap ~f:(fun () -> Parser.netlist lexer lexbuf) diff --git a/lib/bopkit_syntax/src/dune b/lib/bopkit_syntax/src/dune index 4998135b..7b522ee0 100644 --- a/lib/bopkit_syntax/src/dune +++ b/lib/bopkit_syntax/src/dune @@ -15,14 +15,5 @@ (library (name bopkit_syntax) (public_name bopkit.syntax) - (flags - :standard - -w - +a-4-40-41-42-44-45-48-66 - -warn-error - +a - -open - Core - -open - Loc0) - (libraries bopkit core loc0 parsing-utils)) + (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a -open Core) + (libraries bopkit comments-parser core loc parsing-utils)) diff --git a/lib/bopkit_syntax/src/lexer.mll b/lib/bopkit_syntax/src/lexer.mll index f33b638b..671562f7 100644 --- a/lib/bopkit_syntax/src/lexer.mll +++ b/lib/bopkit_syntax/src/lexer.mll @@ -12,11 +12,11 @@ let one_line_comment = ['/'] ['/'] [^'\n']* newline rule read = parse | (['/'] ['*'] ([^'*'] | (['*'] [^'/']))* ['*'] ['/']) as comment - { Parsing_utils.Comments_state.add_comment ~lexbuf ~comment; + { Comments_parser.add_comment ~lexbuf ~comment; Syntax_util.new_lines ~lexbuf comment; read lexbuf } - | one_line_comment as comment { Parsing_utils.Comments_state.add_comment ~lexbuf ~comment; + | one_line_comment as comment { Comments_parser.add_comment ~lexbuf ~comment; Lexing.new_line lexbuf; read lexbuf } | newline { Lexing.new_line lexbuf; diff --git a/lib/bopkit_to_c/src/bopkit_to_c.ml b/lib/bopkit_to_c/src/bopkit_to_c.ml index f9cc27b1..2d1884bc 100644 --- a/lib/bopkit_to_c/src/bopkit_to_c.ml +++ b/lib/bopkit_to_c/src/bopkit_to_c.ml @@ -38,12 +38,13 @@ let fragments_of_cds ~(cds : Bopkit_circuit.Cds.t) = | None -> let constant = if input_value then "1" else "0" in Err.debug - [ Pp.textf - "Unassigned input (%d, %d) : Constant = %s" - gate_index - input_index - constant - ]; + (lazy + [ Pp.textf + "Unassigned input (%d, %d) : Constant = %s" + gate_index + input_index + constant + ]); constant) in let outputs = @@ -64,7 +65,7 @@ let fragments_of_cds ~(cds : Bopkit_circuit.Cds.t) = match gate.gate_kind with | Input -> let input_width = output_width in - Err.debug [ Pp.textf "Input Count : %d" input_width ]; + Err.debug (lazy [ Pp.textf "Input Count : %d" input_width ]); Queue.enqueue q_declarations (C_code.input_declaration ~input_width); Queue.enqueue q_declarations (C_code.input ~input_width); emit @@ -72,7 +73,7 @@ let fragments_of_cds ~(cds : Bopkit_circuit.Cds.t) = ++ Pp.verbatim ";") | Output -> let output_width = input_width in - Err.debug [ Pp.textf "Output Count : %d" output_width ]; + Err.debug (lazy [ Pp.textf "Output Count : %d" output_width ]); Queue.enqueue q_declarations (C_code.output_declaration ~output_width); Queue.enqueue q_declarations (C_code.output ~output_width); emit (C_code.call ~name:"output" ~args:inputs ++ Pp.verbatim ";") @@ -139,7 +140,7 @@ let emit_c_code ~(circuit : Bopkit_circuit.Circuit.t) ~to_:oc = (Printf.sprintf "/* Original circuit : %s , Main = \"%s\" */" (path |> Fpath.to_string) - main) + main.txt) ++ Pp.newline ; Pp.newline ; Pp.verbatim "#include " ++ Pp.newline diff --git a/lib/bopkit_to_c/src/dune b/lib/bopkit_to_c/src/dune index 28820eee..6de59be1 100644 --- a/lib/bopkit_to_c/src/dune +++ b/lib/bopkit_to_c/src/dune @@ -1,21 +1,13 @@ (library (name bopkit_to_c) (public_name bopkit.to_c) - (flags - :standard - -w - +a-4-40-41-42-44-45-48-66 - -warn-error - +a - -open - Base - -open - Err0) + (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a -open Base) (libraries base bopkit_circuit bopkit_compiler - err0 + err + loc parsing-utils pp pp-extended) diff --git a/lib/bopkit_topological_sort/test/dune b/lib/bopkit_topological_sort/test/dune index bc4ec4cd..88f7bde2 100644 --- a/lib/bopkit_topological_sort/test/dune +++ b/lib/bopkit_topological_sort/test/dune @@ -10,16 +10,11 @@ -open Base -open - Err0 - -open - Err0_handler - -open Expect_test_helpers_base) (libraries base bopkit_topological_sort - err0 - err0-handler + err expect_test_helpers_core.expect_test_helpers_base) (inline_tests) (lint diff --git a/lib/bopkit_topological_sort/test/test__bopkit_topological_sort.ml b/lib/bopkit_topological_sort/test/test__bopkit_topological_sort.ml index 0c9694c1..3d730634 100644 --- a/lib/bopkit_topological_sort/test/test__bopkit_topological_sort.ml +++ b/lib/bopkit_topological_sort/test/test__bopkit_topological_sort.ml @@ -12,7 +12,7 @@ end let%expect_test "sort" = let test nodes = - Err_handler.For_test.protect (fun () -> + Err.For_test.protect (fun () -> let nodes = List.map (Bopkit_topological_sort.sort (module T) (module String) nodes) diff --git a/project/digital-watch/dune b/project/digital-watch/dune index 3c0c2c3b..93d34ad2 100644 --- a/project/digital-watch/dune +++ b/project/digital-watch/dune @@ -11,15 +11,8 @@ -open Stdio -open - Commandlang) - (libraries - base - cmdliner - commandlang - commandlang-to-cmdliner - graphics - stdio - threads) + Cmdlang) + (libraries base cmdlang cmdlang-to-cmdliner cmdliner graphics stdio threads) (preprocess (pps ppx_compare @@ -101,11 +94,13 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) (mdx + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) diff --git a/project/digital-watch/remove_duplicates.ml b/project/digital-watch/remove_duplicates.ml index 132610b5..6a7f921a 100644 --- a/project/digital-watch/remove_duplicates.ml +++ b/project/digital-watch/remove_duplicates.ml @@ -22,4 +22,4 @@ let main = done)) ;; -let () = Commandlang_to_cmdliner.run main ~name:"remove_duplicate" ~version:"%%VERSION%%" +let () = Cmdlang_to_cmdliner.run main ~name:"remove_duplicate" ~version:"%%VERSION%%" diff --git a/project/subleq/bin/dune b/project/subleq/bin/dune index f39aa8b8..5839ce66 100644 --- a/project/subleq/bin/dune +++ b/project/subleq/bin/dune @@ -2,5 +2,5 @@ (name main) (package subleq) (public_name subleq) - (libraries commandlang-to-cmdliner subleq_command) + (libraries cmdlang-to-cmdliner subleq_command) (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a)) diff --git a/project/subleq/bin/main.ml b/project/subleq/bin/main.ml index 64eb7632..8f67e2bb 100644 --- a/project/subleq/bin/main.ml +++ b/project/subleq/bin/main.ml @@ -1,3 +1 @@ -let () = - Commandlang_to_cmdliner.run Subleq_command.main ~name:"subleq" ~version:"%%VERSION%%" -;; +let () = Cmdlang_to_cmdliner.run Subleq_command.main ~name:"subleq" ~version:"%%VERSION%%" diff --git a/project/subleq/circuit/dune b/project/subleq/circuit/dune index 3c2f8804..b540bc3d 100644 --- a/project/subleq/circuit/dune +++ b/project/subleq/circuit/dune @@ -10,10 +10,10 @@ -open Stdio -open - Commandlang) + Cmdlang) (libraries base - commandlang + cmdlang core core_unix.core_thread bopkit_block @@ -46,6 +46,7 @@ (run %{bin:bopkit} simu %{dep:main.bop} --parameter 'WithPulse=1'))) (cram + (package bopkit-tests) (deps (package bopkit) (package subleq) diff --git a/project/subleq/dune b/project/subleq/dune index 9c798e11..48974f5e 100644 --- a/project/subleq/dune +++ b/project/subleq/dune @@ -1,4 +1,5 @@ (mdx + (package bopkit-tests) (deps (package bopkit) (glob_files *.input))) diff --git a/project/subleq/lib/subleq_command/src/dune b/project/subleq/lib/subleq_command/src/dune index 2e0d773a..00c8dd65 100644 --- a/project/subleq/lib/subleq_command/src/dune +++ b/project/subleq/lib/subleq_command/src/dune @@ -14,14 +14,14 @@ -open Stdio -open - Commandlang) + Cmdlang) (libraries base bit_utils bopkit_memory + cmdlang + cmdlang-to-cmdliner cmdliner - commandlang - commandlang-to-cmdliner core fpath fpath-base diff --git a/project/subleq/test/simulator/dune b/project/subleq/test/simulator/dune index 6fe10b95..0929149b 100644 --- a/project/subleq/test/simulator/dune +++ b/project/subleq/test/simulator/dune @@ -1,4 +1,5 @@ (cram + (package bopkit-tests) (deps (package bopkit) (glob_files *.input) diff --git a/project/visa/bin/dune b/project/visa/bin/dune index df11ebed..ab9e57d2 100644 --- a/project/visa/bin/dune +++ b/project/visa/bin/dune @@ -2,5 +2,5 @@ (name main) (package visa) (public_name visa) - (libraries commandlang-to-cmdliner visa_command) + (libraries cmdlang-to-cmdliner visa_command) (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a)) diff --git a/project/visa/bin/main.ml b/project/visa/bin/main.ml index 6ddbf322..4ed818d9 100644 --- a/project/visa/bin/main.ml +++ b/project/visa/bin/main.ml @@ -1 +1 @@ -let () = Commandlang_to_cmdliner.run Visa_command.main ~name:"visa" ~version:"%%VERSION%%" +let () = Cmdlang_to_cmdliner.run Visa_command.main ~name:"visa" ~version:"%%VERSION%%" diff --git a/project/visa/circuit/dune b/project/visa/circuit/dune index 5616f521..5afe5060 100644 --- a/project/visa/circuit/dune +++ b/project/visa/circuit/dune @@ -171,8 +171,8 @@ -open Stdio -open - Commandlang) - (libraries base bopkit_block commandlang core stdio unix threads) + Cmdlang) + (libraries base bopkit_block cmdlang core stdio unix threads) (preprocess (pps ppx_compare @@ -186,6 +186,7 @@ -check-doc-comments))) (cram + (package bopkit-tests) (deps (package bopkit) get_date.exe diff --git a/project/visa/circuit/get_date.ml b/project/visa/circuit/get_date.ml index a0cfe7ec..d5945852 100644 --- a/project/visa/circuit/get_date.ml +++ b/project/visa/circuit/get_date.ml @@ -33,4 +33,4 @@ let cmd = ()) ;; -let () = Commandlang_to_cmdliner.run cmd ~name:"get_date" ~version:"%%VERSION%%" +let () = Cmdlang_to_cmdliner.run cmd ~name:"get_date" ~version:"%%VERSION%%" diff --git a/project/visa/doc/dune b/project/visa/doc/dune index b2c691cd..941ef3a6 100644 --- a/project/visa/doc/dune +++ b/project/visa/doc/dune @@ -1,4 +1,5 @@ (cram + (package bopkit-tests) (deps (package bopkit) (package visa) @@ -9,6 +10,7 @@ (glob_files *.bop))) (mdx + (package bopkit-tests) (deps (package bopkit) (package visa) diff --git a/project/visa/lib/visa/src/assembly_instruction.ml b/project/visa/lib/visa/src/assembly_instruction.ml index 80ed6d66..ac903c52 100644 --- a/project/visa/lib/visa/src/assembly_instruction.ml +++ b/project/visa/lib/visa/src/assembly_instruction.ml @@ -30,7 +30,7 @@ end type t = { loc : Loc.t ; operation_kind : Operation_kind.t - ; arguments : Argument.t With_loc.t list + ; arguments : Argument.t Loc.Txt.t list } [@@deriving equal, sexp_of] @@ -40,7 +40,7 @@ let to_string { loc = _; operation_kind; arguments } = | Macro_call { macro_name } -> Macro_name.to_string macro_name | Instruction { instruction_name } -> Instruction_name.to_string instruction_name in - let arguments = List.map arguments ~f:(fun t -> Argument.to_string t.symbol) in + let arguments = List.map arguments ~f:(fun t -> Argument.to_string t.txt) in match arguments with | [] -> operator | _ :: _ -> String.concat [ operator; String.concat arguments ~sep:", " ] ~sep:" " diff --git a/project/visa/lib/visa/src/assembly_instruction.mli b/project/visa/lib/visa/src/assembly_instruction.mli index 8af0c8c4..8844d27e 100644 --- a/project/visa/lib/visa/src/assembly_instruction.mli +++ b/project/visa/lib/visa/src/assembly_instruction.mli @@ -21,7 +21,7 @@ end type t = { loc : Loc.t ; operation_kind : Operation_kind.t - ; arguments : Argument.t With_loc.t list + ; arguments : Argument.t Loc.Txt.t list } [@@deriving equal, sexp_of] diff --git a/project/visa/lib/visa/src/dune b/project/visa/lib/visa/src/dune index 61cdf1ff..f02882db 100644 --- a/project/visa/lib/visa/src/dune +++ b/project/visa/lib/visa/src/dune @@ -10,19 +10,15 @@ -open Base -open - Loc0 - -open - Err0 - -open Stdio) (libraries base bit_utils - commandlang + cmdlang core ;; For [Core.String_id] - err0 + err fpath - loc0 + loc parsing-utils pp stdio) diff --git a/project/visa/lib/visa/src/executable.ml b/project/visa/lib/visa/src/executable.ml index 0d0ba284..e60615da 100644 --- a/project/visa/lib/visa/src/executable.ml +++ b/project/visa/lib/visa/src/executable.ml @@ -16,7 +16,7 @@ module With_labels = struct (* As of now it is not clear how we build values of type [t], it is possible we will determine that it is possible to obtain some real positions from it. To be determined. *) - let label = With_loc.with_dummy_pos label in + let label = Loc.Txt.no_loc label in Queue.enqueue program (Label_introduction { label })); Queue.enqueue program diff --git a/project/visa/lib/visa/src/instruction.ml b/project/visa/lib/visa/src/instruction.ml index 5371a83c..bcdc171e 100644 --- a/project/visa/lib/visa/src/instruction.ml +++ b/project/visa/lib/visa/src/instruction.ml @@ -51,9 +51,9 @@ let map t ~f = let disassemble t ~disassemble_label = let instr instruction_name arguments = - { Assembly_instruction.loc = Loc.dummy_pos + { Assembly_instruction.loc = Loc.none ; operation_kind = Instruction { instruction_name } - ; arguments = List.map arguments ~f:(fun a -> With_loc.with_dummy_pos a) + ; arguments = List.map arguments ~f:(fun a -> Loc.Txt.no_loc a) } in match t with diff --git a/project/visa/lib/visa/src/machine_code.ml b/project/visa/lib/visa/src/machine_code.ml index ef6ec64b..86389727 100644 --- a/project/visa/lib/visa/src/machine_code.ml +++ b/project/visa/lib/visa/src/machine_code.ml @@ -165,12 +165,14 @@ type t = Byte.t array [@@deriving equal, sexp_of] let of_text_file_exn ~path = let q = Queue.create () in - let lines = - try Stdio.In_channel.read_lines (path |> Fpath.to_string) with + let file_contents = + try Stdio.In_channel.read_all (path |> Fpath.to_string) with | Sys_error (m : string) -> Err.raise ~loc:(Loc.in_file ~path) [ Pp.text m ] in + let lines = String.split_lines file_contents in + let file_cache = Loc.File_cache.create ~path ~file_contents in List.iteri lines ~f:(fun i line -> - let loc = Loc.in_file_at_line ~path ~line:i in + let loc = Loc.in_file_line ~file_cache ~line:(Int.succ i) in if not (String.is_prefix line ~prefix:"//") then ( let length = String.length line in @@ -218,6 +220,8 @@ let of_instructions (instructions : int Instruction.t array) = ;; let to_instructions (bytes : t) ~path = + let file_contents = In_channel.read_all (path |> Fpath.to_string) in + let file_cache = Loc.File_cache.create ~path ~file_contents in let size = Array.length bytes in let label_resolution = (* Because some instructions are encoded on 1 byte, and others on 2, there @@ -232,7 +236,7 @@ let to_instructions (bytes : t) ~path = while not (Queue.is_empty bytes) do label_resolution.(size - Queue.length bytes) <- Queue.length results; let line, byte = Queue.dequeue_exn bytes in - let loc = Loc.in_file_at_line ~path ~line in + let loc = Loc.in_file_line ~file_cache ~line in let operation = match Operation.of_byte byte with | Some operation -> operation diff --git a/project/visa/lib/visa/src/program.ml b/project/visa/lib/visa/src/program.ml index 560e05d2..aee697c3 100644 --- a/project/visa/lib/visa/src/program.ml +++ b/project/visa/lib/visa/src/program.ml @@ -10,15 +10,15 @@ module Top_level_construct = struct | Newline | Comment of { text : string } | Constant_definition of - { constant_name : Constant_name.t With_loc.t + { constant_name : Constant_name.t Loc.Txt.t ; constant_kind : Constant_kind.t } | Macro_definition of - { macro_name : Macro_name.t With_loc.t + { macro_name : Macro_name.t Loc.Txt.t ; parameters : Parameter_name.t list ; body : Assembly_instruction.t list } - | Label_introduction of { label : Label.t With_loc.t } + | Label_introduction of { label : Label.t Loc.Txt.t } | Assembly_instruction of { assembly_instruction : Assembly_instruction.t } [@@deriving equal, sexp_of] end diff --git a/project/visa/lib/visa/src/program.mli b/project/visa/lib/visa/src/program.mli index e2222bf3..b7f50b86 100644 --- a/project/visa/lib/visa/src/program.mli +++ b/project/visa/lib/visa/src/program.mli @@ -21,15 +21,15 @@ module Top_level_construct : sig | Newline | Comment of { text : string } | Constant_definition of - { constant_name : Constant_name.t With_loc.t + { constant_name : Constant_name.t Loc.Txt.t ; constant_kind : Constant_kind.t } | Macro_definition of - { macro_name : Macro_name.t With_loc.t + { macro_name : Macro_name.t Loc.Txt.t ; parameters : Parameter_name.t list ; body : Assembly_instruction.t list } - | Label_introduction of { label : Label.t With_loc.t } + | Label_introduction of { label : Label.t Loc.Txt.t } | Assembly_instruction of { assembly_instruction : Assembly_instruction.t } [@@deriving equal, sexp_of] end diff --git a/project/visa/lib/visa_assembler/src/dune b/project/visa/lib/visa_assembler/src/dune index 71bf4b4e..7c9c9ee8 100644 --- a/project/visa/lib/visa_assembler/src/dune +++ b/project/visa/lib/visa_assembler/src/dune @@ -1,19 +1,8 @@ (library (name visa_assembler) (public_name bopkit.visa-assembler) - (flags - :standard - -w - +a-4-40-41-42-44-45-48-66 - -warn-error - +a - -open - Base - -open - Loc0 - -open - Err0) - (libraries base err0 loc0 visa) + (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a -open Base) + (libraries base err loc visa) (lint (pps ppx_js_style -check-doc-comments)) (preprocess diff --git a/project/visa/lib/visa_assembler/src/visa_assembler.ml b/project/visa/lib/visa_assembler/src/visa_assembler.ml index f61d2b14..e7ef229f 100644 --- a/project/visa/lib/visa_assembler/src/visa_assembler.ml +++ b/project/visa/lib/visa_assembler/src/visa_assembler.ml @@ -2,13 +2,13 @@ open! Or_error.Let_syntax module Assembly_construct = struct type t = - | Label_introduction of { label : Visa.Label.t With_loc.t } + | Label_introduction of { label : Visa.Label.t Loc.Txt.t } | Assembly_instruction of { assembly_instruction : Visa.Assembly_instruction.t } end module Macro_definition = struct type t = - { macro_name : Visa.Macro_name.t With_loc.t + { macro_name : Visa.Macro_name.t Loc.Txt.t ; parameters : Visa.Parameter_name.t list ; body : Visa.Assembly_instruction.t list } @@ -17,9 +17,9 @@ end module Environment = struct type t = - { constants : Visa.Program.Constant_kind.t With_loc.t Map.M(Visa.Constant_name).t + { constants : Visa.Program.Constant_kind.t Loc.Txt.t Map.M(Visa.Constant_name).t ; macros : Macro_definition.t Map.M(Visa.Macro_name).t - ; labels : Visa.Label.t With_loc.t Map.M(Visa.Label).t + ; labels : Visa.Label.t Loc.Txt.t Map.M(Visa.Label).t } [@@deriving sexp_of] end @@ -29,7 +29,7 @@ let build_environment ~(program : Visa.Program.t) = let macros = Hashtbl.create (module Visa.Macro_name) in let labels = Hashtbl.create (module Visa.Label) in let code : Assembly_construct.t Queue.t = Queue.create () in - let pending_label_introduction : Visa.Label.t With_loc.t option ref = ref None in + let pending_label_introduction : Visa.Label.t Loc.Txt.t option ref = ref None in let emit_code ~assembly_instruction = (match !pending_label_introduction with | None -> () @@ -42,31 +42,31 @@ let build_environment ~(program : Visa.Program.t) = match top_level_construct with | Newline | Comment { text = (_ : string) } -> () | Constant_definition { constant_name; constant_kind } -> - if Hashtbl.mem constants constant_name.symbol + if Hashtbl.mem constants constant_name.txt then Err.error ~loc:constant_name.loc [ Pp.text "Multiple definition of constants is not allowed" ; Pp.text (Sexp.to_string_hum - [%sexp { constant_name : Visa.Constant_name.t With_loc.t }]) + [%sexp { constant_name : Visa.Constant_name.t Loc.Txt.t }]) ]; Hashtbl.set constants - ~key:constant_name.symbol - ~data:(With_loc.map constant_name ~f:(Fn.const constant_kind)) + ~key:constant_name.txt + ~data:(Loc.Txt.map constant_name ~f:(Fn.const constant_kind)) | Macro_definition { macro_name; parameters; body } -> - if Hashtbl.mem macros macro_name.symbol + if Hashtbl.mem macros macro_name.txt then Err.error ~loc:macro_name.loc [ Pp.text "Multiple definition of macros is not allowed" ; Pp.text - (Sexp.to_string_hum [%sexp { macro_name : Visa.Macro_name.t With_loc.t }]) + (Sexp.to_string_hum [%sexp { macro_name : Visa.Macro_name.t Loc.Txt.t }]) ]; Hashtbl.set macros - ~key:macro_name.symbol + ~key:macro_name.txt ~data:{ Macro_definition.macro_name; parameters; body } | Label_introduction { label } -> (match !pending_label_introduction with @@ -76,17 +76,17 @@ let build_environment ~(program : Visa.Program.t) = ~loc:label.loc [ Pp.textf "Label '%s' was not followed by any instruction" - (Visa.Label.to_string label.symbol) + (Visa.Label.to_string label.txt) ]); pending_label_introduction := Some label; - if Hashtbl.mem labels label.symbol + if Hashtbl.mem labels label.txt then Err.error ~loc:label.loc [ Pp.text "Multiple definition of label is not allowed" - ; Pp.text (Sexp.to_string_hum [%sexp { label : Visa.Label.t With_loc.t }]) + ; Pp.text (Sexp.to_string_hum [%sexp { label : Visa.Label.t Loc.Txt.t }]) ]; - Hashtbl.set labels ~key:label.symbol ~data:label + Hashtbl.set labels ~key:label.txt ~data:label | Assembly_instruction { assembly_instruction } -> emit_code ~assembly_instruction); let code = Queue.to_list code in let environment = @@ -104,7 +104,7 @@ let check_unused_macro_parameters ~(environment : Environment.t) = let used_parameters = Hash_set.create (module Visa.Parameter_name) in List.iter body ~f:(function { loc = _; operation_kind = _; arguments } -> List.iter arguments ~f:(fun argument -> - match argument.symbol with + match argument.txt with | Parameter { parameter_name } -> Hash_set.add used_parameters parameter_name | _ -> ())); let unused_parameters = @@ -119,7 +119,7 @@ let check_unused_macro_parameters ~(environment : Environment.t) = ; Pp.text (Sexp.to_string_hum [%sexp - { macro_name : Visa.Macro_name.t With_loc.t + { macro_name : Visa.Macro_name.t Loc.Txt.t ; unused_parameters : Visa.Parameter_name.t list }]) ]) @@ -133,7 +133,7 @@ let check_unused_definitions let used_macros = Hash_set.create (module Visa.Macro_name) in let used_labels = Hash_set.create (module Visa.Label) in List.iter assembly_constructs ~f:(function - | Label_introduction { label = (_ : Visa.Label.t With_loc.t) } -> () + | Label_introduction { label = (_ : Visa.Label.t Loc.Txt.t) } -> () | Assembly_instruction { assembly_instruction = { loc = _; operation_kind; arguments } } -> let () = @@ -142,7 +142,7 @@ let check_unused_definitions | Instruction { instruction_name = _ } -> () in List.iter arguments ~f:(fun argument -> - match argument.symbol with + match argument.txt with | Value { value = (_ : int) } | Address { address = (_ : Visa.Address.t) } | Register { register_name = (_ : Visa.Register_name.t) } @@ -156,17 +156,17 @@ let check_unused_definitions ~loc:constant.loc [ Pp.textf "Unused constant '%s'" (Visa.Constant_name.to_string constant_name) ]); Map.iter environment.macros ~f:(fun { macro_name; _ } -> - if not (Hash_set.mem used_macros macro_name.symbol) + if not (Hash_set.mem used_macros macro_name.txt) then Err.warning ~loc:macro_name.loc - [ Pp.textf "Unused macro '%s'" (Visa.Macro_name.to_string macro_name.symbol) ]); + [ Pp.textf "Unused macro '%s'" (Visa.Macro_name.to_string macro_name.txt) ]); Map.iter environment.labels ~f:(fun label -> - if not (Hash_set.mem used_labels label.symbol) + if not (Hash_set.mem used_labels label.txt) then Err.warning ~loc:label.loc - [ Pp.textf "Unused label '%s'" (Visa.Label.to_string label.symbol) ]); + [ Pp.textf "Unused label '%s'" (Visa.Label.to_string label.txt) ]); () ;; @@ -209,7 +209,7 @@ let build_instruction ~(environment : Environment.t) ~loc ~instruction_name ~arg | [ x; y ] -> return (x, y) | [] | [ _ ] | _ :: _ :: _ :: _ -> arity_error ~expects:2 in - let invalid_argument ~arg ~argument:{ With_loc.loc; symbol = argument } ~expected = + let invalid_argument ~arg ~argument:{ Loc.Txt.txt = argument; loc } ~expected = Error ( loc , Error.create_s @@ -221,13 +221,13 @@ let build_instruction ~(environment : Environment.t) ~loc ~instruction_name ~arg ; applied_to = (argument : Visa.Assembly_instruction.Argument.t) }] ) in - let register_name ~arg (argument : Visa.Assembly_instruction.Argument.t With_loc.t) = - match argument.symbol with + let register_name ~arg (argument : Visa.Assembly_instruction.Argument.t Loc.Txt.t) = + match argument.txt with | Register { register_name } -> return register_name | _ -> invalid_argument ~arg ~argument ~expected:[%sexp Register] in - let label ~arg (argument : Visa.Assembly_instruction.Argument.t With_loc.t) = - match argument.symbol with + let label ~arg (argument : Visa.Assembly_instruction.Argument.t Loc.Txt.t) = + match argument.txt with | Label { label } -> if Map.mem environment.labels label then return label @@ -237,13 +237,13 @@ let build_instruction ~(environment : Environment.t) ~loc ~instruction_name ~arg , Error.create_s [%sexp "Undefined label", { label : Visa.Label.t }] ) | _ -> invalid_argument ~arg ~argument ~expected:[%sexp Label] in - let address ~arg (argument : Visa.Assembly_instruction.Argument.t With_loc.t) = - match argument.symbol with + let address ~arg (argument : Visa.Assembly_instruction.Argument.t Loc.Txt.t) = + match argument.txt with | Address { address } -> return address | _ -> invalid_argument ~arg ~argument ~expected:[%sexp Address] in - let value ~arg (argument : Visa.Assembly_instruction.Argument.t With_loc.t) = - match argument.symbol with + let value ~arg (argument : Visa.Assembly_instruction.Argument.t Loc.Txt.t) = + match argument.txt with | Value { value } -> return value | _ -> invalid_argument ~arg ~argument ~expected:[%sexp Constant] in @@ -295,7 +295,7 @@ let build_instruction ~(environment : Environment.t) ~loc ~instruction_name ~arg | LOAD -> let%bind arg1, arg2 = two_arguments () in let%bind register_name = register_name ~arg:2 arg2 in - (match arg1.symbol with + (match arg1.txt with | Value _ -> let%map value = value ~arg:1 arg1 in Visa.Instruction.Load_value { value; register_name } @@ -310,10 +310,10 @@ let build_instruction ~(environment : Environment.t) ~loc ~instruction_name ~arg let rec lookup_argument ~(environment : Environment.t) ~bindings - ~(argument : Visa.Assembly_instruction.Argument.t With_loc.t) + ~(argument : Visa.Assembly_instruction.Argument.t Loc.Txt.t) = let open Result.Let_syntax in - match argument.symbol with + match argument.txt with | Parameter { parameter_name } -> (match List.Assoc.find bindings parameter_name ~equal:Visa.Parameter_name.equal with | Some argument -> lookup_argument ~environment ~bindings ~argument @@ -326,12 +326,12 @@ let rec lookup_argument (match Map.find environment.constants constant_name with | Some constant -> return - { With_loc.loc = argument.loc - ; symbol = - (match constant.symbol with + { Loc.Txt.txt = + (match constant.txt with | Value { value } -> Visa.Assembly_instruction.Argument.Value { value } | Address { address } -> Visa.Assembly_instruction.Argument.Address { address }) + ; loc = argument.loc } | None -> Error @@ -346,10 +346,10 @@ let program_to_executable_with_labels ~(program : Visa.Program.t) = check_unused_definitions ~environment ~assembly_constructs; check_unused_macro_parameters ~environment; let executable : Visa.Executable.With_labels.Line.t Queue.t = Queue.create () in - let pending_label_introduction : Visa.Label.t With_loc.t option ref = ref None in + let pending_label_introduction : Visa.Label.t Loc.Txt.t option ref = ref None in let emit_instruction ~instruction = let label_introduction = - pending_label_introduction.contents |> Option.map ~f:With_loc.symbol + pending_label_introduction.contents |> Option.map ~f:Loc.Txt.txt in pending_label_introduction := None; Queue.enqueue executable { label_introduction; instruction } @@ -395,7 +395,7 @@ let program_to_executable_with_labels ~(program : Visa.Program.t) = ; Pp.text (Sexp.to_string_hum [%sexp - { macro_name : Visa.Macro_name.t With_loc.t + { macro_name : Visa.Macro_name.t Loc.Txt.t ; expected = (List.length parameters : int) ; applied_to = (List.length arguments : int) }]) @@ -405,7 +405,7 @@ let program_to_executable_with_labels ~(program : Visa.Program.t) = | Label_introduction { label } -> pending_label_introduction := Some label | Assembly_instruction { assembly_instruction } -> process_assembly_instruction ~bindings:[] ~assembly_instruction); - let () = if Err.State.had_errors Err.the_state then Err.exit Some_error in + let () = if Err.had_errors () then Err.exit Err.Exit_code.some_error in Queue.to_array executable ;; diff --git a/project/visa/lib/visa_assembler/src/visa_assembler.mli b/project/visa/lib/visa_assembler/src/visa_assembler.mli index 4d99bcb7..4c6834d5 100644 --- a/project/visa/lib/visa_assembler/src/visa_assembler.mli +++ b/project/visa/lib/visa_assembler/src/visa_assembler.mli @@ -2,13 +2,13 @@ module Assembly_construct : sig (** After the environment is built, the assembler only keep these top level constructs from the original program. *) type t = private - | Label_introduction of { label : Visa.Label.t With_loc.t } + | Label_introduction of { label : Visa.Label.t Loc.Txt.t } | Assembly_instruction of { assembly_instruction : Visa.Assembly_instruction.t } end module Macro_definition : sig type t = private - { macro_name : Visa.Macro_name.t With_loc.t + { macro_name : Visa.Macro_name.t Loc.Txt.t ; parameters : Visa.Parameter_name.t list ; body : Visa.Assembly_instruction.t list } @@ -19,9 +19,9 @@ module Environment : sig (** All the definitions and labels of a program are gathered in an initial pass to build the environment. *) type t = private - { constants : Visa.Program.Constant_kind.t With_loc.t Map.M(Visa.Constant_name).t + { constants : Visa.Program.Constant_kind.t Loc.Txt.t Map.M(Visa.Constant_name).t ; macros : Macro_definition.t Map.M(Visa.Macro_name).t - ; labels : Visa.Label.t With_loc.t Map.M(Visa.Label).t + ; labels : Visa.Label.t Loc.Txt.t Map.M(Visa.Label).t } [@@deriving sexp_of] end @@ -39,15 +39,15 @@ val build_environment val lookup_argument : environment:Environment.t -> bindings: - (Visa.Parameter_name.t * Visa.Assembly_instruction.Argument.t With_loc.t) list - -> argument:Visa.Assembly_instruction.Argument.t With_loc.t - -> Visa.Assembly_instruction.Argument.t With_loc.t Or_located_error.t + (Visa.Parameter_name.t * Visa.Assembly_instruction.Argument.t Loc.Txt.t) list + -> argument:Visa.Assembly_instruction.Argument.t Loc.Txt.t + -> Visa.Assembly_instruction.Argument.t Loc.Txt.t Or_located_error.t val build_instruction : environment:Environment.t -> loc:Loc.t -> instruction_name:Visa.Instruction_name.t - -> arguments:Visa.Assembly_instruction.Argument.t With_loc.t list + -> arguments:Visa.Assembly_instruction.Argument.t Loc.Txt.t list -> Visa.Label.t Visa.Instruction.t Or_located_error.t val program_to_executable_with_labels diff --git a/project/visa/lib/visa_command/src/dune b/project/visa/lib/visa_command/src/dune index d25e2a21..20a6ace9 100644 --- a/project/visa/lib/visa_command/src/dune +++ b/project/visa/lib/visa_command/src/dune @@ -10,22 +10,18 @@ -open Base -open - Err0 - -open - Err0_handler - -open Fpath_base -open Stdio -open - Commandlang) + Cmdlang) (libraries auto-format base - commandlang + cmdlang core - err0 - err0-handler + err + err-cli fpath fpath-base seven_segment_display diff --git a/project/visa/lib/visa_command/src/visa_command.ml b/project/visa/lib/visa_command/src/visa_command.ml index 62cb515a..3bebe8ea 100644 --- a/project/visa/lib/visa_command/src/visa_command.ml +++ b/project/visa/lib/visa_command/src/visa_command.ml @@ -7,7 +7,7 @@ let parse_cmd = (Param.validated_string (module Fpath)) ~docv:"FILE" ~doc:"assembler program to process" - and () = Err_handler.set_config () in + and () = Err_cli.set_config () in let p = Parsing_utils.parse_file_exn (module Visa_syntax) ~path in print_s [%sexp (p : Visa.Program.t)]) ;; @@ -32,7 +32,7 @@ let process_cmd = (Param.validated_string (module Fpath)) ~docv:"FILE" ~doc:"assembler program to process" - and () = Err_handler.set_config () in + and () = Err_cli.set_config () in let program = Parsing_utils.parse_file_exn (module Visa_syntax) ~path in let executable = Visa_assembler.program_to_executable ~program in let program = Visa.Executable.disassemble executable in @@ -48,7 +48,7 @@ let check_cmd = (Param.validated_string (module Fpath)) ~docv:"FILE" ~doc:"assembler program to process" - and () = Err_handler.set_config () in + and () = Err_cli.set_config () in let program = Parsing_utils.parse_file_exn (module Visa_syntax) ~path in let executable = Visa_assembler.program_to_executable ~program in let machine_code = Visa.Executable.to_machine_code executable in @@ -64,7 +64,7 @@ let assemble_cmd = (Param.validated_string (module Fpath)) ~docv:"FILE" ~doc:"assembler program to process" - and () = Err_handler.set_config () in + and () = Err_cli.set_config () in let program = Parsing_utils.parse_file_exn (module Visa_syntax) ~path in let executable = Visa_assembler.program_to_executable ~program in let machine_code = Visa.Executable.to_machine_code executable in @@ -81,7 +81,7 @@ let disassemble_cmd = (Param.validated_string (module Fpath)) ~docv:"FILE" ~doc:"machine code to process" - and () = Err_handler.set_config () in + and () = Err_cli.set_config () in let machine_code = Visa.Machine_code.of_text_file_exn ~path in let program = Visa.Executable.Machine_code.disassemble machine_code ~path in print_string (Pp_extended.to_string (Visa_pp.Program.pp program))) diff --git a/project/visa/lib/visa_dsl/src/dune b/project/visa/lib/visa_dsl/src/dune index 4d590407..47dff1ca 100644 --- a/project/visa/lib/visa_dsl/src/dune +++ b/project/visa/lib/visa_dsl/src/dune @@ -1,17 +1,8 @@ (library (name visa_dsl) (public_name bopkit.visa-dsl) - (flags - :standard - -w - +a-4-40-41-42-44-45-48-66 - -warn-error - +a - -open - Base - -open - Loc0) - (libraries base bit_utils loc0 parsing-utils pp visa visa_pp) + (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a -open Base) + (libraries base bit_utils loc parsing-utils pp visa visa_pp) (lint (pps ppx_js_style -check-doc-comments)) (preprocess @@ -26,4 +17,5 @@ ppx_sexp_value))) (mdx + (package bopkit-tests) (files :standard - *.mli)) diff --git a/project/visa/lib/visa_dsl/src/visa_dsl.ml b/project/visa/lib/visa_dsl/src/visa_dsl.ml index 46d8c237..8319d667 100644 --- a/project/visa/lib/visa_dsl/src/visa_dsl.ml +++ b/project/visa/lib/visa_dsl/src/visa_dsl.ml @@ -44,7 +44,7 @@ module O = struct Queue.enqueue t.program (Constant_definition - { constant_name = With_loc.with_dummy_pos constant_name + { constant_name = Loc.Txt.no_loc constant_name ; constant_kind = Address { address } }); Constant { constant_name } @@ -55,9 +55,7 @@ module O = struct Queue.enqueue t.program (Constant_definition - { constant_name = With_loc.with_dummy_pos constant_name - ; constant_kind = Value { value } - }); + { constant_name = Loc.Txt.no_loc constant_name; constant_kind = Value { value } }); Constant { constant_name } ;; @@ -139,7 +137,7 @@ module O = struct Queue.enqueue t.program (Macro_definition - { macro_name = With_loc.with_dummy_pos macro.macro_name + { macro_name = Loc.Txt.no_loc macro.macro_name ; parameters = Parameters.to_list macro.parameters ; body }) @@ -150,11 +148,10 @@ module O = struct t.program (Assembly_instruction { assembly_instruction = - { loc = Loc.dummy_pos + { loc = Loc.none ; operation_kind = Macro_call { macro_name = macro.macro_name } ; arguments = - Parameters.arguments macro.parameters input - |> List.map ~f:With_loc.with_dummy_pos + Parameters.arguments macro.parameters input |> List.map ~f:Loc.Txt.no_loc } }) ;; @@ -162,9 +159,7 @@ module O = struct let add_label (t : t) label = match (label : label) with | Label { label } -> - Queue.enqueue - t.program - (Label_introduction { label = With_loc.with_dummy_pos label }) + Queue.enqueue t.program (Label_introduction { label = Loc.Txt.no_loc label }) | _ -> raise_s [%sexp @@ -182,9 +177,9 @@ module O = struct t.program (Assembly_instruction { assembly_instruction = - { loc = Loc.dummy_pos + { loc = Loc.none ; operation_kind = Instruction { instruction_name } - ; arguments = List.map arguments ~f:(fun a -> With_loc.with_dummy_pos a) + ; arguments = List.map arguments ~f:(fun a -> Loc.Txt.no_loc a) } }) ;; diff --git a/project/visa/lib/visa_dsl/test/dune b/project/visa/lib/visa_dsl/test/dune index a93befb8..aeb8959c 100644 --- a/project/visa/lib/visa_dsl/test/dune +++ b/project/visa/lib/visa_dsl/test/dune @@ -10,15 +10,10 @@ -open Base -open - Err0 - -open - Err0_handler - -open Expect_test_helpers_base) (libraries base - err0 - err0-handler + err expect_test_helpers_core.expect_test_helpers_base parsing-utils pp diff --git a/project/visa/lib/visa_dsl/test/test__visa_dsl.ml b/project/visa/lib/visa_dsl/test/test__visa_dsl.ml index 58562047..d276857b 100644 --- a/project/visa/lib/visa_dsl/test/test__visa_dsl.ml +++ b/project/visa/lib/visa_dsl/test/test__visa_dsl.ml @@ -31,7 +31,7 @@ let%expect_test "loop pp" = let%expect_test "loop run" = let program = loop () in let config = Visa_simulator.Config.create ~sleep:false ~stop_after_n_outputs:20 () in - Err_handler.For_test.protect (fun () -> + Err.For_test.protect (fun () -> let visa_simulator = Visa_simulator.create ~config ~program in Visa_simulator.run visa_simulator |> Or_error.ok_exn); [%expect @@ -130,7 +130,7 @@ let%expect_test "minus" = write R1, 1 |}]; let run program = let config = Visa_simulator.Config.create ~sleep:false ~stop_after_n_outputs:2 () in - Err_handler.For_test.protect (fun () -> + Err.For_test.protect (fun () -> let visa_simulator = Visa_simulator.create ~config ~program in Visa_simulator.run visa_simulator |> Or_error.ok_exn) in @@ -144,7 +144,7 @@ let%expect_test "minus" = {| 0001000000000000000000000000000000000000000000000000000000000000 0001000000000001000000000000000000000000000000000000000000000000 |}]; - (Err_handler.For_test.protect + (Err.For_test.protect @@ fun () -> let executable_with_ocaml_macro = Visa_assembler.program_to_executable ~program:ocaml_macro diff --git a/project/visa/lib/visa_pp/src/program.ml b/project/visa/lib/visa_pp/src/program.ml index 7610b2fb..92f25860 100644 --- a/project/visa/lib/visa_pp/src/program.ml +++ b/project/visa/lib/visa_pp/src/program.ml @@ -10,7 +10,7 @@ let pp_top_level_construct ~(top_level_construct : Visa.Program.Top_level_constr | Constant_definition { constant_name; constant_kind } -> Pp.concat [ Pp.verbatim "define " - ; Pp.verbatim (Visa.Constant_name.to_string constant_name.symbol) + ; Pp.verbatim (Visa.Constant_name.to_string constant_name.txt) ; Pp.verbatim " " ; (match constant_kind with | Value { value } -> Pp.verbatim (sprintf "#%d" value) @@ -20,7 +20,7 @@ let pp_top_level_construct ~(top_level_construct : Visa.Program.Top_level_constr Pp.concat [ Pp.concat [ Pp.verbatim "macro " - ; Pp.verbatim (Visa.Macro_name.to_string macro_name.symbol) + ; Pp.verbatim (Visa.Macro_name.to_string macro_name.txt) ; (if List.is_empty parameters then Pp.nop else Pp.verbatim " ") ; Pp.concat ~sep:(Pp.verbatim ", ") @@ -37,7 +37,7 @@ let pp_top_level_construct ~(top_level_construct : Visa.Program.Top_level_constr ; Pp.verbatim "end" ] | Label_introduction { label } -> - Pp.concat [ Pp.verbatim (Visa.Label.to_string label.symbol); Pp.verbatim ":" ] + Pp.concat [ Pp.verbatim (Visa.Label.to_string label.txt); Pp.verbatim ":" ] | Assembly_instruction { assembly_instruction } -> Pp.verbatim (Visa.Assembly_instruction.to_string assembly_instruction) ;; diff --git a/project/visa/lib/visa_simulator/src/code.ml b/project/visa/lib/visa_simulator/src/code.ml index 2bb4dd78..b30805e3 100644 --- a/project/visa/lib/visa_simulator/src/code.ml +++ b/project/visa/lib/visa_simulator/src/code.ml @@ -2,7 +2,7 @@ open! Or_error.Let_syntax module Statement = struct type t = - { labels : Visa.Label.t With_loc.t list + { labels : Visa.Label.t Loc.Txt.t list ; assembly_instruction : Visa.Assembly_instruction.t } [@@deriving sexp_of] @@ -30,7 +30,7 @@ let of_assembly_constructs let mapping = Hashtbl.create (module Visa.Label) in Array.iteri statements ~f:(fun index statement -> List.iter statement.labels ~f:(fun label -> - Hashtbl.set mapping ~key:label.symbol ~data:index)); + Hashtbl.set mapping ~key:label.txt ~data:index)); mapping |> Hashtbl.to_alist |> Map.of_alist_exn (module Visa.Label) in { statements; labels_resolution } diff --git a/project/visa/lib/visa_simulator/src/code.mli b/project/visa/lib/visa_simulator/src/code.mli index 3cac4151..df2663fe 100644 --- a/project/visa/lib/visa_simulator/src/code.mli +++ b/project/visa/lib/visa_simulator/src/code.mli @@ -1,6 +1,6 @@ module Statement : sig type t = private - { labels : Visa.Label.t With_loc.t list + { labels : Visa.Label.t Loc.Txt.t list ; assembly_instruction : Visa.Assembly_instruction.t } [@@deriving sexp_of] diff --git a/project/visa/lib/visa_simulator/src/dune b/project/visa/lib/visa_simulator/src/dune index fedf4c8b..a87b49d8 100644 --- a/project/visa/lib/visa_simulator/src/dune +++ b/project/visa/lib/visa_simulator/src/dune @@ -10,30 +10,24 @@ -open Base -open - Loc0 - -open - Err0 - -open - Err0_handler - -open Fpath_base -open Stdio -open - Commandlang) + Cmdlang) (libraries base bit_utils - commandlang + cmdlang core core_unix core_unix.core_thread core_unix.sys_unix - err0 - err0-handler + err + err-cli fpath fpath-base - loc0 + loc stdio visa visa_assembler diff --git a/project/visa/lib/visa_simulator/src/execution_stack.ml b/project/visa/lib/visa_simulator/src/execution_stack.ml index 2ec214ce..fdfdf789 100644 --- a/project/visa/lib/visa_simulator/src/execution_stack.ml +++ b/project/visa/lib/visa_simulator/src/execution_stack.ml @@ -1,8 +1,8 @@ module Macro_frame = struct type t = - { macro_name : Visa.Macro_name.t With_loc.t + { macro_name : Visa.Macro_name.t Loc.Txt.t ; bindings : - (Visa.Parameter_name.t * Visa.Assembly_instruction.Argument.t With_loc.t) list + (Visa.Parameter_name.t * Visa.Assembly_instruction.Argument.t Loc.Txt.t) list ; assembly_instructions : Visa.Assembly_instruction.t array ; mutable macro_code_pointer : int } diff --git a/project/visa/lib/visa_simulator/src/execution_stack.mli b/project/visa/lib/visa_simulator/src/execution_stack.mli index 9ac86177..d4b33a1b 100644 --- a/project/visa/lib/visa_simulator/src/execution_stack.mli +++ b/project/visa/lib/visa_simulator/src/execution_stack.mli @@ -1,8 +1,8 @@ module Macro_frame : sig type t = - { macro_name : Visa.Macro_name.t With_loc.t + { macro_name : Visa.Macro_name.t Loc.Txt.t ; bindings : - (Visa.Parameter_name.t * Visa.Assembly_instruction.Argument.t With_loc.t) list + (Visa.Parameter_name.t * Visa.Assembly_instruction.Argument.t Loc.Txt.t) list ; assembly_instructions : Visa.Assembly_instruction.t array ; mutable macro_code_pointer : int } diff --git a/project/visa/lib/visa_simulator/src/visa_simulator.ml b/project/visa/lib/visa_simulator/src/visa_simulator.ml index cca6680e..94566d4a 100644 --- a/project/visa/lib/visa_simulator/src/visa_simulator.ml +++ b/project/visa/lib/visa_simulator/src/visa_simulator.ml @@ -52,7 +52,7 @@ type t = let create ~(config : Config.t) ~program = let environment, assembly_constructs = Visa_assembler.build_environment ~program in - let () = if Err.State.had_errors Err.the_state then Err.exit Some_error in + let () = if Err.had_errors () then Err.exit Err.Exit_code.some_error in let code = Code.of_assembly_constructs ~assembly_constructs in let execution_stack = Execution_stack.create () in let memory = Memory.create () in @@ -144,7 +144,7 @@ let execute_instruction t ~instruction = module Step_result = struct type t = - | Macro_call of { macro_name : Visa.Macro_name.t With_loc.t } + | Macro_call of { macro_name : Visa.Macro_name.t Loc.Txt.t } | Executed of { instruction : Visa.Label.t Visa.Instruction.t ; continue : bool @@ -197,7 +197,7 @@ let step (t : t) = Or_error.error_s [%sexp "Invalid number of macro arguments" - , { macro_name : Visa.Macro_name.t With_loc.t + , { macro_name : Visa.Macro_name.t Loc.Txt.t ; expected = (List.length parameters : int) ; applied_to = (List.length arguments : int) }] @@ -264,7 +264,7 @@ let main = (Param.validated_string (module Fpath)) ~docv:"FILE" ~doc:"assembler program to execute" - and () = Err_handler.set_config () + and () = Err_cli.set_config () and config = Config.arg in let program = Parsing_utils.parse_file_exn (module Visa_syntax) ~path in let visa_simulator = create ~config ~program in diff --git a/project/visa/lib/visa_simulator/src/visa_simulator.mli b/project/visa/lib/visa_simulator/src/visa_simulator.mli index 140ded27..fadeef29 100644 --- a/project/visa/lib/visa_simulator/src/visa_simulator.mli +++ b/project/visa/lib/visa_simulator/src/visa_simulator.mli @@ -38,7 +38,7 @@ val create : config:Config.t -> program:Visa.Program.t -> t module Step_result : sig type t = - | Macro_call of { macro_name : Visa.Macro_name.t With_loc.t } + | Macro_call of { macro_name : Visa.Macro_name.t Loc.Txt.t } | Executed of { instruction : Visa.Label.t Visa.Instruction.t ; continue : bool diff --git a/project/visa/lib/visa_syntax/src/dune b/project/visa/lib/visa_syntax/src/dune index 638260b1..3121a312 100644 --- a/project/visa/lib/visa_syntax/src/dune +++ b/project/visa/lib/visa_syntax/src/dune @@ -6,5 +6,5 @@ (library (name visa_syntax) (public_name bopkit.visa-syntax) - (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a -open Loc0) - (libraries loc0 parsing-utils visa)) + (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a) + (libraries loc parsing-utils visa)) diff --git a/project/visa/lib/visa_syntax/src/parser.mly b/project/visa/lib/visa_syntax/src/parser.mly index fbccc2e3..fbf7ceae 100644 --- a/project/visa/lib/visa_syntax/src/parser.mly +++ b/project/visa/lib/visa_syntax/src/parser.mly @@ -56,7 +56,7 @@ top_level_construct : | label=INT COLON { Visa.Program.Top_level_construct.Label_introduction { label = - With_loc.create $loc + Loc.Txt.create $loc (Visa.Label.of_string label) } } @@ -67,14 +67,14 @@ top_level_construct : macro_name: | macro_name=IDENT - { With_loc.create $loc + { Loc.Txt.create $loc (Visa.Macro_name.of_string macro_name) } ; constant_name: | constant_name=IDENT - { With_loc.create $loc + { Loc.Txt.create $loc (Visa.Constant_name.of_string constant_name) } ; @@ -115,7 +115,7 @@ arguments : ; argument: - | argument_kind=argument_kind { With_loc.create $loc argument_kind } + | argument_kind=argument_kind { Loc.Txt.create $loc argument_kind } ; argument_kind : diff --git a/project/visa/test/assembler/error/dune b/project/visa/test/assembler/error/dune index c13c668f..693c900c 100644 --- a/project/visa/test/assembler/error/dune +++ b/project/visa/test/assembler/error/dune @@ -14,6 +14,7 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (package bopkit) %{bin:visa} diff --git a/project/visa/test/assembler/syntax/dune b/project/visa/test/assembler/syntax/dune index 8e8f1ccd..f0ef0f32 100644 --- a/project/visa/test/assembler/syntax/dune +++ b/project/visa/test/assembler/syntax/dune @@ -1,4 +1,5 @@ (cram + (package bopkit-tests) (deps (package bopkit) %{bin:visa} diff --git a/project/visa/test/assembler/syntax/run.t b/project/visa/test/assembler/syntax/run.t index f8edb36b..65a94a0e 100644 --- a/project/visa/test/assembler/syntax/run.t +++ b/project/visa/test/assembler/syntax/run.t @@ -4,11 +4,20 @@ monitor in tests. $ visa fmt test ================================: comments-at-end-of-line.asm - File "comments-at-end-of-line.asm", line 2, characters 14-14: syntax error. + File "comments-at-end-of-line.asm", line 2, characters 14-37: + 2 | define var 42 // But not after a line + ^^^^^^^^^^^^^^^^^^^^^^^ + Error: syntax error. ================================: comments-in-macro.asm - File "comments-in-macro.asm", line 4, characters 2-2: syntax error. + File "comments-in-macro.asm", line 4, characters 2-54: + 4 | // At the moment comments in macro are not supported + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Error: syntax error. ================================: label-in-macro.asm - File "label-in-macro.asm", line 5, characters 7-7: syntax error. + File "label-in-macro.asm", line 5, characters 7-8: + 5 | LABEL: sleep + ^ + Error: syntax error. ================================: multiple-empty-lines.asm // Comments in their own lines are supported define var 42 diff --git a/project/visa/test/disassembler/check/dune b/project/visa/test/disassembler/check/dune index 0cf24fa5..7fe2e1a0 100644 --- a/project/visa/test/disassembler/check/dune +++ b/project/visa/test/disassembler/check/dune @@ -1,4 +1,5 @@ (cram + (package bopkit-tests) (deps (package bopkit) %{bin:visa} diff --git a/project/visa/test/disassembler/error/dune b/project/visa/test/disassembler/error/dune index 0cf24fa5..7fe2e1a0 100644 --- a/project/visa/test/disassembler/error/dune +++ b/project/visa/test/disassembler/error/dune @@ -1,4 +1,5 @@ (cram + (package bopkit-tests) (deps (package bopkit) %{bin:visa} diff --git a/project/visa/test/disassembler/error/invalid-code.t b/project/visa/test/disassembler/error/invalid-code.t index 9eaaabe7..d4f1ba98 100644 --- a/project/visa/test/disassembler/error/invalid-code.t +++ b/project/visa/test/disassembler/error/invalid-code.t @@ -1,4 +1,6 @@ $ visa disassemble invalid-code.bin - File "invalid-code.bin", line 1, characters 0-0: + File "invalid-code.bin", line 1, characters 0-8: + 1 | 10111000 + ^^^^^^^^ Error: Invalid byte code '10111000'. [123] diff --git a/project/visa/test/disassembler/error/missing-byte.t b/project/visa/test/disassembler/error/missing-byte.t index c68a4066..70279ed9 100644 --- a/project/visa/test/disassembler/error/missing-byte.t +++ b/project/visa/test/disassembler/error/missing-byte.t @@ -3,7 +3,9 @@ an instruction that expects to be encoded on 2 bytes not to followed by its second part. $ visa disassemble missing-byte.bin - File "missing-byte.bin", line 1, characters 0-0: + File "missing-byte.bin", line 1, characters 0-8: + 1 | 00010000 + ^^^^^^^^ Error: Invalid executable. Operation 'Jmp' is expected to be followed by another byte. [123] diff --git a/project/visa/test/runtime/dune b/project/visa/test/runtime/dune index 5f71f4d1..c5012605 100644 --- a/project/visa/test/runtime/dune +++ b/project/visa/test/runtime/dune @@ -17,6 +17,7 @@ (copy ../../circuit/visa.bop visa.bop)) (cram + (package bopkit-tests) (deps (package bopkit) (glob_files *.txt) @@ -25,6 +26,7 @@ (glob_files *.bop))) (mdx + (package bopkit-tests) (deps (package bopkit) get_date.exe diff --git a/stdlib/7-segment/bin/digital_calendar.ml b/stdlib/7-segment/bin/digital_calendar.ml index 62592944..d1c61ef6 100644 --- a/stdlib/7-segment/bin/digital_calendar.ml +++ b/stdlib/7-segment/bin/digital_calendar.ml @@ -1,5 +1,5 @@ let () = - Commandlang_to_cmdliner.run + Cmdlang_to_cmdliner.run Seven_segment_display.Main.digital_calendar ~name:"bopkit" ~version:"%%VERSION%%" diff --git a/stdlib/7-segment/bin/digital_calendar_display.ml b/stdlib/7-segment/bin/digital_calendar_display.ml index 2803ff6d..5206fbdf 100644 --- a/stdlib/7-segment/bin/digital_calendar_display.ml +++ b/stdlib/7-segment/bin/digital_calendar_display.ml @@ -1,5 +1,5 @@ let () = - Commandlang_to_cmdliner.run + Cmdlang_to_cmdliner.run Seven_segment_display.digital_calendar_display ~name:"digital_calendar_display" ~version:"%%VERSION%%" diff --git a/stdlib/7-segment/bin/digital_watch.ml b/stdlib/7-segment/bin/digital_watch.ml index 6e807702..cc08eca9 100644 --- a/stdlib/7-segment/bin/digital_watch.ml +++ b/stdlib/7-segment/bin/digital_watch.ml @@ -1,5 +1,5 @@ let () = - Commandlang_to_cmdliner.run + Cmdlang_to_cmdliner.run Seven_segment_display.Main.digital_watch ~name:"digital_watch" ~version:"%%VERSION%%" diff --git a/stdlib/7-segment/bin/digital_watch_display.ml b/stdlib/7-segment/bin/digital_watch_display.ml index 37194941..65fe998a 100644 --- a/stdlib/7-segment/bin/digital_watch_display.ml +++ b/stdlib/7-segment/bin/digital_watch_display.ml @@ -1,5 +1,5 @@ let () = - Commandlang_to_cmdliner.run + Cmdlang_to_cmdliner.run Seven_segment_display.digital_watch_display ~name:"digital_watch_display" ~version:"%%VERSION%%" diff --git a/stdlib/7-segment/bin/dune b/stdlib/7-segment/bin/dune index 0ed09178..b3f7ae1c 100644 --- a/stdlib/7-segment/bin/dune +++ b/stdlib/7-segment/bin/dune @@ -5,7 +5,7 @@ digital_calendar digital_calendar_display) (flags -w +a-40-42-44-66 -warn-error +a) - (libraries base commandlang-to-cmdliner seven_segment_display) + (libraries base cmdlang-to-cmdliner seven_segment_display) (preprocess (pps ppx_compare diff --git a/stdlib/7-segment/dune b/stdlib/7-segment/dune index 000ddd9c..3f264ac2 100644 --- a/stdlib/7-segment/dune +++ b/stdlib/7-segment/dune @@ -21,11 +21,13 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) (mdx + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) diff --git a/stdlib/7-segment/src/dune b/stdlib/7-segment/src/dune index 6eea5f1b..e409022c 100644 --- a/stdlib/7-segment/src/dune +++ b/stdlib/7-segment/src/dune @@ -12,12 +12,12 @@ -open Stdio -open - Commandlang) + Cmdlang) (libraries ANSITerminal base bit_utils - commandlang + cmdlang core core_unix core_unix.core_thread diff --git a/stdlib/bopboard/bin/dune b/stdlib/bopboard/bin/dune index ffebbd14..8b4fe6ed 100644 --- a/stdlib/bopboard/bin/dune +++ b/stdlib/bopboard/bin/dune @@ -1,7 +1,7 @@ (executables (names main) (flags -w +a-40-42-44-66 -warn-error +a) - (libraries bopboard cmdliner commandlang-to-cmdliner)) + (libraries bopboard cmdliner cmdlang-to-cmdliner)) (install (package bopkit) diff --git a/stdlib/bopboard/bin/main.ml b/stdlib/bopboard/bin/main.ml index 64941a50..15ae653f 100644 --- a/stdlib/bopboard/bin/main.ml +++ b/stdlib/bopboard/bin/main.ml @@ -1 +1 @@ -let () = Commandlang_to_cmdliner.run Bopboard.main ~name:"bopboard" ~version:"%%VERSION%%" +let () = Cmdlang_to_cmdliner.run Bopboard.main ~name:"bopboard" ~version:"%%VERSION%%" diff --git a/stdlib/bopboard/example/dune b/stdlib/bopboard/example/dune index f9a8a4c5..9108cc23 100644 --- a/stdlib/bopboard/example/dune +++ b/stdlib/bopboard/example/dune @@ -14,11 +14,13 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) (mdx + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) diff --git a/stdlib/bopboard/images/dune b/stdlib/bopboard/images/dune index b9b86c27..f82a4d22 100644 --- a/stdlib/bopboard/images/dune +++ b/stdlib/bopboard/images/dune @@ -20,6 +20,7 @@ (copy ../bin/main.exe bopboard)) (cram + (package bopkit-tests) (deps (package bopkit) bopboard diff --git a/stdlib/bopboard/src/dune b/stdlib/bopboard/src/dune index 20887ba8..5f1c0142 100644 --- a/stdlib/bopboard/src/dune +++ b/stdlib/bopboard/src/dune @@ -12,12 +12,12 @@ -open Stdio -open - Commandlang) + Cmdlang) (libraries base bopkit_block bopkit_sites - commandlang + cmdlang core core_unix.core_thread core_unix.sys_unix diff --git a/stdlib/counter/bin/counter.ml b/stdlib/counter/bin/counter.ml index b77128fe..3a33633e 100644 --- a/stdlib/counter/bin/counter.ml +++ b/stdlib/counter/bin/counter.ml @@ -1,5 +1,5 @@ let () = - Commandlang_to_cmdliner.run + Cmdlang_to_cmdliner.run Bopkit_counter.Counter.main ~name:"counter" ~version:"%%VERSION%%" diff --git a/stdlib/counter/bin/dune b/stdlib/counter/bin/dune index b0da293a..2b76d14d 100644 --- a/stdlib/counter/bin/dune +++ b/stdlib/counter/bin/dune @@ -1,6 +1,6 @@ (executables (names counter) - (libraries bopkit_counter cmdliner commandlang-to-cmdliner)) + (libraries bopkit_counter cmdliner cmdlang-to-cmdliner)) (install (package bopkit) diff --git a/stdlib/counter/dune b/stdlib/counter/dune index 6989269e..3f8f8ca1 100644 --- a/stdlib/counter/dune +++ b/stdlib/counter/dune @@ -14,6 +14,7 @@ (run dune format-dune-file))))) (mdx + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) diff --git a/stdlib/counter/src/dune b/stdlib/counter/src/dune index c32ebe25..d2ef2fd8 100644 --- a/stdlib/counter/src/dune +++ b/stdlib/counter/src/dune @@ -12,7 +12,7 @@ -open Stdio -open - Commandlang) + Cmdlang) (libraries bopkit_block bopkit_sleeper core graphics threads unix) (lint (pps ppx_js_style -check-doc-comments)) diff --git a/stdlib/counter/test/dune b/stdlib/counter/test/dune index 85e22c0c..839c576a 100644 --- a/stdlib/counter/test/dune +++ b/stdlib/counter/test/dune @@ -1,4 +1,5 @@ (cram + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) diff --git a/stdlib/memories/bin/dune b/stdlib/memories/bin/dune index 49880007..a7658417 100644 --- a/stdlib/memories/bin/dune +++ b/stdlib/memories/bin/dune @@ -10,10 +10,10 @@ -open Stdio -open - Commandlang) + Cmdlang) (libraries base - commandlang + cmdlang core core_unix.core_thread bopkit_block diff --git a/stdlib/pulse/bin/dune b/stdlib/pulse/bin/dune index 7ca3d853..1ce3dc7b 100644 --- a/stdlib/pulse/bin/dune +++ b/stdlib/pulse/bin/dune @@ -1,6 +1,6 @@ (executables (names pulse) - (libraries bopkit_pulse cmdliner commandlang-to-cmdliner)) + (libraries bopkit_pulse cmdliner cmdlang-to-cmdliner)) (install (package bopkit) diff --git a/stdlib/pulse/bin/pulse.ml b/stdlib/pulse/bin/pulse.ml index 36fa55fb..bd10237f 100644 --- a/stdlib/pulse/bin/pulse.ml +++ b/stdlib/pulse/bin/pulse.ml @@ -1,3 +1,3 @@ let () = - Commandlang_to_cmdliner.run Bopkit_pulse.Pulse.main ~name:"pulse" ~version:"%%VERSION%%" + Cmdlang_to_cmdliner.run Bopkit_pulse.Pulse.main ~name:"pulse" ~version:"%%VERSION%%" ;; diff --git a/stdlib/pulse/dune b/stdlib/pulse/dune index 0aa1ca34..b2298a21 100644 --- a/stdlib/pulse/dune +++ b/stdlib/pulse/dune @@ -21,11 +21,13 @@ (files pulse.bop)) (cram + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) (mdx + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) diff --git a/stdlib/pulse/src/dune b/stdlib/pulse/src/dune index ee268e93..25f41dfa 100644 --- a/stdlib/pulse/src/dune +++ b/stdlib/pulse/src/dune @@ -12,8 +12,8 @@ -open Stdio -open - Commandlang) - (libraries base bopkit_block bopkit_sleeper commandlang core unix) + Cmdlang) + (libraries base bopkit_block bopkit_sleeper cmdlang core unix) (lint (pps ppx_js_style -check-doc-comments)) (preprocess diff --git a/stdlib/pulse/test/dune b/stdlib/pulse/test/dune index 85e22c0c..839c576a 100644 --- a/stdlib/pulse/test/dune +++ b/stdlib/pulse/test/dune @@ -1,4 +1,5 @@ (cram + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) diff --git a/stdlib/stdlib/dune b/stdlib/stdlib/dune index 72187f68..12b2656d 100644 --- a/stdlib/stdlib/dune +++ b/stdlib/stdlib/dune @@ -21,11 +21,13 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) (mdx + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) diff --git a/stdlib/stdlib/test/dune b/stdlib/stdlib/test/dune index 62e9e8ba..1c629736 100644 --- a/stdlib/stdlib/test/dune +++ b/stdlib/stdlib/test/dune @@ -14,6 +14,7 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) diff --git a/subleq.opam b/subleq.opam index d3737e75..584a58e9 100644 --- a/subleq.opam +++ b/subleq.opam @@ -12,25 +12,25 @@ depends: [ "ocaml" {>= "5.2"} "ANSITerminal" {>= "0.8.3"} "appendable-list" {>= "v0.17" & < "v0.18"} - "auto-format" {>= "0.0.11"} + "auto-format" {>= "0.0.12"} "base" {>= "v0.17" & < "v0.18"} "base_quickcheck" {>= "v0.17" & < "v0.18"} "bopkit" {= version} + "cmdlang" {>= "0.0.4"} + "cmdlang-to-cmdliner" {>= "0.0.4"} "cmdliner" {= "1.3.0"} - "commandlang" {>= "0.0.2"} - "commandlang-to-cmdliner" {>= "0.0.2"} "core" {>= "v0.17" & < "v0.18"} "core_unix" {>= "v0.17" & < "v0.18"} "dune-site" {>= "3.16"} - "err0" {>= "0.0.2"} - "err0-handler" {>= "0.0.2"} + "err" {>= "0.0.4"} + "err-cli" {>= "0.0.4"} "fpath" {>= "0.7.3"} - "fpath-base" {>= "0.0.9"} + "fpath-base" {>= "0.2.0"} "graphics" {>= "5.1.2"} - "loc0" {>= "0.1.0"} + "loc" {>= "0.2.0"} "mdx" {>= "2.4"} "menhir" {>= "20220210"} - "parsing-utils" {>= "0.0.8"} + "parsing-utils" {>= "0.2.0"} "pp" {>= "1.2.0"} "pp-extended" {>= "0.0.2"} "ppx_compare" {>= "v0.17" & < "v0.18"} @@ -38,7 +38,6 @@ depends: [ "ppx_fields_conv" {>= "v0.17" & < "v0.18"} "ppx_hash" {>= "v0.17" & < "v0.18"} "ppx_here" {>= "v0.17" & < "v0.18"} - "ppx_js_style" {dev & >= "v0.17" & < "v0.18"} "ppx_let" {>= "v0.17" & < "v0.18"} "ppx_sexp_conv" {>= "v0.17" & < "v0.18"} "ppx_sexp_value" {>= "v0.17" & < "v0.18"} diff --git a/test/bdd/dune b/test/bdd/dune index 4dac122d..d6880e0a 100644 --- a/test/bdd/dune +++ b/test/bdd/dune @@ -1,6 +1,7 @@ (include dune.inc) (cram + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop) diff --git a/test/bop2c/dune b/test/bop2c/dune index 247be855..37a64907 100644 --- a/test/bop2c/dune +++ b/test/bop2c/dune @@ -32,6 +32,7 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (package bopkit) %{bin:bopkit} diff --git a/test/bop2c/gen-dune/dune b/test/bop2c/gen-dune/dune index 904f31f5..452a6d19 100644 --- a/test/bop2c/gen-dune/dune +++ b/test/bop2c/gen-dune/dune @@ -9,13 +9,13 @@ -open Base -open - Commandlang) + Cmdlang) (libraries auto-format base + cmdlang + cmdlang-to-cmdliner cmdliner - commandlang - commandlang-to-cmdliner eio eio_main parsing-utils) diff --git a/test/bop2c/gen-dune/main.ml b/test/bop2c/gen-dune/main.ml index 41282454..c6b89669 100644 --- a/test/bop2c/gen-dune/main.ml +++ b/test/bop2c/gen-dune/main.ml @@ -73,4 +73,4 @@ let gen_dune_cmd = Stdlib.print_endline (Sexp.to_string_hum sexp)))) ;; -let () = Commandlang_to_cmdliner.run gen_dune_cmd ~name:"gen-dune" ~version:"%%VERSION%%" +let () = Cmdlang_to_cmdliner.run gen_dune_cmd ~name:"gen-dune" ~version:"%%VERSION%%" diff --git a/test/netlist/check/dune b/test/netlist/check/dune index ab905d37..960e8245 100644 --- a/test/netlist/check/dune +++ b/test/netlist/check/dune @@ -14,6 +14,7 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (package bopkit) %{bin:bopkit} diff --git a/test/netlist/error/dune b/test/netlist/error/dune index ab905d37..960e8245 100644 --- a/test/netlist/error/dune +++ b/test/netlist/error/dune @@ -14,6 +14,7 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (package bopkit) %{bin:bopkit} diff --git a/test/netlist/runtime/dune b/test/netlist/runtime/dune index ab905d37..960e8245 100644 --- a/test/netlist/runtime/dune +++ b/test/netlist/runtime/dune @@ -14,6 +14,7 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (package bopkit) %{bin:bopkit} diff --git a/test/netlist/syntax/dune b/test/netlist/syntax/dune index 780651e7..7772fd5e 100644 --- a/test/netlist/syntax/dune +++ b/test/netlist/syntax/dune @@ -1,4 +1,5 @@ (cram + (package bopkit-tests) (deps (package bopkit) %{bin:bopkit} diff --git a/test/netlist/syntax/run.t b/test/netlist/syntax/run.t index 129f72e7..f603d3bd 100644 --- a/test/netlist/syntax/run.t +++ b/test/netlist/syntax/run.t @@ -132,7 +132,10 @@ monitor in tests. where end where; ================================: external-arity.bop - File "external-arity.bop", line 8, characters 16-16: syntax error. + File "external-arity.bop", line 8, characters 16-17: + 8 | out = $cal.add[2](a, b); + ^ + Error: syntax error. ================================: external-call.bop #define N 4 @@ -209,7 +212,10 @@ monitor in tests. s = FoldLeft[N]<"And", "Map", "Id">(a:[N]); end where; ================================: include-dash-file.bop - File "include-dash-file.bop", line 2, characters 16-16: syntax error. + File "include-dash-file.bop", line 2, characters 16-17: + 2 | #include + ^ + Error: syntax error. ================================: include.bop #include "user-file.bop" #include @@ -296,7 +302,10 @@ monitor in tests. Gnd())))); end where; ================================: pipe-arity.bop - File "pipe-arity.bop", line 5, characters 12-12: syntax error. + File "pipe-arity.bop", line 5, characters 12-13: + 5 | out = pipe[2]("./external.exe", f); + ^ + Error: syntax error. ================================: pipe.bop A(a, b) = out where diff --git a/test/process/error/dune b/test/process/error/dune index e7beb85b..c249a2e7 100644 --- a/test/process/error/dune +++ b/test/process/error/dune @@ -22,6 +22,7 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (package bopkit) %{bin:bopkit} diff --git a/test/process/runtime/dune b/test/process/runtime/dune index e7beb85b..c249a2e7 100644 --- a/test/process/runtime/dune +++ b/test/process/runtime/dune @@ -22,6 +22,7 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (package bopkit) %{bin:bopkit} diff --git a/test/process/syntax/dune b/test/process/syntax/dune index 15f75b07..959901c8 100644 --- a/test/process/syntax/dune +++ b/test/process/syntax/dune @@ -1,4 +1,5 @@ (cram + (package bopkit-tests) (deps (package bopkit) %{bin:bopkit} diff --git a/test/process/syntax/run.t b/test/process/syntax/run.t index 93bb3fca..9bdc8cd6 100644 --- a/test/process/syntax/run.t +++ b/test/process/syntax/run.t @@ -26,6 +26,12 @@ monitor in tests. // This is comment G // This is comment H ================================: invalid-comment.bpp - File "invalid-comment.bpp", line 5, characters 0-0: syntax error. + File "invalid-comment.bpp", line 5, characters 0-6: + 5 | output t // Here is fine though + ^^^^^^ + Error: syntax error. ================================: syntax-error.bpp - File "syntax-error.bpp", line 5, characters 10-10: syntax error. + File "syntax-error.bpp", line 5, characters 10-15: + 5 | p = q - 4 ERROR + ^^^^^ + Error: syntax error. diff --git a/tutorial/bdd/division/dune b/tutorial/bdd/division/dune index 2125617f..13e4ff4a 100644 --- a/tutorial/bdd/division/dune +++ b/tutorial/bdd/division/dune @@ -33,8 +33,8 @@ -open Stdio -open - Commandlang) - (libraries base commandlang bopkit_block core graphics stdio unix threads) + Cmdlang) + (libraries base cmdlang bopkit_block core graphics stdio unix threads) (preprocess (pps ppx_compare @@ -125,6 +125,7 @@ (diff div_check.output div_check.output.corrected))) (cram + (package bopkit-tests) (deps (package bopkit) div.exe @@ -133,6 +134,7 @@ (glob_files *.txt))) (mdx + (package bopkit-tests) (deps (package bopkit) div.exe diff --git a/tutorial/bdd/dune b/tutorial/bdd/dune index 86e6575f..f6202a0e 100644 --- a/tutorial/bdd/dune +++ b/tutorial/bdd/dune @@ -81,12 +81,14 @@ (run %{bin:bopkit} simu %{dep:check_starred.bop} -n 1024)))) (cram + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop) (glob_files *.txt))) (mdx + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop) diff --git a/tutorial/functional-args/dune b/tutorial/functional-args/dune index 57d4efdc..4f5ecc05 100644 --- a/tutorial/functional-args/dune +++ b/tutorial/functional-args/dune @@ -14,6 +14,7 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (package bopkit) argsfcts.bop)) diff --git a/tutorial/hello-world/dune b/tutorial/hello-world/dune index 68aa4880..069e9081 100644 --- a/tutorial/hello-world/dune +++ b/tutorial/hello-world/dune @@ -1,4 +1,5 @@ (cram + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) @@ -19,6 +20,7 @@ (run dune format-dune-file))))) (mdx + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) diff --git a/tutorial/misc/dune b/tutorial/misc/dune index 9fb993c4..662d503a 100644 --- a/tutorial/misc/dune +++ b/tutorial/misc/dune @@ -14,10 +14,12 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (glob_files *.bop) (package bopkit))) (mdx + (package bopkit-tests) (deps (package bopkit))) diff --git a/tutorial/parametrized-blocks/dune b/tutorial/parametrized-blocks/dune index 62e9e8ba..1c629736 100644 --- a/tutorial/parametrized-blocks/dune +++ b/tutorial/parametrized-blocks/dune @@ -14,6 +14,7 @@ (run dune format-dune-file))))) (cram + (package bopkit-tests) (deps (package bopkit) (glob_files *.bop))) diff --git a/visa.opam b/visa.opam index d985eab5..47c03e75 100644 --- a/visa.opam +++ b/visa.opam @@ -12,25 +12,25 @@ depends: [ "ocaml" {>= "5.2"} "ANSITerminal" {>= "0.8.3"} "appendable-list" {>= "v0.17" & < "v0.18"} - "auto-format" {>= "0.0.11"} + "auto-format" {>= "0.0.12"} "base" {>= "v0.17" & < "v0.18"} "base_quickcheck" {>= "v0.17" & < "v0.18"} "bopkit" {= version} + "cmdlang" {>= "0.0.4"} + "cmdlang-to-cmdliner" {>= "0.0.4"} "cmdliner" {= "1.3.0"} - "commandlang" {>= "0.0.2"} - "commandlang-to-cmdliner" {>= "0.0.2"} "core" {>= "v0.17" & < "v0.18"} "core_unix" {>= "v0.17" & < "v0.18"} "dune-site" {>= "3.16"} - "err0" {>= "0.0.2"} - "err0-handler" {>= "0.0.2"} + "err" {>= "0.0.4"} + "err-cli" {>= "0.0.4"} "fpath" {>= "0.7.3"} - "fpath-base" {>= "0.0.9"} + "fpath-base" {>= "0.2.0"} "graphics" {>= "5.1.2"} - "loc0" {>= "0.1.0"} + "loc" {>= "0.2.0"} "mdx" {>= "2.4"} "menhir" {>= "20220210"} - "parsing-utils" {>= "0.0.8"} + "parsing-utils" {>= "0.2.0"} "pp" {>= "1.2.0"} "pp-extended" {>= "0.0.2"} "ppx_compare" {>= "v0.17" & < "v0.18"} @@ -38,7 +38,6 @@ depends: [ "ppx_fields_conv" {>= "v0.17" & < "v0.18"} "ppx_hash" {>= "v0.17" & < "v0.18"} "ppx_here" {>= "v0.17" & < "v0.18"} - "ppx_js_style" {dev & >= "v0.17" & < "v0.18"} "ppx_let" {>= "v0.17" & < "v0.18"} "ppx_sexp_conv" {>= "v0.17" & < "v0.18"} "ppx_sexp_value" {>= "v0.17" & < "v0.18"}