equal
deleted
inserted
replaced
41 | _ => Position.line_file line file); |
41 | _ => Position.line_file line file); |
42 |
42 |
43 |
43 |
44 (* parse trees *) |
44 (* parse trees *) |
45 |
45 |
46 fun report_parse_tree context = |
46 fun report_parse_tree context depth = |
47 let |
47 let |
48 val pos_of = pos_of_location context; |
48 val pos_of = pos_of_location context; |
49 fun report loc (PTtype types) = (* FIXME body text *) |
49 fun report loc (PTtype types) = |
50 Position.report Markup.ML_typing (pos_of loc) |
50 PolyML.NameSpace.displayTypeExpression (types, depth) |
|
51 |> pretty_ml |> Pretty.from_ML |> Pretty.string_of |
|
52 |> Position.report_text Markup.ML_typing (pos_of loc) |
51 | report loc (PTdeclaredAt decl) = |
53 | report loc (PTdeclaredAt decl) = |
52 Markup.markup (Markup.properties (Position.properties_of (pos_of decl)) Markup.ML_def) "" |
54 Markup.markup (Markup.properties (Position.properties_of (pos_of decl)) Markup.ML_def) "" |
53 |> Position.report_text Markup.ML_ref (pos_of loc) |
55 |> Position.report_text Markup.ML_ref (pos_of loc) |
54 | report _ (PTnextSibling tree) = report_tree (tree ()) |
56 | report _ (PTnextSibling tree) = report_tree (tree ()) |
55 | report _ (PTfirstChild tree) = report_tree (tree ()) |
57 | report _ (PTfirstChild tree) = report_tree (tree ()) |
93 put (Pretty.string_of (Pretty.from_ML (pretty_ml message))); |
95 put (Pretty.string_of (Pretty.from_ML (pretty_ml message))); |
94 put (Position.str_of (pos_of_location (the (Context.thread_data ())) location) ^ "\n")); |
96 put (Position.str_of (pos_of_location (the (Context.thread_data ())) location) ^ "\n")); |
95 |
97 |
96 |
98 |
97 (* results *) |
99 (* results *) |
|
100 |
|
101 val depth = get_print_depth (); |
|
102 val with_struct = ! PolyML.Compiler.printTypesWithStructureName; |
98 |
103 |
99 fun apply_result {fixes, types, signatures, structures, functors, values} = |
104 fun apply_result {fixes, types, signatures, structures, functors, values} = |
100 let |
105 let |
101 fun add_prefix prefix (PrettyBlock (ind, consistent, context, prts)) = |
106 fun add_prefix prefix (PrettyBlock (ind, consistent, context, prts)) = |
102 let |
107 let |
107 val this_prefix = make_prefix context; |
112 val this_prefix = make_prefix context; |
108 in PrettyBlock (ind, consistent, context, map (add_prefix this_prefix) prts) end |
113 in PrettyBlock (ind, consistent, context, map (add_prefix this_prefix) prts) end |
109 | add_prefix prefix (prt as PrettyString s) = |
114 | add_prefix prefix (prt as PrettyString s) = |
110 if prefix = "" then prt else PrettyString (prefix ^ s) |
115 if prefix = "" then prt else PrettyString (prefix ^ s) |
111 | add_prefix _ (prt as PrettyBreak _) = prt; |
116 | add_prefix _ (prt as PrettyBreak _) = prt; |
112 |
|
113 val depth = get_print_depth (); |
|
114 val with_struct = ! PolyML.Compiler.printTypesWithStructureName; |
|
115 |
117 |
116 fun display disp x = |
118 fun display disp x = |
117 if depth > 0 then |
119 if depth > 0 then |
118 (disp x |
120 (disp x |
119 |> with_struct ? add_prefix "" |
121 |> with_struct ? add_prefix "" |
141 List.app apply_val values |
143 List.app apply_val values |
142 end; |
144 end; |
143 |
145 |
144 fun result_fun (phase1, phase2) () = |
146 fun result_fun (phase1, phase2) () = |
145 (case phase1 of NONE => () |
147 (case phase1 of NONE => () |
146 | SOME parse_tree => report_parse_tree (the (Context.thread_data ())) parse_tree; |
148 | SOME parse_tree => report_parse_tree (the (Context.thread_data ())) depth parse_tree; |
147 case phase2 of NONE => error "Static Errors" |
149 case phase2 of NONE => error "Static Errors" |
148 | SOME code => apply_result (Toplevel.program code)); |
150 | SOME code => apply_result (Toplevel.program code)); |
149 |
151 |
150 |
152 |
151 (* compiler invocation *) |
153 (* compiler invocation *) |