556 -- Scan.option (P.$$$ module_nameK |-- P.name) |
556 -- Scan.option (P.$$$ module_nameK |-- P.name) |
557 -- Scan.option (P.$$$ fileK |-- P.name) |
557 -- Scan.option (P.$$$ fileK |-- P.name) |
558 -- Scan.optional (P.$$$ "(" |-- P.arguments --| P.$$$ ")") [] |
558 -- Scan.optional (P.$$$ "(" |-- P.arguments --| P.$$$ ")") [] |
559 ) >> (fn (raw_cs, seris) => cmd raw_cs seris)); |
559 ) >> (fn (raw_cs, seris) => cmd raw_cs seris)); |
560 |
560 |
561 val _ = OuterSyntax.add_keywords [inK, module_nameK, fileK]; |
561 val _ = OuterSyntax.keywords [inK, module_nameK, fileK]; |
562 |
562 |
563 val (codeK, code_thmsK, code_depsK, code_propsK) = |
563 val (codeK, code_thmsK, code_depsK, code_propsK) = |
564 ("export_code", "code_thms", "code_deps", "code_props"); |
564 ("export_code", "code_thms", "code_deps", "code_props"); |
565 |
565 |
566 in |
566 in |
567 |
567 |
568 val codeP = |
568 val _ = |
569 OuterSyntax.improper_command codeK "generate executable code for constants" |
569 OuterSyntax.improper_command codeK "generate executable code for constants" |
570 K.diag (P.!!! (code_exprP code_cmd) >> (fn f => Toplevel.keep (f o Toplevel.theory_of))); |
570 K.diag (P.!!! (code_exprP code_cmd) >> (fn f => Toplevel.keep (f o Toplevel.theory_of))); |
571 |
571 |
572 fun codegen_command thy cmd = |
572 fun codegen_command thy cmd = |
573 case Scan.read OuterLex.stopper (P.!!! (code_exprP code_cmd)) ((filter OuterLex.is_proper o OuterSyntax.scan) cmd) |
573 case Scan.read OuterLex.stopper (P.!!! (code_exprP code_cmd)) ((filter OuterLex.is_proper o OuterSyntax.scan) cmd) |
574 of SOME f => (writeln "Now generating code..."; f thy) |
574 of SOME f => (writeln "Now generating code..."; f thy) |
575 | NONE => error ("Bad directive " ^ quote cmd); |
575 | NONE => error ("Bad directive " ^ quote cmd); |
576 |
576 |
577 val code_thmsP = |
577 val _ = |
578 OuterSyntax.improper_command code_thmsK "print system of defining equations for code" OuterKeyword.diag |
578 OuterSyntax.improper_command code_thmsK "print system of defining equations for code" OuterKeyword.diag |
579 (Scan.repeat P.term |
579 (Scan.repeat P.term |
580 >> (fn cs => Toplevel.no_timing o Toplevel.unknown_theory |
580 >> (fn cs => Toplevel.no_timing o Toplevel.unknown_theory |
581 o Toplevel.keep ((fn thy => code_thms_cmd thy cs) o Toplevel.theory_of))); |
581 o Toplevel.keep ((fn thy => code_thms_cmd thy cs) o Toplevel.theory_of))); |
582 |
582 |
583 val code_depsP = |
583 val _ = |
584 OuterSyntax.improper_command code_depsK "visualize dependencies of defining equations for code" OuterKeyword.diag |
584 OuterSyntax.improper_command code_depsK "visualize dependencies of defining equations for code" OuterKeyword.diag |
585 (Scan.repeat P.term |
585 (Scan.repeat P.term |
586 >> (fn cs => Toplevel.no_timing o Toplevel.unknown_theory |
586 >> (fn cs => Toplevel.no_timing o Toplevel.unknown_theory |
587 o Toplevel.keep ((fn thy => code_deps_cmd thy cs) o Toplevel.theory_of))); |
587 o Toplevel.keep ((fn thy => code_deps_cmd thy cs) o Toplevel.theory_of))); |
588 |
588 |
589 val code_propsP = |
589 val _ = |
590 OuterSyntax.command code_propsK "generate characteristic properties for executable constants" |
590 OuterSyntax.command code_propsK "generate characteristic properties for executable constants" |
591 K.thy_decl (P.!!! (code_exprP code_props_cmd) >> Toplevel.theory); |
591 K.thy_decl (P.!!! (code_exprP code_props_cmd) >> Toplevel.theory); |
592 |
592 |
593 val _ = OuterSyntax.add_parsers [codeP, code_thmsP, code_depsP, code_propsP]; |
|
594 |
|
595 end; (*local*) |
593 end; (*local*) |
596 |
594 |
597 end; (*struct*) |
595 end; (*struct*) |