src/Pure/Isar/outer_parse.ML
author ballarin
Thu Jul 07 15:52:31 2005 +0200 (2005-07-07)
changeset 16736 1e792b32abef
parent 16498 9d265401fee0
child 17070 3b29a01417f8
permissions -rw-r--r--
Preparations for interpretation of locales in locales.
wenzelm@5826
     1
(*  Title:      Pure/Isar/outer_parse.ML
wenzelm@5826
     2
    ID:         $Id$
wenzelm@5826
     3
    Author:     Markus Wenzel, TU Muenchen
wenzelm@5826
     4
wenzelm@5826
     5
Generic parsers for Isabelle/Isar outer syntax.
wenzelm@5826
     6
*)
wenzelm@5826
     7
wenzelm@5826
     8
signature OUTER_PARSE =
wenzelm@5826
     9
sig
wenzelm@5826
    10
  type token
wenzelm@5826
    11
  val group: string -> (token list -> 'a) -> token list -> 'a
wenzelm@5826
    12
  val !!! : (token list -> 'a) -> token list -> 'a
wenzelm@8581
    13
  val !!!! : (token list -> 'a) -> token list -> 'a
wenzelm@12047
    14
  val triple1: ('a * 'b) * 'c -> 'a * 'b * 'c
wenzelm@12047
    15
  val triple2: 'a * ('b * 'c) -> 'a * 'b * 'c
wenzelm@12047
    16
  val triple_swap: ('a * 'b) * 'c -> ('a * 'c) * 'b
wenzelm@15703
    17
  val not_eof: token list -> token * token list
wenzelm@5826
    18
  val position: (token list -> 'a * 'b) -> token list -> ('a * Position.T) * 'b
wenzelm@7026
    19
  val command: token list -> string * token list
wenzelm@5826
    20
  val keyword: token list -> string * token list
wenzelm@5826
    21
  val short_ident: token list -> string * token list
wenzelm@5826
    22
  val long_ident: token list -> string * token list
wenzelm@5826
    23
  val sym_ident: token list -> string * token list
kleing@15963
    24
  val minus: token list -> string * token list
wenzelm@5826
    25
  val term_var: token list -> string * token list
wenzelm@5826
    26
  val type_ident: token list -> string * token list
wenzelm@5826
    27
  val type_var: token list -> string * token list
wenzelm@5826
    28
  val number: token list -> string * token list
wenzelm@5826
    29
  val string: token list -> string * token list
wenzelm@5826
    30
  val verbatim: token list -> string * token list
wenzelm@6860
    31
  val sync: token list -> string * token list
wenzelm@5826
    32
  val eof: token list -> string * token list
wenzelm@15703
    33
  val $$$ : string -> token list -> string * token list
wenzelm@16030
    34
  val reserved : string -> token list -> string * token list
wenzelm@15703
    35
  val semicolon: token list -> string * token list
wenzelm@15703
    36
  val underscore: token list -> string * token list
wenzelm@15703
    37
  val maybe: (token list -> 'a * token list) -> token list -> 'a option * token list
wenzelm@7930
    38
  val opt_unit: token list -> unit * token list
wenzelm@14646
    39
  val opt_keyword: string -> token list -> bool * token list
wenzelm@5826
    40
  val nat: token list -> int * token list
wenzelm@5826
    41
  val enum: string -> (token list -> 'a * token list) -> token list -> 'a list * token list
wenzelm@5826
    42
  val enum1: string -> (token list -> 'a * token list) -> token list -> 'a list * token list
wenzelm@5826
    43
  val list: (token list -> 'a * token list) -> token list -> 'a list * token list
wenzelm@5826
    44
  val list1: (token list -> 'a * token list) -> token list -> 'a list * token list
wenzelm@6013
    45
  val and_list: (token list -> 'a * token list) -> token list -> 'a list * token list
wenzelm@6013
    46
  val and_list1: (token list -> 'a * token list) -> token list -> 'a list * token list
wenzelm@5826
    47
  val name: token list -> bstring * token list
wenzelm@5826
    48
  val xname: token list -> xstring * token list
wenzelm@5826
    49
  val text: token list -> string * token list
wenzelm@14949
    50
  val path: token list -> Path.T * token list
wenzelm@8897
    51
  val sort: token list -> string * token list
wenzelm@8897
    52
  val arity: token list -> (string list * string) * token list
wenzelm@5826
    53
  val type_args: token list -> string list * token list
wenzelm@5826
    54
  val typ: token list -> string * token list
wenzelm@5826
    55
  val opt_infix: token list -> Syntax.mixfix * token list
wenzelm@5826
    56
  val opt_mixfix: token list -> Syntax.mixfix * token list
wenzelm@9037
    57
  val opt_infix': token list -> Syntax.mixfix * token list
wenzelm@9037
    58
  val opt_mixfix': token list -> Syntax.mixfix * token list
wenzelm@14646
    59
  val mixfix': token list -> Syntax.mixfix * token list
wenzelm@5826
    60
  val const: token list -> (bstring * string * Syntax.mixfix) * token list
wenzelm@5826
    61
  val term: token list -> string * token list
wenzelm@5826
    62
  val prop: token list -> string * token list
wenzelm@6935
    63
  val propp: token list -> (string * (string list * string list)) * token list
wenzelm@6949
    64
  val termp: token list -> (string * string list) * token list
wenzelm@9131
    65
  val arguments: token list -> Args.T list * token list
wenzelm@15703
    66
  val attribs: token list -> Attrib.src list * token list
wenzelm@15703
    67
  val opt_attribs: token list -> Attrib.src list * token list
wenzelm@15703
    68
  val thm_name: string -> token list -> (bstring * Attrib.src list) * token list
wenzelm@15703
    69
  val opt_thm_name: string -> token list -> (bstring * Attrib.src list) * token list
wenzelm@15703
    70
  val spec_name: token list -> ((bstring * string) * Attrib.src list) * token list
wenzelm@15703
    71
  val spec_opt_name: token list -> ((bstring * string) * Attrib.src list) * token list
wenzelm@15703
    72
  val xthm: token list -> (thmref * Attrib.src list) * token list
wenzelm@15703
    73
  val xthms1: token list -> (thmref * Attrib.src list) list * token list
ballarin@16736
    74
  val locale_target: token list -> xstring * token list
ballarin@16736
    75
  val opt_locale_target: token list -> xstring option * token list
wenzelm@12272
    76
  val locale_expr: token list -> Locale.expr * token list
wenzelm@12942
    77
  val locale_keyword: token list -> string * token list
wenzelm@15703
    78
  val locale_element: token list -> Locale.element * token list
wenzelm@15703
    79
  val locale_elem_or_expr: token list -> Locale.element Locale.elem_expr * token list
wenzelm@5826
    80
  val method: token list -> Method.text * token list
wenzelm@5826
    81
end;
wenzelm@5826
    82
wenzelm@5826
    83
structure OuterParse: OUTER_PARSE =
wenzelm@5826
    84
struct
wenzelm@5826
    85
wenzelm@9131
    86
structure T = OuterLex;
wenzelm@9131
    87
type token = T.token;
wenzelm@5826
    88
wenzelm@5826
    89
wenzelm@5826
    90
(** error handling **)
wenzelm@5826
    91
wenzelm@5826
    92
(* group atomic parsers (no cuts!) *)
wenzelm@5826
    93
wenzelm@5826
    94
fun fail_with s = Scan.fail_with
wenzelm@5826
    95
  (fn [] => s ^ " expected (past end-of-file!)"
wenzelm@9155
    96
    | (tok :: _) => s ^ " expected,\nbut " ^ T.name_of tok ^ T.pos_of tok ^ " was found");
wenzelm@5826
    97
wenzelm@5826
    98
fun group s scan = scan || fail_with s;
wenzelm@5826
    99
wenzelm@5826
   100
wenzelm@5877
   101
(* cut *)
wenzelm@5826
   102
wenzelm@8581
   103
fun cut kind scan =
wenzelm@5826
   104
  let
wenzelm@5826
   105
    fun get_pos [] = " (past end-of-file!)"
wenzelm@9131
   106
      | get_pos (tok :: _) = T.pos_of tok;
wenzelm@5826
   107
skalberg@15531
   108
    fun err (toks, NONE) = kind ^ get_pos toks
skalberg@15531
   109
      | err (toks, SOME msg) = kind ^ get_pos toks ^ ": " ^ msg;
wenzelm@5826
   110
  in Scan.!! err scan end;
wenzelm@5826
   111
wenzelm@8586
   112
fun !!! scan = cut "Outer syntax error" scan;
wenzelm@8586
   113
fun !!!! scan = cut "Corrupted outer syntax in presentation" scan;
wenzelm@8581
   114
wenzelm@5826
   115
wenzelm@5826
   116
wenzelm@5826
   117
(** basic parsers **)
wenzelm@5826
   118
wenzelm@5826
   119
(* utils *)
wenzelm@5826
   120
wenzelm@5826
   121
fun triple1 ((x, y), z) = (x, y, z);
wenzelm@5826
   122
fun triple2 (x, (y, z)) = (x, y, z);
wenzelm@6430
   123
fun triple_swap ((x, y), z) = ((x, z), y);
wenzelm@5826
   124
wenzelm@5826
   125
wenzelm@5826
   126
(* tokens *)
wenzelm@5826
   127
wenzelm@15703
   128
val not_eof = Scan.one T.not_eof;
wenzelm@15703
   129
wenzelm@15703
   130
fun position scan = (Scan.ahead not_eof >> T.position_of) -- scan >> Library.swap;
wenzelm@5826
   131
wenzelm@5826
   132
fun kind k =
wenzelm@9131
   133
  group (T.str_of_kind k) (Scan.one (T.is_kind k) >> T.val_of);
wenzelm@5826
   134
wenzelm@9131
   135
val command = kind T.Command;
wenzelm@9131
   136
val keyword = kind T.Keyword;
wenzelm@9131
   137
val short_ident = kind T.Ident;
wenzelm@9131
   138
val long_ident = kind T.LongIdent;
wenzelm@9131
   139
val sym_ident = kind T.SymIdent;
wenzelm@9131
   140
val term_var = kind T.Var;
wenzelm@9131
   141
val type_ident = kind T.TypeIdent;
wenzelm@9131
   142
val type_var = kind T.TypeVar;
wenzelm@9131
   143
val number = kind T.Nat;
wenzelm@9131
   144
val string = kind T.String;
wenzelm@9131
   145
val verbatim = kind T.Verbatim;
wenzelm@9131
   146
val sync = kind T.Sync;
wenzelm@9131
   147
val eof = kind T.EOF;
wenzelm@5826
   148
wenzelm@5826
   149
fun $$$ x =
wenzelm@9131
   150
  group (T.str_of_kind T.Keyword ^ " " ^ quote x)
wenzelm@9131
   151
    (Scan.one (T.keyword_with (equal x)) >> T.val_of);
wenzelm@9131
   152
wenzelm@16030
   153
fun reserved x =
wenzelm@16030
   154
  group ("Reserved identifier " ^ quote x)
wenzelm@16030
   155
    (Scan.one (T.ident_with (equal x)) >> T.val_of);
wenzelm@16030
   156
wenzelm@9131
   157
val semicolon = $$$ ";";
wenzelm@5826
   158
wenzelm@15703
   159
val minus = sym_ident :-- (fn "-" => Scan.succeed () | _ => Scan.fail) >> #1;
wenzelm@11792
   160
val underscore = sym_ident :-- (fn "_" => Scan.succeed () | _ => Scan.fail) >> #1;
wenzelm@15703
   161
fun maybe scan = underscore >> K NONE || scan >> SOME;
wenzelm@11792
   162
wenzelm@14835
   163
val nat = number >> (#1 o Library.read_int o Symbol.explode);
wenzelm@5826
   164
wenzelm@7930
   165
val opt_unit = Scan.optional ($$$ "(" -- $$$ ")" >> (K ())) ();
wenzelm@7930
   166
wenzelm@14646
   167
fun opt_keyword s = Scan.optional ($$$ "(" |-- !!! (($$$ s >> K true) --| $$$ ")")) false;
wenzelm@14646
   168
wenzelm@5826
   169
wenzelm@5826
   170
(* enumerations *)
wenzelm@5826
   171
wenzelm@6003
   172
fun enum1 sep scan = scan -- Scan.repeat ($$$ sep |-- !!! scan) >> op ::;
wenzelm@5826
   173
fun enum sep scan = enum1 sep scan || Scan.succeed [];
wenzelm@5826
   174
wenzelm@5826
   175
fun list1 scan = enum1 "," scan;
wenzelm@5826
   176
fun list scan = enum "," scan;
wenzelm@5826
   177
wenzelm@6013
   178
fun and_list1 scan = enum1 "and" scan;
wenzelm@6013
   179
fun and_list scan = enum "and" scan;
wenzelm@6013
   180
wenzelm@5826
   181
wenzelm@5960
   182
(* names and text *)
wenzelm@5826
   183
wenzelm@8146
   184
val name = group "name declaration" (short_ident || sym_ident || string || number);
wenzelm@8146
   185
val xname = group "name reference" (short_ident || long_ident || sym_ident || string || number);
wenzelm@8146
   186
val text = group "text" (short_ident || long_ident || sym_ident || string || number || verbatim);
wenzelm@14949
   187
val path = group "file name/path specification" name >> Path.unpack;
wenzelm@6553
   188
wenzelm@6553
   189
wenzelm@6372
   190
(* sorts and arities *)
wenzelm@5826
   191
wenzelm@8897
   192
val sort = group "sort" xname;
wenzelm@5826
   193
wenzelm@6372
   194
fun gen_arity cod =
wenzelm@7352
   195
  Scan.optional ($$$ "(" |-- !!! (list1 sort --| $$$ ")")) [] -- cod;
wenzelm@6372
   196
wenzelm@6372
   197
val arity = gen_arity sort;
wenzelm@5826
   198
wenzelm@5826
   199
wenzelm@5826
   200
(* types *)
wenzelm@5826
   201
wenzelm@8146
   202
val typ = group "type"
wenzelm@8146
   203
  (short_ident || long_ident || sym_ident || type_ident || type_var || string || number);
wenzelm@5826
   204
wenzelm@5826
   205
val type_args =
wenzelm@5826
   206
  type_ident >> single ||
wenzelm@5826
   207
  $$$ "(" |-- !!! (list1 type_ident --| $$$ ")") ||
wenzelm@5826
   208
  Scan.succeed [];
wenzelm@5826
   209
wenzelm@5826
   210
wenzelm@5826
   211
(* mixfix annotations *)
wenzelm@5826
   212
wenzelm@11651
   213
val infx = $$$ "infix" |-- !!! (nat >> Syntax.Infix || string -- nat >> Syntax.InfixName);
wenzelm@5826
   214
val infxl = $$$ "infixl" |-- !!! (nat >> Syntax.Infixl || string -- nat >> Syntax.InfixlName);
wenzelm@5826
   215
val infxr = $$$ "infixr" |-- !!! (nat >> Syntax.Infixr || string -- nat >> Syntax.InfixrName);
wenzelm@5826
   216
wenzelm@5826
   217
val binder =
wenzelm@5826
   218
  $$$ "binder" |--
wenzelm@5826
   219
    !!! (string -- ($$$ "[" |-- nat --| $$$ "]" -- nat || nat >> (fn n => (n, n))))
wenzelm@5826
   220
  >> (Syntax.Binder o triple2);
wenzelm@5826
   221
wenzelm@5826
   222
wenzelm@5826
   223
val opt_pris = Scan.optional ($$$ "[" |-- !!! (list nat --| $$$ "]")) [];
wenzelm@5826
   224
wenzelm@5826
   225
val mixfix =
wenzelm@8648
   226
  (string -- !!! (opt_pris -- Scan.optional nat Syntax.max_pri))
wenzelm@8648
   227
  >> (Syntax.Mixfix o triple2);
wenzelm@5826
   228
wenzelm@14646
   229
fun fix_decl guard fix = $$$ "(" |-- guard (fix --| $$$ ")");
wenzelm@14646
   230
fun opt_fix guard fix = Scan.optional (fix_decl guard fix) Syntax.NoSyn;
wenzelm@5826
   231
wenzelm@11651
   232
val opt_infix = opt_fix !!! (infxl || infxr || infx);
wenzelm@11651
   233
val opt_mixfix = opt_fix !!! (mixfix || binder || infxl || infxr || infx);
wenzelm@11651
   234
val opt_infix' = opt_fix I (infxl || infxr || infx);
wenzelm@11651
   235
val opt_mixfix' = opt_fix I (mixfix || binder || infxl || infxr || infx);
wenzelm@14646
   236
val mixfix' = fix_decl !!! (mixfix || binder || infxl || infxr || infx);
wenzelm@5826
   237
wenzelm@5826
   238
wenzelm@5826
   239
(* consts *)
wenzelm@5826
   240
wenzelm@5826
   241
val const =
wenzelm@5826
   242
  name -- ($$$ "::" |-- !!! (typ -- opt_mixfix)) >> triple2;
wenzelm@5826
   243
wenzelm@5826
   244
wenzelm@5826
   245
(* terms *)
wenzelm@5826
   246
wenzelm@7477
   247
val trm = short_ident || long_ident || sym_ident || term_var || number || string;
wenzelm@5826
   248
wenzelm@5826
   249
val term = group "term" trm;
wenzelm@5826
   250
val prop = group "proposition" trm;
wenzelm@5826
   251
wenzelm@5826
   252
wenzelm@6949
   253
(* patterns *)
wenzelm@6935
   254
wenzelm@6949
   255
val is_terms = Scan.repeat1 ($$$ "is" |-- term);
wenzelm@6935
   256
val is_props = Scan.repeat1 ($$$ "is" |-- prop);
wenzelm@6935
   257
val concl_props = $$$ "concl" |-- !!! is_props;
wenzelm@7418
   258
val any_props = concl_props >> pair [] || is_props -- Scan.optional concl_props [];
wenzelm@6935
   259
wenzelm@6935
   260
val propp = prop -- Scan.optional ($$$ "(" |-- !!! (any_props --| $$$ ")")) ([], []);
wenzelm@12047
   261
val propp' = prop -- Scan.optional ($$$ "(" |-- !!! (is_props --| $$$ ")")) [];
wenzelm@6949
   262
val termp = term -- Scan.optional ($$$ "(" |-- !!! (is_terms --| $$$ ")")) [];
wenzelm@6935
   263
wenzelm@6935
   264
wenzelm@5826
   265
(* arguments *)
wenzelm@5826
   266
wenzelm@9131
   267
fun keyword_symid is_symid = Scan.one (T.keyword_with is_symid) >> T.val_of;
wenzelm@9131
   268
val keyword_sid = keyword_symid T.is_sid;
wenzelm@5826
   269
wenzelm@6983
   270
fun atom_arg is_symid blk =
wenzelm@5826
   271
  group "argument"
wenzelm@7477
   272
    (position (short_ident || long_ident || sym_ident || term_var ||
wenzelm@15703
   273
        type_ident || type_var || number) >> Args.mk_ident ||
wenzelm@15703
   274
      position (keyword_symid is_symid) >> Args.mk_keyword ||
wenzelm@15703
   275
      position (string || verbatim) >> Args.mk_string ||
wenzelm@15703
   276
      position (if blk then $$$ "," else Scan.fail) >> Args.mk_keyword);
wenzelm@5826
   277
wenzelm@5877
   278
fun paren_args l r scan = position ($$$ l) -- !!! (scan true -- position ($$$ r))
wenzelm@15703
   279
  >> (fn (x, (ys, z)) => Args.mk_keyword x :: ys @ [Args.mk_keyword z]);
wenzelm@5826
   280
wenzelm@6983
   281
fun args is_symid blk x = Scan.optional (args1 is_symid blk) [] x
wenzelm@6983
   282
and args1 is_symid blk x =
wenzelm@5826
   283
  ((Scan.repeat1
wenzelm@6983
   284
    (Scan.repeat1 (atom_arg is_symid blk) ||
wenzelm@6983
   285
      paren_args "(" ")" (args is_symid) ||
skalberg@15570
   286
      paren_args "[" "]" (args is_symid))) >> List.concat) x;
wenzelm@5826
   287
wenzelm@9131
   288
val arguments = args T.is_sid false;
wenzelm@9131
   289
wenzelm@5826
   290
wenzelm@6372
   291
(* theorem specifications *)
wenzelm@5826
   292
wenzelm@9131
   293
val attrib = position ((keyword_sid || xname) -- !!! arguments) >> Args.src;
wenzelm@5826
   294
val attribs = $$$ "[" |-- !!! (list attrib --| $$$ "]");
wenzelm@5826
   295
val opt_attribs = Scan.optional attribs [];
wenzelm@5826
   296
wenzelm@6398
   297
fun thm_name s = name -- opt_attribs --| $$$ s;
wenzelm@6511
   298
fun opt_thm_name s =
wenzelm@6511
   299
  Scan.optional ((name -- opt_attribs || (attribs >> pair "")) --| $$$ s) ("", []);;
wenzelm@5917
   300
wenzelm@6372
   301
val spec_name = thm_name ":" -- prop >> (fn ((x, y), z) => ((x, z), y));
wenzelm@6372
   302
val spec_opt_name = opt_thm_name ":" -- prop >> (fn ((x, y), z) => ((x, z), y));
wenzelm@6372
   303
berghofe@15456
   304
val thm_sel = $$$ "(" |-- list1
wenzelm@15703
   305
 (nat --| minus -- nat >> PureThy.FromTo ||
wenzelm@15703
   306
  nat --| minus >> PureThy.From ||
wenzelm@15703
   307
  nat >> PureThy.Single) --| $$$ ")";
berghofe@15456
   308
wenzelm@16498
   309
val xthm = (xname -- thm_sel >> NameSelection || xname >> Name) -- opt_attribs;
wenzelm@6372
   310
val xthms1 = Scan.repeat1 xthm;
wenzelm@5826
   311
wenzelm@5826
   312
wenzelm@12047
   313
(* locale elements *)
wenzelm@12047
   314
wenzelm@12272
   315
local
wenzelm@12272
   316
skalberg@15531
   317
val loc_mixfix = $$$ "(" -- $$$ "structure" -- !!! ($$$ ")") >> K NONE || opt_mixfix >> SOME;
ballarin@16169
   318
val loc_keyword = $$$ "fixes" || $$$ "constrains" || $$$ "assumes" ||
ballarin@16169
   319
   $$$ "defines" || $$$ "notes" || $$$ "includes";
wenzelm@12272
   320
ballarin@15127
   321
val loc_element =
ballarin@15127
   322
  $$$ "fixes" |-- !!! (and_list1 (name -- Scan.option ($$$ "::" |-- typ) -- loc_mixfix
ballarin@15127
   323
    >> triple1)) >> Locale.Fixes ||
ballarin@16169
   324
  $$$ "constrains" |-- !!! (and_list1 (name -- ($$$ "::" |-- typ)))
ballarin@16169
   325
    >> Locale.Constrains ||
ballarin@15127
   326
  $$$ "assumes" |-- !!! (and_list1 (opt_thm_name ":" -- Scan.repeat1 propp))
ballarin@15127
   327
    >> Locale.Assumes ||
ballarin@15127
   328
  $$$ "defines" |-- !!! (and_list1 (opt_thm_name ":" -- propp'))
ballarin@15127
   329
    >> Locale.Defines ||
ballarin@15127
   330
  $$$ "notes" |-- !!! (and_list1 (opt_thm_name "=" -- xthms1))
ballarin@15127
   331
    >> Locale.Notes;
ballarin@15127
   332
wenzelm@12272
   333
fun plus1 scan =
wenzelm@12272
   334
  scan -- Scan.repeat ($$$ "+" |-- Scan.unless loc_keyword (!!! scan)) >> op ::;
wenzelm@12272
   335
ballarin@16102
   336
val rename = name -- Scan.option mixfix';
ballarin@16102
   337
wenzelm@12268
   338
fun expr2 x = (xname >> Locale.Locale || $$$ "(" |-- !!! (expr0 --| $$$ ")")) x
ballarin@16102
   339
and expr1 x = (expr2 -- Scan.repeat1 (maybe rename) >> Locale.Rename || expr2) x
wenzelm@12272
   340
and expr0 x = (plus1 expr1 >> (fn [e] => e | es => Locale.Merge es)) x;
wenzelm@12268
   341
wenzelm@12272
   342
in
wenzelm@12272
   343
ballarin@16736
   344
val locale_target = ($$$ "(" -- $$$ "in") |-- !!! (xname --| $$$ ")");
ballarin@16736
   345
val opt_locale_target = Scan.option locale_target;
wenzelm@12272
   346
val locale_expr = expr0;
wenzelm@12942
   347
val locale_keyword = loc_keyword;
wenzelm@12047
   348
ballarin@15127
   349
val locale_element = group "locale element" loc_element;
ballarin@15127
   350
ballarin@15127
   351
val locale_elem_or_expr = group "locale element or includes"
ballarin@15127
   352
  (loc_element >> Locale.Elem ||
wenzelm@12955
   353
  $$$ "includes" |-- !!! locale_expr >> Locale.Expr);
wenzelm@12272
   354
wenzelm@12272
   355
end;
wenzelm@12047
   356
wenzelm@12047
   357
wenzelm@5826
   358
(* proof methods *)
wenzelm@5826
   359
wenzelm@6983
   360
fun is_symid_meth s =
wenzelm@9131
   361
  s <> "|" andalso s <> "?" andalso s <> "+" andalso T.is_sid s;
wenzelm@6983
   362
wenzelm@5826
   363
fun meth4 x =
wenzelm@5877
   364
 (position (xname >> rpair []) >> (Method.Source o Args.src) ||
wenzelm@6983
   365
  $$$ "(" |-- !!! (meth0 --| $$$ ")")) x
wenzelm@5826
   366
and meth3 x =
wenzelm@5826
   367
 (meth4 --| $$$ "?" >> Method.Try ||
wenzelm@5826
   368
  meth4 --| $$$ "+" >> Method.Repeat1 ||
wenzelm@5940
   369
  meth4) x
wenzelm@5940
   370
and meth2 x =
wenzelm@6983
   371
 (position (xname -- args1 is_symid_meth false) >> (Method.Source o Args.src) ||
wenzelm@5826
   372
  meth3) x
wenzelm@5826
   373
and meth1 x = (enum1 "," meth2 >> (fn [m] => m | ms => Method.Then ms)) x
wenzelm@5826
   374
and meth0 x = (enum1 "|" meth1 >> (fn [m] => m | ms => Method.Orelse ms)) x;
wenzelm@5826
   375
wenzelm@6558
   376
val method = meth3;
wenzelm@5826
   377
wenzelm@5826
   378
wenzelm@5826
   379
end;