equal
deleted
inserted
replaced
203 |
203 |
204 local |
204 local |
205 |
205 |
206 val keywords = Keyword.add_minor_keywords ["for", "=>"] Keyword.empty_keywords; |
206 val keywords = Keyword.add_minor_keywords ["for", "=>"] Keyword.empty_keywords; |
207 |
207 |
208 val parse_name = Parse.input Parse.name; |
208 val parse_name_args = |
209 |
209 Parse.input Parse.name -- Scan.repeat Parse.embedded_ml; |
210 val parse_args = Scan.repeat Parse.embedded_ml; |
210 |
211 val parse_for_args = Scan.optional (Parse.$$$ "for" |-- Parse.!!! parse_args) []; |
211 val parse_for_args = |
|
212 Scan.optional (Parse.$$$ "for" |-- Parse.!!! (Scan.repeat1 Parse.embedded_ml)) []; |
212 |
213 |
213 fun parse_body b = |
214 fun parse_body b = |
214 if b then Parse.$$$ "=>" |-- Parse.!!! Parse.embedded_input >> (ML_Lex.read_source #> single) |
215 if b then Parse.$$$ "=>" |-- Parse.!!! (Parse.embedded_ml >> single) else Scan.succeed []; |
215 else Scan.succeed []; |
|
216 |
216 |
217 fun is_dummy [Antiquote.Text tok] = ML_Lex.content_of tok = "_" |
217 fun is_dummy [Antiquote.Text tok] = ML_Lex.content_of tok = "_" |
218 | is_dummy _ = false; |
218 | is_dummy _ = false; |
219 |
219 |
220 val ml = ML_Lex.tokenize_no_range; |
220 val ml = ML_Lex.tokenize_no_range; |
231 fun type_antiquotation binding {function} = |
231 fun type_antiquotation binding {function} = |
232 ML_Context.add_antiquotation binding true |
232 ML_Context.add_antiquotation binding true |
233 (fn range => fn src => fn ctxt => |
233 (fn range => fn src => fn ctxt => |
234 let |
234 let |
235 val ((s, type_args), fn_body) = src |
235 val ((s, type_args), fn_body) = src |
236 |> Parse.read_embedded_src ctxt keywords (parse_name -- parse_args -- parse_body function); |
236 |> Parse.read_embedded_src ctxt keywords (parse_name_args -- parse_body function); |
237 val pos = Input.pos_of s; |
237 val pos = Input.pos_of s; |
238 |
238 |
239 val Type (c, Ts) = |
239 val Type (c, Ts) = |
240 Proof_Context.read_type_name {proper = true, strict = true} ctxt |
240 Proof_Context.read_type_name {proper = true, strict = true} ctxt |
241 (Syntax.implode_input s); |
241 (Syntax.implode_input s); |
267 ML_Context.add_antiquotation binding true |
267 ML_Context.add_antiquotation binding true |
268 (fn range => fn src => fn ctxt => |
268 (fn range => fn src => fn ctxt => |
269 let |
269 let |
270 val (((s, type_args), term_args), fn_body) = src |
270 val (((s, type_args), term_args), fn_body) = src |
271 |> Parse.read_embedded_src ctxt keywords |
271 |> Parse.read_embedded_src ctxt keywords |
272 (parse_name -- parse_args -- parse_for_args -- parse_body function); |
272 (parse_name_args -- parse_for_args -- parse_body function); |
273 |
273 |
274 val Const (c, T) = |
274 val Const (c, T) = |
275 Proof_Context.read_const {proper = true, strict = true} ctxt |
275 Proof_Context.read_const {proper = true, strict = true} ctxt |
276 (Syntax.implode_input s); |
276 (Syntax.implode_input s); |
277 |
277 |