File: mk_coq_main.sh

package info (click to toggle)
sail-ocaml 0.19.1%2Bdfsg5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,008 kB
  • sloc: ml: 75,941; ansic: 8,848; python: 1,342; exp: 560; sh: 474; makefile: 218; cpp: 36
file content (48 lines) | stat: -rwxr-xr-x 1,354 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash

OUT="_coqbuild_$1/main.v"

cat <<EOF > "$OUT"
From SailStdpp Require Import State_monad State_lifting.
Require Import String.
Require Import List.
Import ListNotations.
Open Scope string.

Goal True.
EOF
if grep -q "Definition main '(tt : unit) : unit :=" "_coqbuild_$1/$1.v"; then
  cat <<EOF >> "$OUT"
let result := eval vm_compute in (main tt) in
match result with
| tt => idtac "OK"
| _ => idtac "Fail (unexpected result):" result
end.
exact I.
Qed.
EOF
else
  if grep -q 'initial_regstate' "_coqbuild_$1/$1.v"; then
    REGSTATE="initial_regstate"
  else
    REGSTATE='init_regstate'
  fi
  if grep -q 'sail_model_init.*: unit :=' "_coqbuild_$1/$1.v"; then
    RUN="main tt"
  else
    RUN="Prompt_monad.bind0 (sail_model_init tt) (main tt)"
  fi
  cat <<EOF >> "$OUT"
set (outerr := ltac:(
let result := eval vm_compute in (liftState register_accessors ($RUN) (init_state $REGSTATE) default_choice) in
match result with
  | [(Value tt,?state,_)] => idtac "OK"; exact (state.(ss_output), "")
  | [(Ex (Failure ?s),?state,_)] => idtac "Fail:" s; exact (state.(ss_output), "Assertion failed: " ++ s)
  | _ => idtac "Fail (unexpected result):" result; exact ("","")
end)).
Redirect "output" (let t := eval vm_compute in (fst outerr) in idtac t).
Redirect "error" (let t := eval vm_compute in (snd outerr) in idtac t).
exact I.
Qed.
EOF
fi