src/Pure/Isar/args.ML
author wenzelm
Thu, 06 Jun 2024 12:42:42 +0200
changeset 80267 ea908185a597
parent 78085 dd7bb7f99ad5
permissions -rw-r--r--
more operations;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5822
3f824514ad88 Concrete argument syntax (for attributes, methods etc.).
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Isar/args.ML
3f824514ad88 Concrete argument syntax (for attributes, methods etc.).
wenzelm
parents:
diff changeset
     2
    Author:     Markus Wenzel, TU Muenchen
3f824514ad88 Concrete argument syntax (for attributes, methods etc.).
wenzelm
parents:
diff changeset
     3
58011
bc6bced136e5 tuned signature -- moved type src to Token, without aliases;
wenzelm
parents: 57944
diff changeset
     4
Quasi-inner syntax based on outer tokens: concrete argument syntax of
27811
44bc67675210 unified Args.T with OuterLex.token;
wenzelm
parents: 27732
diff changeset
     5
attributes, methods etc.
5822
3f824514ad88 Concrete argument syntax (for attributes, methods etc.).
wenzelm
parents:
diff changeset
     6
*)
3f824514ad88 Concrete argument syntax (for attributes, methods etc.).
wenzelm
parents:
diff changeset
     7
3f824514ad88 Concrete argument syntax (for attributes, methods etc.).
wenzelm
parents:
diff changeset
     8
signature ARGS =
3f824514ad88 Concrete argument syntax (for attributes, methods etc.).
wenzelm
parents:
diff changeset
     9
sig
30513
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    10
  val context: Proof.context context_parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    11
  val theory: theory context_parser
61814
1ca1142e1711 clarified type Token.src: plain token list, with usual implicit value assignment;
wenzelm
parents: 60577
diff changeset
    12
  val symbolic: Token.T parser
30513
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    13
  val $$$ : string -> string parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    14
  val add: string parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    15
  val del: string parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    16
  val colon: string parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    17
  val query: string parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    18
  val bang: string parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    19
  val query_colon: string parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    20
  val bang_colon: string parser
53168
d998de7f0efc tuned signature;
wenzelm
parents: 53113
diff changeset
    21
  val parens: 'a parser -> 'a parser
d998de7f0efc tuned signature;
wenzelm
parents: 53113
diff changeset
    22
  val bracks: 'a parser -> 'a parser
d998de7f0efc tuned signature;
wenzelm
parents: 53113
diff changeset
    23
  val mode: string -> bool parser
30513
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    24
  val maybe: 'a parser -> 'a option parser
60577
4c9401fbbdf7 tuned signature;
wenzelm
parents: 59857
diff changeset
    25
  val name_token: Token.T parser
4c9401fbbdf7 tuned signature;
wenzelm
parents: 59857
diff changeset
    26
  val name: string parser
69349
7cef9e386ffe more accurate positions for "name" (quoted string) and "embedded" (cartouche): refer to content without delimiters, which is e.g. relevant for systematic selection/renaming of scope groups;
wenzelm
parents: 63120
diff changeset
    27
  val name_position: (string * Position.T) parser
55111
5792f5106c40 tuned signature;
wenzelm
parents: 55045
diff changeset
    28
  val cartouche_inner_syntax: string parser
59809
87641097d0f3 tuned signature;
wenzelm
parents: 59666
diff changeset
    29
  val cartouche_input: Input.source parser
30513
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    30
  val binding: binding parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    31
  val alt_name: string parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    32
  val liberal_name: string parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    33
  val var: indexname parser
58012
0b0519c41229 support for nested Token.src within Token.T;
wenzelm
parents: 58011
diff changeset
    34
  val internal_source: Token.src parser
61814
1ca1142e1711 clarified type Token.src: plain token list, with usual implicit value assignment;
wenzelm
parents: 60577
diff changeset
    35
  val internal_name: Token.name_value parser
30513
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    36
  val internal_typ: typ parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    37
  val internal_term: term parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    38
  val internal_fact: thm list parser
78072
001739cb8d08 clarified signature: more explicit types;
wenzelm
parents: 74887
diff changeset
    39
  val internal_attribute: attribute Morphism.entity parser
78085
dd7bb7f99ad5 tuned signature;
wenzelm
parents: 78072
diff changeset
    40
  val internal_declaration: Morphism.declaration_entity parser
