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

experiment: Viper integration #3477

Merged
merged 88 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
62595d0
stub code for viper
crusso Oct 7, 2022
fce1e32
initial command line arg
crusso Oct 7, 2022
cc5499f
output translations, add annotations and formatting
crusso Oct 7, 2022
353050e
some viper
crusso Oct 7, 2022
e11d486
start on pretty (not pretty)
crusso Oct 7, 2022
b14abe3
hack in more viper
crusso Oct 10, 2022
18e6003
better printing
crusso Oct 11, 2022
07a7912
mo stuff
crusso Oct 11, 2022
4b0a637
fix translation of NotE
crusso Oct 11, 2022
838d399
plumb contexts
crusso Oct 12, 2022
2615160
add self prefix on field access; add self param to methods
crusso Oct 12, 2022
9f7d795
handle await async {}; add test variants
crusso Oct 13, 2022
6c12511
viper: src-loc mapping (#3484)
ggreif Oct 14, 2022
18449d7
viper: cleanups (#3485)
ggreif Oct 14, 2022
36bea43
viper: testing (#3487)
ggreif Oct 14, 2022
c6feeaf
handle equality comparisons
ggreif Oct 14, 2022
137337e
handle `OrE` and `AndE`
ggreif Oct 14, 2022
d1799c9
fix copy&pasto
ggreif Oct 15, 2022
47ad446
implement `>`
ggreif Oct 15, 2022
6b59baf
pretty-print all binary operators
ggreif Oct 15, 2022
4544491
binops
ggreif Oct 15, 2022
228ba23
viper: invariants (#3488)
ggreif Oct 15, 2022
7459811
pretty-print `null`
ggreif Oct 16, 2022
e5a25af
Support generation of __init__ methods based on actor private fields …
aterga Oct 16, 2022
9f1761b
Add 'moc.js' endpoint for Viper integration
rvanasa Oct 17, 2022
7ca05ce
Reorganize moc.js endpoint
rvanasa Oct 17, 2022
2883120
Convert JS array to OCaml array
rvanasa Oct 17, 2022
e56ee70
update `viperserver` nightly
ggreif Oct 18, 2022
33edfca
indentation
ggreif Oct 19, 2022
1a061f2
Generate method specs in Motoko to Viper translation (#3496)
aterga Oct 19, 2022
fcce511
viper: assertions (#3499)
ggreif Oct 20, 2022
c62fa80
experiment: viper await async ghost state (#3500)
crusso Oct 21, 2022
08c8941
Add async constraint into test/viper/claim.mo
aterga Oct 21, 2022
222b601
Add manual encoding into test/viper/ok/claim.vpr.ok
aterga Oct 21, 2022
44fb500
fix tests to increment counter
crusso Oct 21, 2022
59d7ba8
viper: map translation exceptions to diagnostic errors (#3503)
crusso Oct 21, 2022
fee72de
viper: error source mappings in `moc.js` (#3501)
rvanasa Oct 21, 2022
0835e12
XON/XOFF for methods
ggreif Oct 21, 2022
5e112ec
viper: parse and emit concurrency assertions (#3504)
ggreif Oct 22, 2022
29ae2b6
tidy code; report more unsupported syntax; add // @verify to test sou…
crusso Oct 22, 2022
b8bdba2
viper: ignore generated `.mo.vpr` files
ggreif Oct 23, 2022
45d100a
viper: refactor using !!! helper (#3511)
crusso Oct 24, 2022
d76781f
viper: add the concurrency condition, observe verification fail (#3507)
ggreif Oct 24, 2022
80c1d39
turn runtime `assert`s into Viper `assume`s (#3506)
ggreif Oct 24, 2022
29d87d6
bump `viperserver.jar`
ggreif Oct 25, 2022
a8b19cf
Support static assertions as `assert:system` in Motoko to Viper trans…
aterga Oct 25, 2022
b18c52e
Reset 'marks' at the beginning of 'prog_mapped'
rvanasa Oct 27, 2022
adc5e3e
Merge pull request #3523 from dfinity/ryan/viper-reset-pretty
ggreif Oct 27, 2022
1e34444
patch `rocksdb`
ggreif Nov 8, 2022
ddaeb09
next try
ggreif Nov 9, 2022
a88eb35
victory!
ggreif Nov 9, 2022
218a85d
clean up
ggreif Nov 9, 2022
f59eba0
Delete rocks.diff
ggreif Nov 9, 2022
74cc67a
Delete rocks1.diff
ggreif Nov 9, 2022
54fd3f4
only do the defines for M1
ggreif Nov 9, 2022
e3cbe22
Merge branch 'gabor/m1' into viper
ggreif Nov 9, 2022
eadb2d5
bump to newest nightly
ggreif Nov 9, 2022
13f67e0
filter out underscores
ggreif Nov 10, 2022
487e041
ignore viper temporaries
ggreif Nov 14, 2022
8cf94fb
viper: conditionalise lexer/grammar (#3574)
ggreif Nov 15, 2022
15152f8
viper: enable recent VS Code extension improvements (#3581)
rvanasa Nov 15, 2022
fbf13f5
cover `WhileS`, but no invariant yet
ggreif Nov 16, 2022
d097d3c
explicitly fail on `MethodCallS` and `LabelS`
ggreif Nov 16, 2022
de28e14
Update default.nix
ggreif Nov 16, 2022
4fd7011
refresh the download link
ggreif Nov 16, 2022
d0c5f9d
accept
ggreif Nov 16, 2022
401520d
add ingredients for viper testing
ggreif Nov 16, 2022
91a4d92
accept
ggreif Nov 16, 2022
f0701f4
Merge branch 'master' into viper
ggreif Nov 16, 2022
857a0f7
undo merge snafu
ggreif Nov 16, 2022
f24d08c
simplify
ggreif Nov 16, 2022
1dcd79e
Merge branch 'master' into viper
crusso Nov 17, 2022
5c3954f
move IMPLIES token to assertions.mly
crusso Nov 18, 2022
5072557
tweaks
crusso Nov 18, 2022
f93555f
viper: associate the first `exhale` with the `async` expression (#3524)
ggreif Nov 18, 2022
74553c7
viper: switch to stable server (#3593)
ggreif Nov 18, 2022
1222479
Merge branch 'master' into viper
ggreif Nov 18, 2022
585bc73
add a Changelog entry
ggreif Nov 18, 2022
781ded2
Remove crib sheet
ggreif Nov 18, 2022
ffa3c73
remove more
ggreif Nov 18, 2022
55af544
spruce up this test a bit
ggreif Nov 18, 2022
98c563f
add some more features
ggreif Nov 18, 2022
4f15125
fix: thread the mode into the parser (#3599)
ggreif Nov 22, 2022
e8edbcb
test that `--viper` works
ggreif Nov 22, 2022
7bf2635
Update test/repl/viper.sh
ggreif Nov 22, 2022
7127efd
Merge remote-tracking branch 'origin/master' into viper
ggreif Nov 23, 2022
998f484
Document `--viper` in `src/viper/README.md` (#3601)
aterga Nov 25, 2022
de46df9
Merge branch 'master' into viper
aterga Nov 25, 2022
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ result*

/samples/**/*.txt

**/*.mo.vpr
test/viper/tmp

enable-internals

# Editor configuration
Expand Down
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
rejected, not accepted, to be consistent with the declarations of
mutable fields and mutable objects.

* Experimental Viper integration by compiling a very narrow subset of
Motoko to the verification intermediate language. See `src/viper/README.md`
and the PR for details. (#3477).

## 0.7.3 (2022-11-01)

* motoko (`moc`)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ A safe, simple, actor-based programming language for authoring [Internet Compute
* [Concrete syntax](doc/md/examples/grammar.txt).
* [Documentation sources](doc/md/).
* [Base library documentation](doc/md/base/index.md).
* [_Motoko-san_: a prototypical deductive verifier](src/viper/README.md).

## Introduction

Expand Down
9 changes: 9 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ rec {
patchShebangs .
${llvmEnv}
export ESM=${nixpkgs.sources.esm}
export VIPER_SERVER=${viperServer}
ggreif marked this conversation as resolved.
Show resolved Hide resolved
type -p moc && moc --version
make -C ${dir}
'';
Expand Down Expand Up @@ -490,6 +491,7 @@ rec {
run-deser = test_subdir "run-deser" [ deser ];
perf = perf_subdir "perf" [ moc nixpkgs.drun ];
bench = perf_subdir "bench" [ moc nixpkgs.drun ];
viper = test_subdir "viper" [ moc nixpkgs.which nixpkgs.openjdk nixpkgs.z3 ];
inherit qc lsp unit candid profiling-graphs coverage;
}) // { recurseForDerivations = true; };

Expand Down Expand Up @@ -750,6 +752,11 @@ rec {
builtins.attrValues js;
};

viperServer = nixpkgs.fetchurl {
url = https://github.com/viperproject/viperserver/releases/download/v.22.11-release/viperserver.jar;
sha256 = "sha256-debC8ZpbIjgpEeISCISU0EVySJvf+WsUkUaLuJ526wA=";
};

shell = stdenv.mkDerivation {
name = "motoko-shell";

Expand Down Expand Up @@ -780,6 +787,7 @@ rec {
nixpkgs.nix-update
nixpkgs.rlwrap # for `rlwrap moc`
nixpkgs.difftastic
nixpkgs.openjdk nixpkgs.z3 nixpkgs.jq # for viper dev
]
));

Expand All @@ -797,6 +805,7 @@ rec {
LOCALE_ARCHIVE = nixpkgs.lib.optionalString stdenv.isLinux "${nixpkgs.glibcLocales}/lib/locale/locale-archive";
MOTOKO_BASE = base-src;
CANDID_TESTS = "${nixpkgs.sources.candid}/test";
VIPER_SERVER = "${viperServer}";

# allow building this as a derivation, so that hydra builds and caches
# the dependencies of shell.
Expand Down
2 changes: 2 additions & 0 deletions emacs/motoko-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"var"
"while"
"prim"
"invariant"
"implies"
))
;; Braces introduce blocks; it's nice to make them stand
;; out more than ordinary symbols
Expand Down
6 changes: 5 additions & 1 deletion src/exes/moc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let usage = "Usage: " ^ name ^ " [option] [file ...]"

(* Argument handling *)

type mode = Default | Check | StableCompatible | Compile | Run | Interact | PrintDeps | Explain
type mode = Default | Check | StableCompatible | Compile | Run | Interact | PrintDeps | Explain | Viper

let mode = ref Default
let args = ref []
Expand Down Expand Up @@ -42,6 +42,7 @@ let argspec = [
"-r", Arg.Unit (set_mode Run), " interpret programs";
"-i", Arg.Unit (set_mode Interact), " run interactive REPL (implies -r)";
"--check", Arg.Unit (set_mode Check), " type-check only";
"--viper", Arg.Unit (set_mode Viper), " emit viper code";
"--stable-compatible",
Arg.Tuple [
Arg.String (fun fp -> Flags.pre_ref := Some fp);
Expand Down Expand Up @@ -189,6 +190,9 @@ let process_files files : unit =
exit_on_none (Pipeline.run_files_and_stdin files)
| Check ->
Diag.run (Pipeline.check_files files)
| Viper ->
let (s, _) = Diag.run (Pipeline.viper_files files) in
printf "%s" s
| StableCompatible ->
begin
match (!Flags.pre_ref, !Flags.post_ref) with
Expand Down
1 change: 1 addition & 0 deletions src/ir_def/construct.ml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ let notE : Ir.exp -> Ir.exp = fun e ->
primE (RelPrim (T.bool, Operator.EqOp)) [e; falseE ()]
let andE : Ir.exp -> Ir.exp -> Ir.exp = fun e1 e2 -> ifE e1 e2 (falseE ()) T.bool
let orE : Ir.exp -> Ir.exp -> Ir.exp = fun e1 e2 -> ifE e1 (trueE ()) e2 T.bool
let impliesE : Ir.exp -> Ir.exp -> Ir.exp = fun e1 e2 -> orE (notE e1) e2
let rec conjE : Ir.exp list -> Ir.exp = function
| [] -> trueE ()
| [x] -> x
Expand Down
1 change: 1 addition & 0 deletions src/ir_def/construct.mli
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ val trueE : unit -> exp
val notE : exp -> exp
val andE : exp -> exp -> exp
val orE : exp -> exp -> exp
val impliesE : exp -> exp -> exp
val conjE : exp list -> exp

val declare_idE : id -> typ -> exp -> exp
Expand Down
25 changes: 21 additions & 4 deletions src/js/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,30 @@ let js_run list source =
let list = Js.to_array list |> Array.to_list |> List.map Js.to_string in
ignore (Pipeline.run_stdin_from_file list (Js.to_string source))

let js_viper filenames =
let result = Pipeline.viper_files (Js.to_array filenames |> Array.to_list |> List.map Js.to_string) in
js_result result (fun (viper, lookup) ->
let js_viper = Js.string viper in
let js_lookup = Js.wrap_callback (fun js_file js_region ->
let file = Js.to_string js_file in
let viper_region = match js_region |> Js.to_array |> Array.to_list with
| [a; b; c; d] ->
lookup { left = { file; line = a + 1; column = b }; right = { file; line = c + 1; column = d } }
| _ -> None in
match viper_region with
| Some region ->
Js.some (range_of_region region)
| None -> Js.null) in
Js.some (object%js
val viper = js_viper
val lookup = js_lookup
end))

let js_candid source =
js_result (Pipeline.generate_idl [Js.to_string source])
(fun prog ->
let code = Idllib.Arrange_idl.string_of_prog prog in
Js.some (Js.string code)
)
Js.some (Js.string code))

let js_stable_compatible pre post =
js_result (Pipeline.stable_compatible (Js.to_string pre) (Js.to_string post)) (fun _ -> Js.null)
Expand Down Expand Up @@ -96,8 +114,7 @@ let js_compile_wasm mode source =
val wasm = code
val candid = Js.string candid
val stable = sig_
end)
)
end))

let js_parse_candid s =
let parse_result = Idllib.Pipeline.parse_string (Js.to_string s) in
Expand Down
1 change: 1 addition & 0 deletions src/js/moc_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ let () =
method gcFlags option = gc_flags option
method run list s = Flags.compiled := false; wrap_output (fun _ -> js_run list s)
method check s = Flags.compiled := false; js_check s
method viper filenames = js_viper filenames
method candid s = Flags.compiled := true; js_candid s
method stableCompatible pre post = js_stable_compatible pre post
method compileWasm mode s = Flags.compiled := true; js_compile_wasm mode s
Expand Down
1 change: 1 addition & 0 deletions src/lang_utils/error_codes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,5 @@ let error_codes : (string * string option) list =
"M0178", None; (* Bases of record extensions must be either objects or modules *)
"M0179", None; (* Mutable (var) fields from bases must be overwritten explicitly *)
"M0180", None; (* Shared function has unexpected type parameters *)
"M0181", None; (* Verification mode assertions not allowed *)
]
5 changes: 4 additions & 1 deletion src/languageServer/imports.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ type import = string * string

let parse_with mode lexbuf parser =
let tokenizer, _ = Lexer.tokenizer mode lexbuf in
Ok (Parsing.parse 0 (parser lexbuf.Lexing.lex_curr_p) tokenizer lexbuf)
Ok
(Parsing.parse Lexer_lib.mode 0
(parser lexbuf.Lexing.lex_curr_p)
tokenizer lexbuf)

let parse_string s =
try
Expand Down
4 changes: 3 additions & 1 deletion src/lowering/desugar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ and exp' at note = function
| S.NotE e -> (notE (exp e)).it
| S.AndE (e1, e2) -> (andE (exp e1) (exp e2)).it
| S.OrE (e1, e2) -> (orE (exp e1) (exp e2)).it
| S.ImpliesE (e1, e2) -> (impliesE (exp e1) (exp e2)).it
| S.IfE (e1, e2, e3) -> I.IfE (exp e1, exp e2, exp e3)
| S.SwitchE (e1, cs) -> I.SwitchE (exp e1, cases cs)
| S.TryE (e1, cs) -> I.TryE (exp e1, cases cs)
Expand All @@ -222,7 +223,8 @@ and exp' at note = function
| T.Async (t, _) -> t
| _ -> assert false)
| S.AwaitE e -> I.PrimE (I.AwaitPrim, [exp e])
| S.AssertE e -> I.PrimE (I.AssertPrim, [exp e])
| S.AssertE (Runtime, e) -> I.PrimE (I.AssertPrim, [exp e])
| S.AssertE (_, e) -> (unitE ()).it
| S.AnnotE (e, _) -> assert false
| S.ImportE (f, ir) -> raise (Invalid_argument (Printf.sprintf "Import expression found in unit body: %s" f))
| S.PrimE s -> raise (Invalid_argument ("Unapplied prim " ^ s))
Expand Down
11 changes: 10 additions & 1 deletion src/mo_def/arrange.ml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ module Make (Cfg : Config) = struct
| NotE e -> "NotE" $$ [exp e]
| AndE (e1, e2) -> "AndE" $$ [exp e1; exp e2]
| OrE (e1, e2) -> "OrE" $$ [exp e1; exp e2]
| ImpliesE (e1, e2) -> "ImpliesE"$$ [exp e1; exp e2]
| IfE (e1, e2, e3) -> "IfE" $$ [exp e1; exp e2; exp e3]
| SwitchE (e, cs) -> "SwitchE" $$ [exp e] @ List.map case cs
| WhileE (e1, e2) -> "WhileE" $$ [exp e1; exp e2]
Expand All @@ -90,7 +91,15 @@ module Make (Cfg : Config) = struct
| RetE e -> "RetE" $$ [exp e]
| AsyncE (tb, e) -> "AsyncE" $$ [typ_bind tb; exp e]
| AwaitE e -> "AwaitE" $$ [exp e]
| AssertE e -> "AssertE" $$ [exp e]
| AssertE (Runtime, e) -> "AssertE" $$ [exp e]
| AssertE (Static, e) -> "Static_AssertE" $$ [exp e]
| AssertE (Invariant, e) -> "Invariant" $$ [exp e]
| AssertE (Precondition, e) -> "Precondition" $$ [exp e]
| AssertE (Postcondition, e) -> "Postcondition" $$ [exp e]
| AssertE (Loop_entry, e) -> "Loop_entry" $$ [exp e]
| AssertE (Loop_continue, e) -> "Loop_continue" $$ [exp e]
| AssertE (Loop_exit, e) -> "Loop_exit" $$ [exp e]
| AssertE (Concurrency s, e) -> "Concurrency"^s $$ [exp e]
| AnnotE (e, t) -> "AnnotE" $$ [exp e; typ t]
| OptE e -> "OptE" $$ [exp e]
| DoOptE e -> "DoOptE" $$ [exp e]
Expand Down
6 changes: 5 additions & 1 deletion src/mo_def/syntax.ml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ and exp' =
| NotE of exp (* negation *)
| AndE of exp * exp (* conjunction *)
| OrE of exp * exp (* disjunction *)
| ImpliesE of exp * exp (* implication *)
| IfE of exp * exp * exp (* conditional *)
| SwitchE of exp * case list (* switch *)
| WhileE of exp * exp (* while-do loop *)
Expand All @@ -184,7 +185,7 @@ and exp' =
| DebugE of exp (* debugging *)
| AsyncE of typ_bind * exp (* async *)
| AwaitE of exp (* await *)
| AssertE of exp (* assertion *)
| AssertE of assert_kind * exp (* assertion *)
| AnnotE of exp * typ (* type annotation *)
| ImportE of (string * resolved_import ref) (* import statement *)
| ThrowE of exp (* throw exception *)
Expand All @@ -195,6 +196,9 @@ and exp' =
| AtomE of string (* atom *)
*)

and assert_kind =
| Runtime | Static | Invariant | Precondition | Postcondition | Concurrency of string | Loop_entry | Loop_continue | Loop_exit

and dec_field = dec_field' Source.phrase
and dec_field' = {dec : dec; vis : vis; stab: stab option}

Expand Down
49 changes: 49 additions & 0 deletions src/mo_frontend/assertions.mly
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
%{

let verification_syntax_error at code msg =
Diag.add_msg (Option.get !Parser_lib.msg_store)
(Diag.error_message at code "verification syntax" msg)

(* Verification mode only *)

let (&&&) cond (action : Mo_def.Syntax.exp) =
if not cond then
verification_syntax_error
action.Source.at
"M0181" "verification assertions not permitted in normal mode";
action

let is_verification () =
match !Parser_lib.mode with
| None -> assert false
| Some mode -> mode.Lexer_lib.verification

%}

(* Viper-only tokens and productions *)

%token INVARIANT
%token IMPLIES
(*
%nonassoc IMPLIES (* see parser.mly *)
*)

%%

%public exp_bin(B) :
| e1=exp_bin(B) IMPLIES e2=exp_bin(ob)
{ ImpliesE(e1, e2) @? at $sloc }

%public exp_nondec(B) :
| ASSERT COLON SYSTEM e=exp_nest
{ is_verification () &&& AssertE(Static, e) @? at $sloc }
| ASSERT COLON INVARIANT e=exp_nest
{ is_verification () &&& AssertE(Invariant, e) @? at $sloc }
| ASSERT COLON FUNC e=exp_nest
{ is_verification () &&& AssertE(Precondition, e) @? at $sloc }
| ASSERT COLON RETURN e=exp_nest
{ is_verification () &&& AssertE(Postcondition, e) @? at $sloc }
| ASSERT COLON s=NAT COLON ASYNC e=exp_nest
{ is_verification () &&& AssertE(Concurrency s, e) @? at $sloc }

%%
3 changes: 2 additions & 1 deletion src/mo_frontend/definedness.ml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ let rec exp msgs e : f = match e.it with
| NotE e -> exp msgs e
| AndE (e1, e2) -> exps msgs [e1; e2]
| OrE (e1, e2) -> exps msgs [e1; e2]
| ImpliesE (e1, e2) -> exps msgs [e1; e2]
| IfE (e1, e2, e3) -> exps msgs [e1; e2; e3]
| SwitchE (e, cs) -> exp msgs e ++ cases msgs cs
| TryE (e, cs) -> exp msgs e ++ cases msgs cs
Expand All @@ -124,7 +125,7 @@ let rec exp msgs e : f = match e.it with
| DebugE e -> exp msgs e
| AsyncE (_, e) -> exp msgs e
| AwaitE e -> exp msgs e
| AssertE e -> exp msgs e
| AssertE (_, e) -> exp msgs e
| AnnotE (e, t) -> exp msgs e
| OptE e -> exp msgs e
| DoOptE e -> exp msgs e
Expand Down
3 changes: 2 additions & 1 deletion src/mo_frontend/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
(instrumentation (backend bisect_ppx --bisect-silent yes))
)
(menhir
(modules parser)
(modules parser assertions)
(merge_into parser)
(flags --table --inspection -v --strict)
(infer true)
)
Expand Down
3 changes: 2 additions & 1 deletion src/mo_frontend/effect.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ let rec infer_effect_exp (exp:Syntax.exp) : T.eff =
| TagE (_, exp1)
| DotE (exp1, _)
| NotE exp1
| AssertE exp1
| AssertE (_, exp1)
| LabelE (_, _, exp1)
| BreakE (_, exp1)
| RetE exp1
Expand All @@ -64,6 +64,7 @@ let rec infer_effect_exp (exp:Syntax.exp) : T.eff =
| CallE (exp1, _, exp2)
| AndE (exp1, exp2)
| OrE (exp1, exp2)
| ImpliesE (exp1, exp2)
| WhileE (exp1, exp2)
| LoopE (exp1, Some exp2)
| ForE (_, exp1, exp2) ->
Expand Down
2 changes: 2 additions & 0 deletions src/mo_frontend/error_reporting.ml
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ let terminal2token (type a) (symbol : a terminal) : token =
| T_ANDOP -> ANDOP
| T_ANDASSIGN -> ANDASSIGN
| T_AND -> AND
| T_IMPLIES -> IMPLIES
| T_ADDOP -> ADDOP
| T_ACTOR -> ACTOR
| T_INVARIANT -> INVARIANT
| T_WRAPADDOP -> WRAPADDOP
| T_WRAPSUBOP -> WRAPSUBOP
| T_WRAPMULOP -> WRAPMULOP
Expand Down
3 changes: 3 additions & 0 deletions src/mo_frontend/lexer_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
*)
type mode = {
privileged : bool;
verification : bool;
}

let mode : mode = {
privileged = Option.is_some (Sys.getenv_opt "MOC_UNLOCK_PRIM");
verification = Option.is_some (Sys.getenv_opt "MOC_UNLOCK_VERIFICATION");
}

let mode_priv : mode = { mode with privileged = true }
let mode_verification : mode = { mode with verification = true }


exception Error of Source.region * string
Expand Down
Loading