87 val const_proper: Context.generic * T list -> string * (Context.generic * T list) |
87 val const_proper: Context.generic * T list -> string * (Context.generic * T list) |
88 val thm_sel: T list -> Facts.interval list * T list |
88 val thm_sel: T list -> Facts.interval list * T list |
89 val bang_facts: Context.generic * T list -> thm list * (Context.generic * T list) |
89 val bang_facts: Context.generic * T list -> thm list * (Context.generic * T list) |
90 val goal_spec: ((int -> tactic) -> tactic) -> ('a * T list) |
90 val goal_spec: ((int -> tactic) -> tactic) -> ('a * T list) |
91 -> ((int -> tactic) -> tactic) * ('a * T list) |
91 -> ((int -> tactic) -> tactic) * ('a * T list) |
|
92 val generic_args1: (string -> bool) -> T list -> T list * T list |
92 val attribs: (string -> string) -> T list -> src list * T list |
93 val attribs: (string -> string) -> T list -> src list * T list |
93 val opt_attribs: (string -> string) -> T list -> src list * T list |
94 val opt_attribs: (string -> string) -> T list -> src list * T list |
94 val thm_name: (string -> string) -> string -> T list -> (string * src list) * T list |
95 val thm_name: (string -> string) -> string -> T list -> (string * src list) * T list |
95 val opt_thm_name: (string -> string) -> string -> T list -> (string * src list) * T list |
96 val opt_thm_name: (string -> string) -> string -> T list -> (string * src list) * T list |
96 val syntax: string -> ('b * T list -> 'a * ('b * T list)) -> src -> 'b -> 'a * 'b |
97 val syntax: string -> ('b * T list -> 'a * ('b * T list)) -> src -> 'b -> 'a * 'b |
364 Assumption.prems_of (Context.proof_of context))) || Scan.succeed []); |
365 Assumption.prems_of (Context.proof_of context))) || Scan.succeed []); |
365 |
366 |
366 |
367 |
367 (* goal specification *) |
368 (* goal specification *) |
368 |
369 |
369 (* range *) |
|
370 |
|
371 val from_to = |
370 val from_to = |
372 nat -- ($$$ "-" |-- nat) >> (fn (i, j) => fn tac => Seq.INTERVAL tac i j) || |
371 nat -- ($$$ "-" |-- nat) >> (fn (i, j) => fn tac => Seq.INTERVAL tac i j) || |
373 nat --| $$$ "-" >> (fn i => fn tac => fn st => Seq.INTERVAL tac i (Thm.nprems_of st) st) || |
372 nat --| $$$ "-" >> (fn i => fn tac => fn st => Seq.INTERVAL tac i (Thm.nprems_of st) st) || |
374 nat >> (fn i => fn tac => tac i) || |
373 nat >> (fn i => fn tac => tac i) || |
375 $$$ "!" >> K ALLGOALS; |
374 $$$ "!" >> K ALLGOALS; |
376 |
375 |
377 val goal = $$$ "[" |-- !!! (from_to --| $$$ "]"); |
376 val goal = $$$ "[" |-- !!! (from_to --| $$$ "]"); |
378 fun goal_spec def = Scan.lift (Scan.optional goal def); |
377 fun goal_spec def = Scan.lift (Scan.optional goal def); |
379 |
378 |
380 |
379 |
381 |
380 (* nested args and attribs *) |
382 (* attribs *) |
|
383 |
381 |
384 local |
382 local |
385 |
383 |
386 val exclude = member (op =) (explode "()[],"); |
384 fun parse_args is_symid = |
387 |
385 let |
388 fun atomic blk = touch (Scan.one (fn Arg ((k, x, _), _) => |
386 fun atom blk = touch (Scan.one (fn Arg ((k, x, _), _) => |
389 k <> Keyword orelse not (exclude x) orelse blk andalso x = ",")); |
387 k <> Keyword orelse is_symid x orelse blk andalso x = ",")); |
390 |
388 |
391 fun args blk x = Scan.optional (args1 blk) [] x |
389 fun args blk x = Scan.optional (args1 blk) [] x |
392 and args1 blk x = |
390 and args1 blk x = |
393 ((Scan.repeat1 |
391 ((Scan.repeat1 |
394 (Scan.repeat1 (atomic blk) || |
392 (Scan.repeat1 (atom blk) || |
395 argsp "(" ")" || |
393 argsp "(" ")" || |
396 argsp "[" "]")) >> flat) x |
394 argsp "[" "]")) >> flat) x |
397 and argsp l r x = |
395 and argsp l r x = |
398 (Scan.trace (&&& l -- !!! (args true -- &&& r)) >> #2) x; |
396 (Scan.trace (&&& l -- !!! (args true -- &&& r)) >> #2) x; |
|
397 in (args, args1) end; |
399 |
398 |
400 in |
399 in |
|
400 |
|
401 fun generic_args1 is_symid = #2 (parse_args is_symid) false; |
|
402 val arguments = #1 (parse_args OuterLex.is_sid) false; |
401 |
403 |
402 fun attribs intern = |
404 fun attribs intern = |
403 let |
405 let |
404 val attrib_name = internal_text || (symbolic || named) >> evaluate Text intern; |
406 val attrib_name = internal_text || (symbolic || named) >> evaluate Text intern; |
405 val attrib = position (attrib_name -- !!! (args false)) >> src; |
407 val attrib = position (attrib_name -- !!! arguments) >> src; |
406 in $$$ "[" |-- !!! (list attrib --| $$$ "]") end; |
408 in $$$ "[" |-- !!! (list attrib --| $$$ "]") end; |
407 |
409 |
408 fun opt_attribs intern = Scan.optional (attribs intern) []; |
410 fun opt_attribs intern = Scan.optional (attribs intern) []; |
409 |
411 |
410 end; |
412 end; |
415 fun thm_name intern s = name -- opt_attribs intern --| $$$ s; |
417 fun thm_name intern s = name -- opt_attribs intern --| $$$ s; |
416 fun opt_thm_name intern s = |
418 fun opt_thm_name intern s = |
417 Scan.optional ((name -- opt_attribs intern || attribs intern >> pair "") --| $$$ s) ("", []); |
419 Scan.optional ((name -- opt_attribs intern || attribs intern >> pair "") --| $$$ s) ("", []); |
418 |
420 |
419 |
421 |
420 (* syntax interface *) |
422 |
|
423 |
|
424 (** syntax wrapper **) |
421 |
425 |
422 fun syntax kind scan (src as Src ((s, args), pos)) st = |
426 fun syntax kind scan (src as Src ((s, args), pos)) st = |
423 (case Scan.error (Scan.finite' stopper (Scan.option scan)) (st, args) of |
427 (case Scan.error (Scan.finite' stopper (Scan.option scan)) (st, args) of |
424 (SOME x, (st', [])) => (x, st') |
428 (SOME x, (st', [])) => (x, st') |
425 | (_, (_, args')) => |
429 | (_, (_, args')) => |