58012
0b0519c41229 support for nested Token.src within Token.T;
wenzelm
parents: 58011
diff changeset
    41
  val named_source: (Token.T -> Token.src) -> Token.src parser
30513
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    42
  val named_typ: (string -> typ) -> typ parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    43
  val named_term: (string -> term) -> term parser
57942
e5bec882fdd0 more informative Token.Fact: retain name of dynamic fact (without selection);
wenzelm
parents: 56500
diff changeset
    44
  val named_fact: (string -> string option * thm list) -> thm list parser
78072
001739cb8d08 clarified signature: more explicit types;
wenzelm
parents: 74887
diff changeset
    45
  val named_attribute: (string * Position.T -> attribute Morphism.entity) ->
001739cb8d08 clarified signature: more explicit types;
wenzelm
parents: 74887
diff changeset
    46
    attribute Morphism.entity parser
78085
dd7bb7f99ad5 tuned signature;
wenzelm
parents: 78072
diff changeset
    47
  val embedded_declaration: (Input.source -> Morphism.declaration_entity) ->
dd7bb7f99ad5 tuned signature;
wenzelm
parents: 78072
diff changeset
    48
    Morphism.declaration_entity parser
30513
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    49
  val typ_abbrev: typ context_parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    50
  val typ: typ context_parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    51
  val term: term context_parser
55155
a1affe3eb3fd tuned signature;
wenzelm
parents: 55111
diff changeset
    52
  val term_pattern: term context_parser
30513
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    53
  val term_abbrev: term context_parser
1796b8ea88aa eliminated type Args.T;
wenzelm
parents: 30473
diff changeset
    54
  val prop: term context_parser
55951
c07d184aebe9 tuned signature -- more uniform check_type_name/read_type_name;
wenzelm
parents: 55915
diff changeset
    55
  val type_name: {proper: bool, strict: bool} -> string context_parser
55954
a29aefc88c8d more uniform check_const/read_const;
wenzelm
parents: 55951
diff changeset
    56
  val const: {proper: bool, strict: bool} -> string context_parser
30514
9455ecc7796d simplified goal_spec: default to first goal;
wenzelm
parents: 30513
diff changeset
    57
  val goal_spec: ((int -> tactic) -> tactic) context_parser
5822
3f824514ad88 Concrete argument syntax (for attributes, methods etc.).
wenzelm
parents:
diff changeset
    58
end;
3f824514ad88 Concrete argument syntax (for attributes, methods etc.).
wenzelm
parents:
diff changeset
    59
3f824514ad88 Concrete argument syntax (for attributes, methods etc.).
wenzelm
parents:
diff changeset
    60
structure Args: ARGS =
3f824514ad88 Concrete argument syntax (for attributes, methods etc.).
wenzelm
parents:
diff changeset
    61
struct
3f824514ad88 Concrete argument syntax (for attributes, methods etc.).
wenzelm
parents:
diff changeset
    62
27811
44bc67675210 unified Args.T with OuterLex.token;
wenzelm
parents: 27732
diff changeset
    63
(** argument scanners **)
5822
3f824514ad88 Concrete argument syntax (for attributes, methods etc.).
wenzelm
parents:
diff changeset
    64
27371
f89aa7bd4602 added context/theory scanner;
wenzelm
parents: 27234
diff changeset
    65
(* context *)
f89aa7bd4602 added context/theory scanner;
wenzelm
parents: 27234
diff changeset
    66
f89aa7bd4602 added context/theory scanner;
wenzelm
parents: 27234
diff changeset
    67
fun context x = (Scan.state >> Context.proof_of) x;
f89aa7bd4602 added context/theory scanner;
wenzelm
parents: 27234
diff changeset
    68
fun theory x = (Scan.state >> Context.theory_of) x;
f89aa7bd4602 added context/theory scanner;
wenzelm
parents: 27234
diff changeset
    69
f89aa7bd4602 added context/theory scanner;
wenzelm
parents: 27234
diff changeset
    70
27811
44bc67675210 unified Args.T with OuterLex.token;
wenzelm
parents: 27732
diff changeset
    71
(* basic *)
5878
769abc29bb8e several args parsers;
wenzelm
parents: 5822
diff changeset
    72
56201
dd2df97b379b tuned signature;
wenzelm
parents: 56200
diff changeset
    73
val ident = Parse.token
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36505
diff changeset
    74
  (Parse.short_ident || Parse.long_ident || Parse.sym_ident || Parse.term_var ||
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36505
diff changeset
    75
    Parse.type_ident || Parse.type_var || Parse.number);
