Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[all] Ocamlformat pre-commit hook #785

Merged
merged 6 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/check-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Check format with `dune fmt`

on:
pull_request:
# push:
workflow_dispatch:
schedule:
# Prime the caches every Monday
- cron: 0 1 * * MON

permissions: read-all

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout tree
uses: actions/checkout@v4

- name: Set-up OCaml
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 5.1

- run: opam install dune ocamlformat

- run: opam exec -- dune fmt
2 changes: 2 additions & 0 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = 0.26.1
disable = true
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ repos:
# Expected files should be left verbatim.
\.expected(-failure)?$
)
- repo: https://github.com/arenadotio/pre-commit-ocamlformat
HadrienRenaud marked this conversation as resolved.
Show resolved Hide resolved
rev: 0439858f79b3bcb49e757278eb1312e212d7dd4f
hooks:
- id: ocamlformat
types: [ocaml]

- repo: local
hooks:
Expand Down
1 change: 1 addition & 0 deletions asllib/.ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
disable = false
23 changes: 9 additions & 14 deletions asllib/Interpreter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ module Make (B : Backend.S) (C : Config) = struct
| None, Some t -> base_value env t
in
let* () =
(*
* Those identifiers are initialised to their current value
* before executing each instruction. Hence, we discard
* the initial values from `.asl` files.
*)
(*
* Those identifiers are initialised to their current value
* before executing each instruction. Hence, we discard
* the initial values from `.asl` files.
*)
match name with
| "RESADDR" | "_NZCV" -> return ()
| _ -> B.on_write_identifier name Scope_Global v
Expand All @@ -213,8 +213,7 @@ module Make (B : Backend.S) (C : Config) = struct
in
let fold = function
| TopoSort.ASTFold.Single d -> process_one_decl d
| TopoSort.ASTFold.Recursive ds ->
List.fold_right process_one_decl ds
| TopoSort.ASTFold.Recursive ds -> List.fold_right process_one_decl ds
in
fun ast -> TopoSort.ASTFold.fold fold ast

Expand Down Expand Up @@ -846,8 +845,7 @@ module Make (B : Backend.S) (C : Config) = struct
List.fold_left2 folder (return_normal env) ldis liv
|: SemanticsRule.LDTuple
(* End *)
| LDI_Var _, None
| LDI_Tuple _, None ->
| LDI_Var _, None | LDI_Tuple _, None ->
(* Should not happen in V1 because of TypingRule.LDUninitialisedTuple *)
fatal_from s Error.TypeInferenceNeeded

Expand Down Expand Up @@ -996,17 +994,14 @@ module Make (B : Backend.S) (C : Config) = struct
let () =
if debug then
let open Format in
let pp_value fmt v =
B.debug_value v |> pp_print_string fmt
in
let pp_value fmt v = B.debug_value v |> pp_print_string fmt in
eprintf "@[@<2>%a:@ @[%a@]@ ->@ %a@]@." PP.pp_pos s
(pp_print_list ~pp_sep:pp_print_space PP.pp_expr)
args
(pp_print_list ~pp_sep:pp_print_space pp_value)
vs
else (
List.map B.debug_value vs
|> String.concat " " |> print_string;
List.map B.debug_value vs |> String.concat " " |> print_string;
print_newline ())
in
return_continue env |: SemanticsRule.SDebug
Expand Down
Loading