202 |
202 |
203 val _ = ML_Context.add_antiq "code" (fn _ => Args.term >> ml_code_antiq); |
203 val _ = ML_Context.add_antiq "code" (fn _ => Args.term >> ml_code_antiq); |
204 |
204 |
205 local |
205 local |
206 |
206 |
207 structure P = OuterParse |
|
208 and K = OuterKeyword |
|
209 |
|
210 val datatypesK = "datatypes"; |
207 val datatypesK = "datatypes"; |
211 val functionsK = "functions"; |
208 val functionsK = "functions"; |
212 val fileK = "file"; |
209 val fileK = "file"; |
213 val andK = "and" |
210 val andK = "and" |
214 |
211 |
215 val _ = List.app K.keyword [datatypesK, functionsK]; |
212 val _ = List.app Keyword.keyword [datatypesK, functionsK]; |
216 |
213 |
217 val parse_datatype = (P.name --| P.$$$ "=" -- (P.term ::: (Scan.repeat (P.$$$ "|" |-- P.term)))); |
214 val parse_datatype = |
|
215 Parse.name --| Parse.$$$ "=" -- (Parse.term ::: (Scan.repeat (Parse.$$$ "|" |-- Parse.term))); |
218 |
216 |
219 in |
217 in |
220 |
218 |
221 val _ = |
219 val _ = |
222 OuterSyntax.command "code_reflect" "enrich runtime environment with generated code" |
220 Outer_Syntax.command "code_reflect" "enrich runtime environment with generated code" |
223 K.thy_decl (P.name -- Scan.optional (P.$$$ datatypesK |-- (parse_datatype |
221 Keyword.thy_decl (Parse.name -- Scan.optional (Parse.$$$ datatypesK |-- (parse_datatype |
224 ::: Scan.repeat (P.$$$ andK |-- parse_datatype))) [] |
222 ::: Scan.repeat (Parse.$$$ andK |-- parse_datatype))) [] |
225 -- Scan.optional (P.$$$ functionsK |-- Scan.repeat1 P.name) [] |
223 -- Scan.optional (Parse.$$$ functionsK |-- Scan.repeat1 Parse.name) [] |
226 -- Scan.option (P.$$$ fileK |-- P.name) |
224 -- Scan.option (Parse.$$$ fileK |-- Parse.name) |
227 >> (fn (((module_name, raw_datatypes), raw_functions), some_file) => Toplevel.theory |
225 >> (fn (((module_name, raw_datatypes), raw_functions), some_file) => Toplevel.theory |
228 (code_reflect_cmd raw_datatypes raw_functions module_name some_file))); |
226 (code_reflect_cmd raw_datatypes raw_functions module_name some_file))); |
229 |
227 |
230 end; (*local*) |
228 end; (*local*) |
231 |
229 |