5878
769abc29bb8e several args parsers;
wenzelm
parents: 5822
diff changeset
    76
56500
90f17a04567d proper Args.name vs. Args.text as documented (in contrast to adhoc union in 75aaee32893d, which had to cope with more limited Args.T);
wenzelm
parents: 56499
diff changeset
    77
val string = Parse.token Parse.string;
56499
7e0178c84994 allow text cartouches in regular outer syntax categories "text" and "altstring";
wenzelm
parents: 56333
diff changeset
    78
val alt_string = Parse.token (Parse.alt_string || Parse.cartouche);
56201
dd2df97b379b tuned signature;
wenzelm
parents: 56200
diff changeset
    79
val symbolic = Parse.token (Parse.keyword_with Token.ident_or_symbolic);
27811
44bc67675210 unified Args.T with OuterLex.token;
wenzelm
parents: 27732
diff changeset
    80
55914
c5b752d549e3 clarified init_assignable: make double-sure that initial values are reset;
wenzelm
parents: 55828
diff changeset
    81
fun $$$ x =
56201
dd2df97b379b tuned signature;
wenzelm
parents: 56200
diff changeset
    82
  (ident || Parse.token Parse.keyword) :|-- (fn tok =>
56063
38f13d055107 more explicit markup for Token.Literal;
wenzelm
parents: 56038
diff changeset
    83
    let val y = Token.content_of tok in
38f13d055107 more explicit markup for Token.Literal;
wenzelm
parents: 56038
diff changeset
    84
      if x = y
56202
0a11d17eeeff more markup for improper elements;
wenzelm
parents: 56201
diff changeset
    85
      then (Token.assign (SOME (Token.Literal (false, Markup.quasi_keyword))) tok; Scan.succeed x)
56063
38f13d055107 more explicit markup for Token.Literal;
wenzelm
parents: 56038
diff changeset
    86
      else Scan.fail
38f13d055107 more explicit markup for Token.Literal;
wenzelm
parents: 56038
diff changeset
    87
    end);
5878
769abc29bb8e several args parsers;
wenzelm
parents: 5822
diff changeset
    88
10035
c095955e7575 added common args keywords;
wenzelm
parents: 9952
diff changeset
    89
val add = $$$ "add";
c095955e7575 added common args keywords;
wenzelm
parents: 9952
diff changeset
    90
val del = $$$ "del";
8803
wenzelm
parents: 8687
diff changeset
    91
val colon = $$$ ":";
10035
c095955e7575 added common args keywords;
wenzelm
parents: 9952
diff changeset
    92
val query = $$$ "?";
c095955e7575 added common args keywords;
wenzelm
parents: 9952
diff changeset
    93
val bang = $$$ "!";
20111
ba1676dd3546 query/bang_colon: separate tokens;
wenzelm
parents: 19482
diff changeset
    94
val query_colon = $$$ "?" ^^ $$$ ":";
ba1676dd3546 query/bang_colon: separate tokens;
wenzelm
parents: 19482
diff changeset
    95
val bang_colon = $$$ "!" ^^ $$$ ":";
10035
c095955e7575 added common args keywords;
wenzelm
parents: 9952
diff changeset
    96
8803
wenzelm
parents: 8687
diff changeset
    97
fun parens scan = $$$ "(" |-- scan --| $$$ ")";
10150
a068c666c53e added "bracks";
wenzelm
parents: 10035
diff changeset
    98
fun bracks scan = $$$ "[" |-- scan --| $$$ "]";
53168
d998de7f0efc tuned signature;
wenzelm
parents: 53113
diff changeset
    99
fun mode s = Scan.optional (parens ($$$ s) >> K true) false;
15703
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 15596
diff changeset
   100
fun maybe scan = $$$ "_" >> K NONE || scan >> SOME;
5878
769abc29bb8e several args parsers;
wenzelm
parents: 5822
diff changeset
   101
60577
4c9401fbbdf7 tuned signature;
wenzelm
parents: 59857
diff changeset
   102
val name_token = ident || string;
4c9401fbbdf7 tuned signature;
wenzelm
parents: 59857
diff changeset
   103
val name = name_token >> Token.content_of;
69349
7cef9e386ffe more accurate positions for "name" (quoted string) and "embedded" (cartouche): refer to content without delimiters, which is e.g. relevant for systematic selection/renaming of scope groups;
wenzelm
parents: 63120
diff changeset
   104
