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