236 val termp = term -- Scan.optional ($$$ "(" |-- !!! (is_terms --| $$$ ")")) []; |
236 val termp = term -- Scan.optional ($$$ "(" |-- !!! (is_terms --| $$$ ")")) []; |
237 |
237 |
238 |
238 |
239 (* arguments *) |
239 (* arguments *) |
240 |
240 |
241 val keyword_symid = Scan.one (OuterLex.keyword_pred OuterLex.is_sid) >> OuterLex.val_of; |
241 fun keyword_symid is_symid = Scan.one (OuterLex.keyword_pred is_symid) >> OuterLex.val_of; |
242 |
242 |
243 fun atom_arg blk = |
243 fun atom_arg is_symid blk = |
244 group "argument" |
244 group "argument" |
245 (position (short_ident || long_ident || sym_ident || term_var || text_var || |
245 (position (short_ident || long_ident || sym_ident || term_var || text_var || |
246 type_ident || type_var || number) >> Args.ident || |
246 type_ident || type_var || number) >> Args.ident || |
247 position keyword_symid >> Args.keyword || |
247 position (keyword_symid is_symid) >> Args.keyword || |
248 position string >> Args.string || |
248 position string >> Args.string || |
249 position (if blk then $$$ "," else Scan.fail) >> Args.keyword); |
249 position (if blk then $$$ "," else Scan.fail) >> Args.keyword); |
250 |
250 |
251 fun paren_args l r scan = position ($$$ l) -- !!! (scan true -- position ($$$ r)) |
251 fun paren_args l r scan = position ($$$ l) -- !!! (scan true -- position ($$$ r)) |
252 >> (fn (x, (ys, z)) => Args.keyword x :: ys @ [Args.keyword z]); |
252 >> (fn (x, (ys, z)) => Args.keyword x :: ys @ [Args.keyword z]); |
253 |
253 |
254 fun args blk x = Scan.optional (args1 blk) [] x |
254 fun args is_symid blk x = Scan.optional (args1 is_symid blk) [] x |
255 and args1 blk x = |
255 and args1 is_symid blk x = |
256 ((Scan.repeat1 |
256 ((Scan.repeat1 |
257 (Scan.repeat1 (atom_arg blk) || |
257 (Scan.repeat1 (atom_arg is_symid blk) || |
258 paren_args "(" ")" args || |
258 paren_args "(" ")" (args is_symid) || |
259 paren_args "{" "}" args || |
259 paren_args "{" "}" (args is_symid) || |
260 paren_args "[" "]" args)) >> flat) x; |
260 paren_args "[" "]" (args is_symid))) >> flat) x; |
261 |
261 |
262 |
262 |
263 (* theorem specifications *) |
263 (* theorem specifications *) |
264 |
264 |
265 val attrib = position (xname -- !!! (args false)) >> Args.src; |
265 val attrib = position (xname -- !!! (args OuterLex.is_sid false)) >> Args.src; |
266 val attribs = $$$ "[" |-- !!! (list attrib --| $$$ "]"); |
266 val attribs = $$$ "[" |-- !!! (list attrib --| $$$ "]"); |
267 val opt_attribs = Scan.optional attribs []; |
267 val opt_attribs = Scan.optional attribs []; |
268 |
268 |
269 fun thm_name s = name -- opt_attribs --| $$$ s; |
269 fun thm_name s = name -- opt_attribs --| $$$ s; |
270 fun opt_thm_name s = |
270 fun opt_thm_name s = |
277 val xthms1 = Scan.repeat1 xthm; |
277 val xthms1 = Scan.repeat1 xthm; |
278 |
278 |
279 |
279 |
280 (* proof methods *) |
280 (* proof methods *) |
281 |
281 |
|
282 fun is_symid_meth s = |
|
283 s <> "|" andalso s <> "?" andalso s <> "*" andalso s <> "+" andalso OuterLex.is_sid s; |
|
284 |
282 fun meth4 x = |
285 fun meth4 x = |
283 (position (xname >> rpair []) >> (Method.Source o Args.src) || |
286 (position (xname >> rpair []) >> (Method.Source o Args.src) || |
284 $$$ "(" |-- meth0 --| $$$ ")") x |
287 $$$ "(" |-- !!! (meth0 --| $$$ ")")) x |
285 and meth3 x = |
288 and meth3 x = |
286 (meth4 --| $$$ "?" >> Method.Try || |
289 (meth4 --| $$$ "?" >> Method.Try || |
287 meth4 --| $$$ "*" >> Method.Repeat || |
290 meth4 --| $$$ "*" >> Method.Repeat || |
288 meth4 --| $$$ "+" >> Method.Repeat1 || |
291 meth4 --| $$$ "+" >> Method.Repeat1 || |
289 meth4) x |
292 meth4) x |
290 and meth2 x = |
293 and meth2 x = |
291 (position (xname -- args1 false) >> (Method.Source o Args.src) || |
294 (position (xname -- args1 is_symid_meth false) >> (Method.Source o Args.src) || |
292 meth3) x |
295 meth3) x |
293 and meth1 x = (enum1 "," meth2 >> (fn [m] => m | ms => Method.Then ms)) x |
296 and meth1 x = (enum1 "," meth2 >> (fn [m] => m | ms => Method.Then ms)) x |
294 and meth0 x = (enum1 "|" meth1 >> (fn [m] => m | ms => Method.Orelse ms)) x; |
297 and meth0 x = (enum1 "|" meth1 >> (fn [m] => m | ms => Method.Orelse ms)) x; |
295 |
298 |
296 val method = meth3; |
299 val method = meth3; |