val name_position = name_token >> (Input.source_content o Token.input_of);
60577
4c9401fbbdf7 tuned signature;
wenzelm
parents: 59857
diff changeset
   105
56201
dd2df97b379b tuned signature;
wenzelm
parents: 56200
diff changeset
   106
val cartouche = Parse.token Parse.cartouche;
55111
5792f5106c40 tuned signature;
wenzelm
parents: 55045
diff changeset
   107
val cartouche_inner_syntax = cartouche >> Token.inner_syntax_of;
59809
87641097d0f3 tuned signature;
wenzelm
parents: 59666
diff changeset
   108
val cartouche_input = cartouche >> Token.input_of;
55045
99056d23e05b cartouche within nested args (attributes, methods, etc.);
wenzelm
parents: 55033
diff changeset
   109
69349
7cef9e386ffe more accurate positions for "name" (quoted string) and "embedded" (cartouche): refer to content without delimiters, which is e.g. relevant for systematic selection/renaming of scope groups;
wenzelm
parents: 63120
diff changeset
   110
val binding = Parse.input name >> (Binding.make o Input.source_content);
36959
f5417836dbea renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
wenzelm
parents: 36950
diff changeset
   111
val alt_name = alt_string >> Token.content_of;
61814
1ca1142e1711 clarified type Token.src: plain token list, with usual implicit value assignment;
wenzelm
parents: 60577
diff changeset
   112
val liberal_name = (symbolic >> Token.content_of) || name;
8233
85169951d515 attrib: keyword_symid;
wenzelm
parents: 8089
diff changeset
   113
63120
629a4c5e953e embedded content may be delimited via cartouches;
wenzelm
parents: 61814
diff changeset
   114
val var =
629a4c5e953e embedded content may be delimited via cartouches;
wenzelm
parents: 61814
diff changeset
   115
  (ident >> Token.content_of) :|-- (fn x =>
629a4c5e953e embedded content may be delimited via cartouches;
wenzelm
parents: 61814
diff changeset
   116
    (case Lexicon.read_variable x of SOME v => Scan.succeed v | NONE => Scan.fail));
5878
769abc29bb8e several args parsers;
wenzelm
parents: 5822
diff changeset
   117
5822
3f824514ad88 Concrete argument syntax (for attributes, methods etc.).
wenzelm
parents:
diff changeset
   118
15703
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 15596
diff changeset
   119
(* values *)
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 15596
diff changeset
   120
27811
44bc67675210 unified Args.T with OuterLex.token;
wenzelm
parents: 27732
diff changeset
   121
fun value dest = Scan.some (fn arg =>
36959
f5417836dbea renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
wenzelm
parents: 36950
diff changeset
   122
  (case Token.get_value arg of SOME v => (SOME (dest v) handle Match => NONE) | NONE => NONE));
15703
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 15596
diff changeset
   123
58012
0b0519c41229 support for nested Token.src within Token.T;
wenzelm
parents: 58011
diff changeset
   124
val internal_source = value (fn Token.Source src => src);
61814
1ca1142e1711 clarified type Token.src: plain token list, with usual implicit value assignment;
wenzelm
parents: 60577
diff changeset
   125
val internal_name = value (fn Token.Name (a, _) => a);
36959
f5417836dbea renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
wenzelm
parents: 36950
diff changeset
   126
val internal_typ = value (fn Token.Typ T => T);
f5417836dbea renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
wenzelm
parents: 36950
diff changeset
   127
val internal_term = value (fn Token.Term t => t);
57942
e5bec882fdd0 more informative Token.Fact: retain name of dynamic fact (without selection);
wenzelm
parents: 56500
diff changeset
   128
val internal_fact = value (fn Token.Fact (_, ths) => ths);
36959
f5417836dbea renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
wenzelm
parents: 36950
diff changeset
   129
val internal_attribute = value (fn Token.Attribute att => att);
58017
5bdb58845eab support for declaration within token source;
wenzelm
parents: 58012
diff changeset
   130
val internal_declaration = value (fn Token.Declaration decl => decl);
15703
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 15596
diff changeset
   131
61814
1ca1142e1711 clarified type Token.src: plain token list, with usual implicit value assignment;
wenzelm
parents: 60577
diff changeset
   132
