39 |
39 |
40 (* parse trees *) |
40 (* parse trees *) |
41 |
41 |
42 fun report_parse_tree depth space = |
42 fun report_parse_tree depth space = |
43 let |
43 let |
|
44 fun report_decl markup loc decl = |
|
45 Position.report_text Markup.ML_ref (position_of loc) |
|
46 (Markup.markup (Markup.properties (Position.properties_of (position_of decl)) markup) ""); |
44 fun report loc (PolyML.PTtype types) = |
47 fun report loc (PolyML.PTtype types) = |
45 PolyML.NameSpace.displayTypeExpression (types, depth, space) |
48 PolyML.NameSpace.displayTypeExpression (types, depth, space) |
46 |> pretty_ml |> Pretty.from_ML |> Pretty.string_of |
49 |> pretty_ml |> Pretty.from_ML |> Pretty.string_of |
47 |> Position.report_text Markup.ML_typing (position_of loc) |
50 |> Position.report_text Markup.ML_typing (position_of loc) |
48 | report loc (PolyML.PTdeclaredAt decl) = |
51 | report loc (PolyML.PTdeclaredAt decl) = report_decl Markup.ML_def loc decl |
49 Markup.markup |
52 | report loc (PolyML.PTopenedAt decl) = report_decl Markup.ML_open loc decl |
50 (Markup.properties (Position.properties_of (position_of decl)) Markup.ML_def) "" |
53 | report loc (PolyML.PTstructureAt decl) = report_decl Markup.ML_struct loc decl |
51 |> Position.report_text Markup.ML_ref (position_of loc) |
|
52 | report _ (PolyML.PTnextSibling tree) = report_tree (tree ()) |
54 | report _ (PolyML.PTnextSibling tree) = report_tree (tree ()) |
53 | report _ (PolyML.PTfirstChild tree) = report_tree (tree ()) |
55 | report _ (PolyML.PTfirstChild tree) = report_tree (tree ()) |
54 | report _ _ = () |
56 | report _ _ = () |
55 and report_tree (loc, props) = List.app (report loc) props; |
57 and report_tree (loc, props) = List.app (report loc) props; |
56 in report_tree end; |
58 in report_tree end; |
75 val syms = Symbol.explode (ML_Lex.check_content_of tok); |
77 val syms = Symbol.explode (ML_Lex.check_content_of tok); |
76 val (ps, _) = fold_map (fn s => fn p => (p, Position.advance s p)) syms |
78 val (ps, _) = fold_map (fn s => fn p => (p, Position.advance s p)) syms |
77 (Position.reset_range (ML_Lex.pos_of tok)); |
79 (Position.reset_range (ML_Lex.pos_of tok)); |
78 in ps ~~ map (String.explode o Symbol.esc) syms end); |
80 in ps ~~ map (String.explode o Symbol.esc) syms end); |
79 |
81 |
80 val input_buffer = ref input; |
82 val end_pos = |
|
83 if null toks then Position.none |
|
84 else ML_Lex.end_pos_of (List.last toks); |
|
85 |
|
86 val input_buffer = ref (input @ [(end_pos, [#"\n"])]); |
81 val line = ref (the_default 1 (Position.line_of pos)); |
87 val line = ref (the_default 1 (Position.line_of pos)); |
82 |
88 |
83 fun get_offset () = |
89 fun get_offset () = |
84 the_default 0 |
90 the_default 0 |
85 (get_first (fn (_, []) => NONE | (p, _) => Position.offset_of p) (! input_buffer)); |
91 (get_first (fn (_, []) => NONE | (p, _) => Position.offset_of p) (! input_buffer)); |
150 val parameters = |
156 val parameters = |
151 [PolyML.Compiler.CPOutStream put, |
157 [PolyML.Compiler.CPOutStream put, |
152 PolyML.Compiler.CPNameSpace space, |
158 PolyML.Compiler.CPNameSpace space, |
153 PolyML.Compiler.CPErrorMessageProc put_message, |
159 PolyML.Compiler.CPErrorMessageProc put_message, |
154 PolyML.Compiler.CPLineNo (fn () => ! line), |
160 PolyML.Compiler.CPLineNo (fn () => ! line), |
|
161 PolyML.Compiler.CPLineOffset get_offset, |
155 PolyML.Compiler.CPFileName location_props, |
162 PolyML.Compiler.CPFileName location_props, |
156 PolyML.Compiler.CPLineOffset get_offset, |
163 PolyML.Compiler.CPCompilerResultFun result_fun, |
157 PolyML.Compiler.CPCompilerResultFun result_fun]; |
164 PolyML.Compiler.CPPrintInAlphabeticalOrder false]; |
158 val _ = |
165 val _ = |
159 (while not (List.null (! input_buffer)) do |
166 (while not (List.null (! input_buffer)) do |
160 PolyML.compiler (get, parameters) ()) |
167 PolyML.compiler (get, parameters) ()) |
161 handle exn => |
168 handle exn => |
162 (put ("Exception- " ^ General.exnMessage exn ^ " raised"); |
169 (put ("Exception- " ^ General.exnMessage exn ^ " raised"); |