33 val context' = context |
33 val context' = context |
34 |> Extra_Env.map (fold (fn (i, tok) => Inttab.update (i, ML_Lex.pos_of tok)) regs); |
34 |> Extra_Env.map (fold (fn (i, tok) => Inttab.update (i, ML_Lex.pos_of tok)) regs); |
35 in (regs, context') end; |
35 in (regs, context') end; |
36 |
36 |
37 fun position_of ctxt |
37 fun position_of ctxt |
38 ({file, startLine = line, startPosition = i, endPosition = j, ...}: location) = |
38 ({file, startLine = line, startPosition = i, endPosition = j, ...}: PolyML.location) = |
39 (case pairself (Inttab.lookup (Extra_Env.get (Context.Proof ctxt))) (i, j) of |
39 (case pairself (Inttab.lookup (Extra_Env.get (Context.Proof ctxt))) (i, j) of |
40 (SOME pos1, SOME pos2) => Position.encode_range (pos1, pos2) |
40 (SOME pos1, SOME pos2) => Position.encode_range (pos1, pos2) |
41 | (SOME pos, NONE) => pos |
41 | (SOME pos, NONE) => pos |
42 | _ => Position.line_file line file); |
42 | _ => Position.line_file line file); |
43 |
43 |
45 (* parse trees *) |
45 (* parse trees *) |
46 |
46 |
47 fun report_parse_tree context depth space = |
47 fun report_parse_tree context depth space = |
48 let |
48 let |
49 val pos_of = position_of (Context.proof_of context); |
49 val pos_of = position_of (Context.proof_of context); |
50 fun report loc (PTtype types) = |
50 fun report loc (PolyML.PTtype types) = |
51 PolyML.NameSpace.displayTypeExpression (types, depth, space) |
51 PolyML.NameSpace.displayTypeExpression (types, depth, space) |
52 |> pretty_ml |> Pretty.from_ML |> Pretty.string_of |
52 |> pretty_ml |> Pretty.from_ML |> Pretty.string_of |
53 |> Position.report_text Markup.ML_typing (pos_of loc) |
53 |> Position.report_text Markup.ML_typing (pos_of loc) |
54 | report loc (PTdeclaredAt decl) = |
54 | report loc (PolyML.PTdeclaredAt decl) = |
55 Markup.markup (Markup.properties (Position.properties_of (pos_of decl)) Markup.ML_def) "" |
55 Markup.markup (Markup.properties (Position.properties_of (pos_of decl)) Markup.ML_def) "" |
56 |> Position.report_text Markup.ML_ref (pos_of loc) |
56 |> Position.report_text Markup.ML_ref (pos_of loc) |
57 | report _ (PTnextSibling tree) = report_tree (tree ()) |
57 | report _ (PolyML.PTnextSibling tree) = report_tree (tree ()) |
58 | report _ (PTfirstChild tree) = report_tree (tree ()) |
58 | report _ (PolyML.PTfirstChild tree) = report_tree (tree ()) |
59 | report _ _ = () |
59 | report _ _ = () |
60 and report_tree (loc, props) = List.app (report loc) props; |
60 and report_tree (loc, props) = List.app (report loc) props; |
61 in report_tree end; |
61 in report_tree end; |
62 |
62 |
63 |
63 |