fun named_source read =
1ca1142e1711 clarified type Token.src: plain token list, with usual implicit value assignment;
wenzelm
parents: 60577
diff changeset
   133
  internal_source || name_token >> Token.evaluate Token.Source read;
58012
0b0519c41229 support for nested Token.src within Token.T;
wenzelm
parents: 58011
diff changeset
   134
60577
4c9401fbbdf7 tuned signature;
wenzelm
parents: 59857
diff changeset
   135
fun named_typ read =
74563
042041c0ebeb clarified modules;
wenzelm
parents: 69349
diff changeset
   136
  internal_typ ||
042041c0ebeb clarified modules;
wenzelm
parents: 69349
diff changeset
   137
  Parse.token Parse.embedded >> Token.evaluate Token.Typ (read o Token.inner_syntax_of);
60577
4c9401fbbdf7 tuned signature;
wenzelm
parents: 59857
diff changeset
   138
4c9401fbbdf7 tuned signature;
wenzelm
parents: 59857
diff changeset
   139
fun named_term read =
74563
042041c0ebeb clarified modules;
wenzelm
parents: 69349
diff changeset
   140
  internal_term ||
042041c0ebeb clarified modules;
wenzelm
parents: 69349
diff changeset
   141
  Parse.token Parse.embedded >> Token.evaluate Token.Term (read o Token.inner_syntax_of);
42464
ae16b8abf1a8 proper binding/report of defined simprocs;
wenzelm
parents: 42360
diff changeset
   142
57942
e5bec882fdd0 more informative Token.Fact: retain name of dynamic fact (without selection);
wenzelm
parents: 56500
diff changeset
   143
fun named_fact get =
e5bec882fdd0 more informative Token.Fact: retain name of dynamic fact (without selection);
wenzelm
parents: 56500
diff changeset
   144
  internal_fact ||
61814
1ca1142e1711 clarified type Token.src: plain token list, with usual implicit value assignment;
wenzelm
parents: 60577
diff changeset
   145
  name_token >> Token.evaluate Token.Fact (get o Token.content_of) >> #2 ||
1ca1142e1711 clarified type Token.src: plain token list, with usual implicit value assignment;
wenzelm
parents: 60577
diff changeset
   146
  alt_string >> Token.evaluate Token.Fact (get o Token.inner_syntax_of) >> #2;
42464
ae16b8abf1a8 proper binding/report of defined simprocs;
wenzelm
parents: 42360
diff changeset
   147
36959
f5417836dbea renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
wenzelm
parents: 36950
diff changeset
   148
fun named_attribute att =
42464
ae16b8abf1a8 proper binding/report of defined simprocs;
wenzelm
parents: 42360
diff changeset
   149
  internal_attribute ||
61814
1ca1142e1711 clarified type Token.src: plain token list, with usual implicit value assignment;
wenzelm
parents: 60577
diff changeset
   150
  name_token >>
1ca1142e1711 clarified type Token.src: plain token list, with usual implicit value assignment;
wenzelm
parents: 60577
diff changeset
   151
    Token.evaluate Token.Attribute (fn tok => att (Token.content_of tok, Token.pos_of tok));
15703
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 15596
diff changeset
   152
74887
56247fdb8bbb discontinued old-style {* verbatim *} tokens;
wenzelm
parents: 74563
diff changeset
   153
fun embedded_declaration read =
56247fdb8bbb discontinued old-style {* verbatim *} tokens;
wenzelm
parents: 74563
diff changeset
   154
  internal_declaration ||
56247fdb8bbb discontinued old-style {* verbatim *} tokens;
wenzelm
parents: 74563
diff changeset
   155
  Parse.token Parse.embedded >> Token.evaluate Token.Declaration (read o Token.input_of);
59649
c4104707385d cartouche_declaration for Eisbach;
wenzelm
parents: 59064
diff changeset
   156
15703
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 15596
diff changeset
   157
5878
769abc29bb8e several args parsers;
wenzelm
parents: 5822
diff changeset
   158
(* terms and types *)
769abc29bb8e several args parsers;
wenzelm
parents: 5822
diff changeset
   159
42360
da8817d01e7c modernized structure Proof_Context;
wenzelm
parents: 40291
diff changeset
   160
val typ_abbrev = Scan.peek (named_typ o Proof_Context.read_typ_abbrev o Context.proof_of);
25331
73072178e0ce Syntax.read_typ;
wenzelm
parents: 25323
diff changeset
   161
