Skip to content

Commit

Permalink
Updated Z_Machines to use the new type signature for generating chann…
Browse files Browse the repository at this point in the history
…els types
  • Loading branch information
simondfoster committed Aug 6, 2024
1 parent 4e6012b commit 4561c88
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Z_Machine.ML
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,18 @@ fun zmachine_body_sem n st init inve ops ends ctx =

fun chantype_name n = n ^ "_chan"

fun zmachine_sem (ZMachine {name = n, state = s, init = i, inv = inv, operations = ops, ends = e}) ctx =
fun zmachine_sem (ZMachine {name = n, state = s, init = i, inv = inv, operations = ops, ends = e}) thy =
let open Syntax; open HOLogic; open Lift_Expr
val ctx = Named_Target.theory_init thy
val cs = map (fn n => (firstLower n, YXML.content_of (string_of_typ ctx (get_zop_ptype n ctx)))) ops @
map (fn n => (firstLower n ^ "_Out", YXML.content_of (string_of_typ ctx (get_zop_outtype n ctx)))) ops
val st = read_typ ctx s
val inve = mk_lift_expr ctx (parse_term ctx inv)
val init = parse_term ctx i
val ends = mk_lift_expr ctx (parse_term ctx e)
in Channel_Type.compile_chantype (chantype_name n, cs) ctx |>
Named_Target.theory_init o mk_chan_show_inst (chantype_name n) ops o Local_Theory.exit_global |>
zmachine_body_sem n st init inve ops ends
in Channel_Type.compile_chantype (chantype_name n, cs) thy |>
Named_Target.theory_init o mk_chan_show_inst (chantype_name n) ops |>
Local_Theory.exit_global o zmachine_body_sem n st init inve ops ends
end

val parse_param =
Expand Down
2 changes: 1 addition & 1 deletion Z_Machine.thy
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ ML_file \<open>Z_Machine.ML\<close>

ML \<open>
Outer_Syntax.command @{command_keyword zmachine} "define a Z machine"
(Z_Machine.parse_zmachine >> (Toplevel.local_theory NONE NONE o Z_Machine.zmachine_sem));
(Z_Machine.parse_zmachine >> (Toplevel.theory o Z_Machine.zmachine_sem));
Outer_Syntax.command @{command_keyword zoperation} "define a Z operation"
(Z_Machine.parse_operation >> (Toplevel.local_theory NONE NONE o Z_Machine.mk_zop));
Expand Down

0 comments on commit 4561c88

Please sign in to comment.