100 NONE => Pretty.str name |
100 NONE => Pretty.str name |
101 | SOME (_, markup) => Pretty.mark_str (markup, name)); |
101 | SOME (_, markup) => Pretty.mark_str (markup, name)); |
102 val prt_thm = Pretty.backquote o Display.pretty_thm ctxt; |
102 val prt_thm = Pretty.backquote o Display.pretty_thm ctxt; |
103 fun prt_arg arg = |
103 fun prt_arg arg = |
104 (case Token.get_value arg of |
104 (case Token.get_value arg of |
105 SOME (v as Token.Literal s) => Pretty.marks_str (Token.value_markup v, s) |
105 SOME (Token.Literal markup) => |
|
106 let val x = Token.content_of arg |
|
107 in Pretty.mark_str (Token.keyword_markup markup x, x) end |
106 | SOME (Token.Text s) => Pretty.str (quote s) |
108 | SOME (Token.Text s) => Pretty.str (quote s) |
107 | SOME (Token.Typ T) => Syntax.pretty_typ ctxt T |
109 | SOME (Token.Typ T) => Syntax.pretty_typ ctxt T |
108 | SOME (Token.Term t) => Syntax.pretty_term ctxt t |
110 | SOME (Token.Term t) => Syntax.pretty_term ctxt t |
109 | SOME (Token.Fact ths) => Pretty.enclose "(" ")" (Pretty.breaks (map prt_thm ths)) |
111 | SOME (Token.Fact ths) => Pretty.enclose "(" ")" (Pretty.breaks (map prt_thm ths)) |
110 | _ => Pretty.mark_str (Token.markup arg, Token.unparse arg)); |
112 | _ => Pretty.mark_str (Token.markup arg, Token.unparse arg)); |
111 in Pretty.block (Pretty.breaks (prt_name :: map prt_arg args)) end; |
113 in Pretty.block (Pretty.breaks (prt_name :: map prt_arg args)) end; |
112 |
114 |
113 |
115 |
114 (* check *) |
116 (* check *) |
115 |
117 |
116 fun check_src ctxt table (Src {name = (xname, pos), args, output_info}) = |
118 fun check_src ctxt table (Src {name = (xname, pos), args, output_info = _}) = |
117 let |
119 let |
118 val (name, x) = Name_Space.check (Context.Proof ctxt) table (xname, pos); |
120 val (name, x) = Name_Space.check (Context.Proof ctxt) table (xname, pos); |
119 val space = Name_Space.space_of_table table; |
121 val space = Name_Space.space_of_table table; |
120 val kind = Name_Space.kind_of space; |
122 val kind = Name_Space.kind_of space; |
121 val markup = Name_Space.markup space name; |
123 val markup = Name_Space.markup space name; |
155 (Parse.short_ident || Parse.long_ident || Parse.sym_ident || Parse.term_var || |
157 (Parse.short_ident || Parse.long_ident || Parse.sym_ident || Parse.term_var || |
156 Parse.type_ident || Parse.type_var || Parse.number); |
158 Parse.type_ident || Parse.type_var || Parse.number); |
157 |
159 |
158 val string = token (Parse.string || Parse.verbatim); |
160 val string = token (Parse.string || Parse.verbatim); |
159 val alt_string = token Parse.alt_string; |
161 val alt_string = token Parse.alt_string; |
160 val symbolic = token Parse.keyword_ident_or_symbolic; |
162 val symbolic = token (Parse.keyword_with Token.ident_or_symbolic); |
161 |
163 |
162 fun $$$ x = |
164 fun $$$ x = |
163 (ident || token Parse.keyword) :|-- (fn tok => |
165 (ident || token Parse.keyword) :|-- (fn tok => |
164 let val y = Token.content_of tok |
166 let val y = Token.content_of tok in |
165 in if x = y then (Token.assign (SOME (Token.Literal x)) tok; Scan.succeed x) else Scan.fail end); |
167 if x = y |
|
168 then (Token.assign (SOME (Token.Literal Markup.quasi_keyword)) tok; Scan.succeed x) |
|
169 else Scan.fail |
|
170 end); |
166 |
171 |
167 |
172 |
168 val named = ident || string; |
173 val named = ident || string; |
169 |
174 |
170 val add = $$$ "add"; |
175 val add = $$$ "add"; |
315 fun syntax_generic scan (Src {name = (name, pos), args = args0, output_info}) context = |
320 fun syntax_generic scan (Src {name = (name, pos), args = args0, output_info}) context = |
316 let |
321 let |
317 val args1 = map Token.init_assignable args0; |
322 val args1 = map Token.init_assignable args0; |
318 fun reported_text () = |
323 fun reported_text () = |
319 if Context_Position.is_visible_generic context then |
324 if Context_Position.is_visible_generic context then |
320 maps (Token.reports_of_value o Token.closure) args1 |
325 ((pos, Markup.operator) :: maps (Token.reports_of_value o Token.closure) args1) |
321 |> map (fn (p, m) => Position.reported_text p m "") |
326 |> map (fn (p, m) => Position.reported_text p m "") |
322 |> implode |
327 |> implode |
323 else ""; |
328 else ""; |
324 in |
329 in |
325 (case Scan.error (Scan.finite' Token.stopper (Scan.option scan)) (context, args1) of |
330 (case Scan.error (Scan.finite' Token.stopper (Scan.option scan)) (context, args1) of |