val typ = Scan.peek (named_typ o Syntax.read_typ o Context.proof_of);
24508
c8b82fec6447 replaced ProofContext.read_term/prop by general Syntax.read_term/prop;
wenzelm
parents: 24244
diff changeset
   162
val term = Scan.peek (named_term o Syntax.read_term o Context.proof_of);
55155
a1affe3eb3fd tuned signature;
wenzelm
parents: 55111
diff changeset
   163
val term_pattern = Scan.peek (named_term o Proof_Context.read_term_pattern o Context.proof_of);
42360
da8817d01e7c modernized structure Proof_Context;
wenzelm
parents: 40291
diff changeset
   164
val term_abbrev = Scan.peek (named_term o Proof_Context.read_term_abbrev o Context.proof_of);
24508
c8b82fec6447 replaced ProofContext.read_term/prop by general Syntax.read_term/prop;
wenzelm
parents: 24244
diff changeset
   165
val prop = Scan.peek (named_term o Syntax.read_prop o Context.proof_of);
18635
58bbff56a914 added generic syntax;
wenzelm
parents: 18037
diff changeset
   166
5878
769abc29bb8e several args parsers;
wenzelm
parents: 5822
diff changeset
   167
15703
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 15596
diff changeset
   168
(* type and constant names *)
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 15596
diff changeset
   169
55951
c07d184aebe9 tuned signature -- more uniform check_type_name/read_type_name;
wenzelm
parents: 55915
diff changeset
   170
fun type_name flags =
56002
2028467b4df4 tuned signature;
wenzelm
parents: 55997
diff changeset
   171
  Scan.peek (named_typ o Proof_Context.read_type_name flags o Context.proof_of)
18998
10c251f29847 Context.generic is canonical state of parsers;
wenzelm
parents: 18728
diff changeset
   172
  >> (fn Type (c, _) => c | TFree (a, _) => a | _ => "");
15703
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 15596
diff changeset
   173
55954
a29aefc88c8d more uniform check_const/read_const;
wenzelm
parents: 55951
diff changeset
   174
fun const flags =
56002
2028467b4df4 tuned signature;
wenzelm
parents: 55997
diff changeset
   175
  Scan.peek (named_term o Proof_Context.read_const flags o Context.proof_of)
18998
10c251f29847 Context.generic is canonical state of parsers;
wenzelm
parents: 18728
diff changeset
   176
  >> (fn Const (c, _) => c | Free (x, _) => x | _ => "");
7553
af3a1fe87c42 added bang_facts;
wenzelm
parents: 6447
diff changeset
   177
15703
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 15596
diff changeset
   178
27811
44bc67675210 unified Args.T with OuterLex.token;
wenzelm
parents: 27732
diff changeset
   179
(* improper method arguments *)
15703
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 15596
diff changeset
   180
8536
de307f5bc89a goal_spec;
wenzelm
parents: 8282
diff changeset
   181
val from_to =
36950
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36505
diff changeset
   182
  Parse.nat -- ($$$ "-" |-- Parse.nat) >> (fn (i, j) => fn tac => Seq.INTERVAL tac i j) ||
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36505
diff changeset
   183
  Parse.nat --| $$$ "-" >> (fn i => fn tac => fn st => Seq.INTERVAL tac i (Thm.nprems_of st) st) ||
75b8f26f2f07 refer directly to structure Keyword and Parse;
wenzelm
parents: 36505
diff changeset
   184
  Parse.nat >> (fn i => fn tac => tac i) ||
15703
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 15596
diff changeset
   185
  $$$ "!" >> K ALLGOALS;
8536
de307f5bc89a goal_spec;
wenzelm
parents: 8282
diff changeset
   186
56202
0a11d17eeeff more markup for improper elements;
wenzelm
parents: 56201
diff changeset
   187
val goal = Parse.keyword_improper "[" |-- Parse.!!! (from_to --| Parse.keyword_improper "]");
30514
9455ecc7796d simplified goal_spec: default to first goal;
wenzelm
parents: 30513
diff changeset
   188
fun goal_spec x = Scan.lift (Scan.optional goal (fn tac => tac 1)) x;
8233
85169951d515 attrib: keyword_symid;
wenzelm
parents: 8089
diff changeset
   189
5822
3f824514ad88 Concrete argument syntax (for attributes, methods etc.).
wenzelm
parents:
diff changeset
   190
end;