equal
deleted
inserted
replaced
25 -> string -> int option -> string -> Token.T list -> string * string option list |
25 -> string -> int option -> string -> Token.T list -> string * string option list |
26 val present_code: theory -> string list -> (Code_Thingol.naming -> string list) |
26 val present_code: theory -> string list -> (Code_Thingol.naming -> string list) |
27 -> string -> int option -> string -> Token.T list -> string |
27 -> string -> int option -> string -> Token.T list -> string |
28 val check_code: theory -> string list |
28 val check_code: theory -> string list |
29 -> ((string * bool) * Token.T list) list -> unit |
29 -> ((string * bool) * Token.T list) list -> unit |
30 |
|
31 val shell_command: string (*theory name*) -> string (*export_code expr*) -> unit |
|
32 |
30 |
33 type serializer |
31 type serializer |
34 type literals = Code_Printer.literals |
32 type literals = Code_Printer.literals |
35 val add_target: string * { serializer: serializer, literals: literals, |
33 val add_target: string * { serializer: serializer, literals: literals, |
36 check: { env_var: string, make_destination: Path.T -> Path.T, |
34 check: { env_var: string, make_destination: Path.T -> Path.T, |
54 val add_instance_syntax: string -> class * string -> unit option -> theory -> theory |
52 val add_instance_syntax: string -> class * string -> unit option -> theory -> theory |
55 val add_tyco_syntax: string -> string -> tyco_syntax option -> theory -> theory |
53 val add_tyco_syntax: string -> string -> tyco_syntax option -> theory -> theory |
56 val add_const_syntax: string -> string -> const_syntax option -> theory -> theory |
54 val add_const_syntax: string -> string -> const_syntax option -> theory -> theory |
57 val add_reserved: string -> string -> theory -> theory |
55 val add_reserved: string -> string -> theory -> theory |
58 val add_include: string -> string * (string * string list) option -> theory -> theory |
56 val add_include: string -> string * (string * string list) option -> theory -> theory |
|
57 |
|
58 val codegen_tool: string (*theory name*) -> bool -> string (*export_code expr*) -> unit |
59 end; |
59 end; |
60 |
60 |
61 structure Code_Target : CODE_TARGET = |
61 structure Code_Target : CODE_TARGET = |
62 struct |
62 struct |
63 |
63 |
681 |
681 |
682 val _ = |
682 val _ = |
683 Outer_Syntax.command "export_code" "generate executable code for constants" |
683 Outer_Syntax.command "export_code" "generate executable code for constants" |
684 Keyword.diag (Parse.!!! code_exprP >> (fn f => Toplevel.keep (f o Toplevel.theory_of))); |
684 Keyword.diag (Parse.!!! code_exprP >> (fn f => Toplevel.keep (f o Toplevel.theory_of))); |
685 |
685 |
686 fun shell_command thyname cmd = Toplevel.program (fn _ => |
|
687 (use_thy thyname; case Scan.read Token.stopper (Parse.!!! code_exprP) |
|
688 ((filter Token.is_proper o Outer_Syntax.scan Position.none) cmd) |
|
689 of SOME f => (writeln "Now generating code..."; f (Thy_Info.get_theory thyname)) |
|
690 | NONE => error ("Bad directive " ^ quote cmd))) |
|
691 handle Runtime.TOPLEVEL_ERROR => OS.Process.exit OS.Process.failure; |
|
692 |
|
693 end; (*local*) |
686 end; (*local*) |
694 |
687 |
|
688 |
|
689 (** external entrance point -- for codegen tool **) |
|
690 |
|
691 fun codegen_tool thyname qnd cmd_expr = |
|
692 let |
|
693 val thy = Thy_Info.get_theory thyname; |
|
694 val _ = quick_and_dirty := qnd; |
|
695 val parse = Scan.read Token.stopper (Parse.!!! code_exprP) o |
|
696 (filter Token.is_proper o Outer_Syntax.scan Position.none); |
|
697 in case parse cmd_expr |
|
698 of SOME f => (writeln "Now generating code..."; f thy) |
|
699 | NONE => error ("Bad directive " ^ quote cmd_expr) |
|
700 end; |
|
701 |
695 end; (*struct*) |
702 end; (*struct*) |