Skip to content
Snippets Groups Projects
Commit 2a06b7d8 authored by Frédéric Tuong's avatar Frédéric Tuong
Browse files

simplify

parent 47d6cb3c
Branches master
No related tags found
No related merge requests found
...@@ -376,8 +376,8 @@ subsection \<open>Continuation Calculus with the C Environment: Presentation in ...@@ -376,8 +376,8 @@ subsection \<open>Continuation Calculus with the C Environment: Presentation in
declare [[C_parser_trace = false]] declare [[C_parser_trace = false]]
ML\<open> ML\<open>
fun C src = C_Module.C' (C_Module.env (Context.the_generic_context ())) src val C = C_Module.C' NONE
val C' = C_Module.C' val C' = C_Module.C' o SOME
\<close> \<close>
C \<comment> \<open>Nesting C code without propagating the C environment\<close> \<open> C \<comment> \<open>Nesting C code without propagating the C environment\<close> \<open>
......
...@@ -50,17 +50,14 @@ ML\<open> ...@@ -50,17 +50,14 @@ ML\<open>
val _ = Theory.setup val _ = Theory.setup
(C_Inner_Syntax.command C_Inner_Isar_Cmd.setup' C_Parse.ML_source ("\<simeq>setup", \<^here>, \<^here>)) (C_Inner_Syntax.command C_Inner_Isar_Cmd.setup' C_Parse.ML_source ("\<simeq>setup", \<^here>, \<^here>))
val C' = C_Module.C' val C = C_Module.C'
fun C opt = case opt of NONE => C' (C_Module.env (Context.the_generic_context ()))
| SOME env => C' env
fun C_def dir name _ _ = fun C_def dir name _ _ =
Context.map_theory Context.map_theory
(C_Inner_Syntax.command' (C_Inner_Syntax.command'
(C_Inner_Syntax.drop1 (C_Inner_Syntax.drop1
(C_Scan.Right ( (fn src => fn context => (C_Scan.Right ( (fn src => fn context =>
C' (C_Stack.Data_Lang.get' context |> #2) src context) C_Module.C' (SOME (C_Stack.Data_Lang.get' context |> #2)) src context)
, dir))) , dir)))
C_Parse.C_source C_Parse.C_source
name) name)
......
...@@ -360,19 +360,25 @@ fun C source = ...@@ -360,19 +360,25 @@ fun C source =
exec_eval source exec_eval source
#> Local_Theory.propagate_ml_env #> Local_Theory.propagate_ml_env
fun C' env_lang src context = val C' =
context let
|> C_Env.empty_env_tree fun C env_lang src context =
|> C_Context.eval_source' context
env_lang |> C_Env.empty_env_tree
(fn src => start src context) |> C_Context.eval_source'
err env_lang
accept (fn src => start src context)
src err
|> (fn (_, {context, reports_text, error_lines}) => accept
tap (fn _ => case error_lines of [] => () | l => warning (cat_lines (rev l))) src
(C_Stack.Data_Tree.map (curry C_Stack.Data_Tree_Args.merge (reports_text, [])) |> (fn (_, {context, reports_text, error_lines}) =>
context)) tap (fn _ => case error_lines of [] => () | l => warning (cat_lines (rev l)))
(C_Stack.Data_Tree.map (curry C_Stack.Data_Tree_Args.merge (reports_text, []))
context))
in
fn NONE => (fn src => C (env (Context.the_generic_context ())) src)
| SOME env_lang => C env_lang
end
fun C_export_file (pos, _) lthy = fun C_export_file (pos, _) lthy =
let let
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment