36 ML_Context.eval_text_in (SOME ctxt) false Position.none exp |
36 ML_Context.eval_text_in (SOME ctxt) false Position.none exp |
37 |
37 |
38 (* checks and prints a possibly open expressions, no index *) |
38 (* checks and prints a possibly open expressions, no index *) |
39 fun output_ml {context = ctxt, ...} (txt, (vs, stru)) = |
39 fun output_ml {context = ctxt, ...} (txt, (vs, stru)) = |
40 (eval_fn ctxt (ml_val vs stru txt); |
40 (eval_fn ctxt (ml_val vs stru txt); |
41 output (split_lines txt)) |
41 output ctxt (split_lines txt)) |
42 |
42 |
43 val parser_ml = Scan.lift (Args.name -- |
43 val parser_ml = Scan.lift (Args.name -- |
44 (Scan.optional (Args.$$$ "for" |-- Parse.!!! (Scan.repeat1 Args.name)) [] -- |
44 (Scan.optional (Args.$$$ "for" |-- Parse.!!! (Scan.repeat1 Args.name)) [] -- |
45 Scan.option (Args.$$$ "in" |-- Parse.!!! Args.name))) |
45 Scan.option (Args.$$$ "in" |-- Parse.!!! Args.name))) |
46 |
46 |
47 (* checks and prints a single ML-item and produces an index entry *) |
47 (* checks and prints a single ML-item and produces an index entry *) |
48 fun output_ml_ind {context = ctxt, ...} (txt, stru) = |
48 fun output_ml_ind {context = ctxt, ...} (txt, stru) = |
49 (eval_fn ctxt (ml_val [] stru txt); |
49 (eval_fn ctxt (ml_val [] stru txt); |
50 case (stru, Long_Name.base_name txt, Long_Name.qualifier txt) of |
50 case (stru, Long_Name.base_name txt, Long_Name.qualifier txt) of |
51 (NONE, bn, "") => output_indexed {main = Code txt, minor = NoString} (split_lines txt) |
51 (NONE, bn, "") => output_indexed ctxt {main = Code txt, minor = NoString} (split_lines txt) |
52 | (NONE, bn, qn) => output_indexed {main = Code bn, minor = Struct qn} (split_lines txt) |
52 | (NONE, bn, qn) => output_indexed ctxt {main = Code bn, minor = Struct qn} (split_lines txt) |
53 | (SOME st, _, _) => output_indexed {main = Code txt, minor = Struct st} (split_lines txt)) |
53 | (SOME st, _, _) => output_indexed ctxt {main = Code txt, minor = Struct st} (split_lines txt)) |
54 |
54 |
55 val parser_ml_ind = Scan.lift (Args.name -- |
55 val parser_ml_ind = Scan.lift (Args.name -- |
56 Scan.option (Args.$$$ "in" |-- Parse.!!! Args.name)) |
56 Scan.option (Args.$$$ "in" |-- Parse.!!! Args.name)) |
57 |
57 |
58 (* checks and prints structures *) |
58 (* checks and prints structures *) |
59 fun gen_output_struct outfn {context = ctxt, ...} txt = |
59 fun gen_output_struct outfn ctxt txt = |
60 (eval_fn ctxt (ml_struct txt); |
60 (eval_fn ctxt (ml_struct txt); |
61 outfn {main = Code txt, minor = Plain "structure"} (split_lines txt)) |
61 outfn {main = Code txt, minor = Plain "structure"} (split_lines txt)) |
62 |
62 |
63 val output_struct = gen_output_struct (K output) |
63 fun output_struct {context = ctxt, ...} = gen_output_struct (K (output ctxt)) ctxt |
64 val output_struct_ind = gen_output_struct output_indexed |
64 fun output_struct_ind {context = ctxt, ...} = gen_output_struct (output_indexed ctxt) ctxt |
65 |
65 |
66 (* prints functors; no checks *) |
66 (* prints functors; no checks *) |
67 fun gen_output_funct outfn {context = ctxt, ...} txt = |
67 fun gen_output_funct outfn txt = |
68 (outfn {main = Code txt, minor = Plain "functor"} (split_lines txt)) |
68 (outfn {main = Code txt, minor = Plain "functor"} (split_lines txt)) |
69 |
69 |
70 val output_funct = gen_output_funct (K output) |
70 fun output_funct {context = ctxt, ...} = gen_output_funct (K (output ctxt)) |
71 val output_funct_ind = gen_output_funct output_indexed |
71 fun output_funct_ind {context = ctxt, ...} = gen_output_funct (output_indexed ctxt) |
72 |
72 |
73 (* checks and prints types *) |
73 (* checks and prints types *) |
74 fun gen_output_type outfn {context = ctxt, ...} txt = |
74 fun gen_output_type outfn ctxt txt = |
75 (eval_fn ctxt (ml_type txt); |
75 (eval_fn ctxt (ml_type txt); |
76 outfn {main = Code txt, minor = Plain "type"} (split_lines txt)) |
76 outfn {main = Code txt, minor = Plain "type"} (split_lines txt)) |
77 |
77 |
78 val output_type = gen_output_type (K output) |
78 fun output_type {context = ctxt, ...} = gen_output_type (K (output ctxt)) ctxt |
79 val output_type_ind = gen_output_type output_indexed |
79 fun output_type_ind {context = ctxt, ...} = gen_output_type (output_indexed ctxt) ctxt |
80 |
80 |
81 (* checks and expression agains a result pattern *) |
81 (* checks and expression agains a result pattern *) |
82 fun output_response {context = ctxt, ...} (lhs, pat) = |
82 fun output_response {context = ctxt, ...} (lhs, pat) = |
83 (eval_fn ctxt (ml_pat (lhs, pat)); |
83 (eval_fn ctxt (ml_pat (lhs, pat)); |
84 write_file_ml_blk lhs (ProofContext.theory_of ctxt); |
84 write_file_ml_blk lhs (ProofContext.theory_of ctxt); |
85 output ((prefix_lines "" lhs) @ (prefix_lines "> " pat))) |
85 output ctxt ((prefix_lines "" lhs) @ (prefix_lines "> " pat))) |
86 |
86 |
87 (* checks the expressions, but does not check it against a result pattern *) |
87 (* checks the expressions, but does not check it against a result pattern *) |
88 fun output_response_fake {context = ctxt, ...} (lhs, pat) = |
88 fun output_response_fake {context = ctxt, ...} (lhs, pat) = |
89 (eval_fn ctxt (ml_val [] NONE lhs); |
89 (eval_fn ctxt (ml_val [] NONE lhs); |
90 write_file_ml_blk lhs (ProofContext.theory_of ctxt); |
90 write_file_ml_blk lhs (ProofContext.theory_of ctxt); |
91 output ((split_lines lhs) @ (prefix_lines "> " pat))) |
91 output ctxt ((split_lines lhs) @ (prefix_lines "> " pat))) |
92 |
92 |
93 (* checks the expressions, but does not check it against a result pattern *) |
93 (* checks the expressions, but does not check it against a result pattern *) |
94 fun ouput_response_fake_both _ (lhs, pat) = |
94 fun ouput_response_fake_both {context = ctxt, ...} (lhs, pat) = |
95 output ((split_lines lhs) @ (prefix_lines "> " pat)) |
95 output ctxt ((split_lines lhs) @ (prefix_lines "> " pat)) |
96 |
96 |
97 val single_arg = Scan.lift (Args.name) |
97 val single_arg = Scan.lift (Args.name) |
98 val two_args = Scan.lift (Args.name -- Args.name) |
98 val two_args = Scan.lift (Args.name -- Args.name) |
99 val test = Scan.lift (Args.name -- Args.name -- Scan.option (Args.$$$ "with" |-- Args.name)) |
99 val test = Scan.lift (Args.name -- Args.name -- Scan.option (Args.$$$ "with" |-- Args.name)) |
100 |
100 |