13 let |
13 let |
14 val {file = text, startLine = line, startPosition = offset, |
14 val {file = text, startLine = line, startPosition = offset, |
15 endLine = _, endPosition = end_offset} = loc; |
15 endLine = _, endPosition = end_offset} = loc; |
16 val props = |
16 val props = |
17 (case YXML.parse text of |
17 (case YXML.parse text of |
18 XML.Elem ((e, atts), _) => if e = Markup.positionN then atts else [] |
18 XML.Elem ((e, atts), _) => if e = Isabelle_Markup.positionN then atts else [] |
19 | XML.Text s => Position.file_name s); |
19 | XML.Text s => Position.file_name s); |
20 in |
20 in |
21 Position.make {line = line, offset = offset, end_offset = end_offset, props = props} |
21 Position.make {line = line, offset = offset, end_offset = end_offset, props = props} |
22 end; |
22 end; |
23 |
23 |
39 SOME (Context.Proof ctxt) => Context_Position.reported_text ctxt |
39 SOME (Context.Proof ctxt) => Context_Position.reported_text ctxt |
40 | _ => Position.reported_text); |
40 | _ => Position.reported_text); |
41 |
41 |
42 fun reported_entity kind loc decl = |
42 fun reported_entity kind loc decl = |
43 reported_text (position_of loc) |
43 reported_text (position_of loc) |
44 (Markup.entityN, (Markup.kindN, kind) :: Position.def_properties_of (position_of decl)) ""; |
44 (Isabelle_Markup.entityN, |
|
45 (Markup.kindN, kind) :: Position.def_properties_of (position_of decl)) ""; |
45 |
46 |
46 fun reported loc (PolyML.PTtype types) = |
47 fun reported loc (PolyML.PTtype types) = |
47 cons |
48 cons |
48 (PolyML.NameSpace.displayTypeExpression (types, depth, space) |
49 (PolyML.NameSpace.displayTypeExpression (types, depth, space) |
49 |> pretty_ml |> Pretty.from_ML |> Pretty.string_of |
50 |> pretty_ml |> Pretty.from_ML |> Pretty.string_of |
50 |> reported_text (position_of loc) Markup.ML_typing) |
51 |> reported_text (position_of loc) Isabelle_Markup.ML_typing) |
51 | reported loc (PolyML.PTdeclaredAt decl) = |
52 | reported loc (PolyML.PTdeclaredAt decl) = |
52 cons (reported_entity Markup.ML_defN loc decl) |
53 cons (reported_entity Isabelle_Markup.ML_defN loc decl) |
53 | reported loc (PolyML.PTopenedAt decl) = |
54 | reported loc (PolyML.PTopenedAt decl) = |
54 cons (reported_entity Markup.ML_openN loc decl) |
55 cons (reported_entity Isabelle_Markup.ML_openN loc decl) |
55 | reported loc (PolyML.PTstructureAt decl) = |
56 | reported loc (PolyML.PTstructureAt decl) = |
56 cons (reported_entity Markup.ML_structN loc decl) |
57 cons (reported_entity Isabelle_Markup.ML_structN loc decl) |
57 | reported _ (PolyML.PTnextSibling tree) = reported_tree (tree ()) |
58 | reported _ (PolyML.PTnextSibling tree) = reported_tree (tree ()) |
58 | reported _ (PolyML.PTfirstChild tree) = reported_tree (tree ()) |
59 | reported _ (PolyML.PTfirstChild tree) = reported_tree (tree ()) |
59 | reported _ _ = I |
60 | reported _ _ = I |
60 and reported_tree (loc, props) = fold (reported loc) props; |
61 and reported_tree (loc, props) = fold (reported loc) props; |
61 in fn tree => Output.report (implode (reported_tree tree [])) end; |
62 in fn tree => Output.report (implode (reported_tree tree [])) end; |
70 |
71 |
71 |
72 |
72 (* input *) |
73 (* input *) |
73 |
74 |
74 val location_props = |
75 val location_props = |
75 op ^ (YXML.output_markup (Markup.position |> Markup.properties |
76 op ^ (YXML.output_markup (Isabelle_Markup.position |> Markup.properties |
76 (filter (member (op =) [Markup.idN, Markup.fileN] o #1) (Position.properties_of pos)))); |
77 (filter (member (op =) |
|
78 [Isabelle_Markup.idN, Isabelle_Markup.fileN] o #1) (Position.properties_of pos)))); |
77 |
79 |
78 val input_buffer = |
80 val input_buffer = |
79 Unsynchronized.ref (toks |> map |
81 Unsynchronized.ref (toks |> map |
80 (`(maps (String.explode o Symbol.esc) o Symbol.explode o ML_Lex.check_content_of))); |
82 (`(maps (String.explode o Symbol.esc) o Symbol.explode o ML_Lex.check_content_of))); |
81 |
83 |
109 |
111 |
110 fun message {message = msg, hard, location = loc, context = _} = |
112 fun message {message = msg, hard, location = loc, context = _} = |
111 let |
113 let |
112 val pos = position_of loc; |
114 val pos = position_of loc; |
113 val txt = |
115 val txt = |
114 (Position.is_reported pos ? Markup.markup Markup.no_report) |
116 (Position.is_reported pos ? Markup.markup Isabelle_Markup.no_report) |
115 ((if hard then "Error" else "Warning") ^ Position.str_of pos ^ ":\n") ^ |
117 ((if hard then "Error" else "Warning") ^ Position.str_of pos ^ ":\n") ^ |
116 Pretty.string_of (Pretty.from_ML (pretty_ml msg)) ^ |
118 Pretty.string_of (Pretty.from_ML (pretty_ml msg)) ^ |
117 Position.reported_text pos Markup.report ""; |
119 Position.reported_text pos Isabelle_Markup.report ""; |
118 in if hard then err txt else warn txt end; |
120 in if hard then err txt else warn txt end; |
119 |
121 |
120 |
122 |
121 (* results *) |
123 (* results *) |
122 |
124 |