250 |
250 |
251 fun the_struct structs i = |
251 fun the_struct structs i = |
252 if 1 <= i andalso i <= length structs then nth structs (i - 1) |
252 if 1 <= i andalso i <= length structs then nth structs (i - 1) |
253 else error ("Illegal reference to implicit structure #" ^ string_of_int i); |
253 else error ("Illegal reference to implicit structure #" ^ string_of_int i); |
254 |
254 |
255 fun struct_tr structs [Const ("_indexdefault", _)] = |
255 fun legacy_struct structs i = |
256 Syntax.free (the_struct structs 1) |
256 let |
|
257 val x = the_struct structs i; |
|
258 val _ = |
|
259 legacy_feature |
|
260 ("Old-style numbered structure index " ^ quote ("\\<^sub>" ^ string_of_int i) ^ |
|
261 Position.str_of (Position.thread_data ()) ^ |
|
262 " -- use " ^ quote ("\\<^bsub>" ^ x ^ "\\<^esub>") ^ " instead" ^ |
|
263 (if i = 1 then " (may be omitted)" else "")) |
|
264 in x end; |
|
265 |
|
266 fun struct_tr structs [Const ("_indexdefault", _)] = Syntax.free (the_struct structs 1) |
|
267 | struct_tr structs [Const ("_index1", _)] = Syntax.free (legacy_struct structs 1) |
257 | struct_tr structs [t as (Const ("_indexnum", _) $ Const (s, _))] = |
268 | struct_tr structs [t as (Const ("_indexnum", _) $ Const (s, _))] = |
258 (case Lexicon.read_nat s of |
269 (case Lexicon.read_nat s of |
259 SOME n => |
270 SOME i => Syntax.free (legacy_struct structs i) |
260 let |
|
261 val x = the_struct structs n; |
|
262 val advice = |
|
263 " -- use " ^ quote ("\\<^bsub>" ^ x ^ "\\<^esub>") ^ " instead" ^ |
|
264 (if n = 1 then " (may be omitted)" else ""); |
|
265 val _ = |
|
266 legacy_feature |
|
267 ("Old-style numbered structure index " ^ quote ("\\<^sub>" ^ s) ^ |
|
268 Position.str_of (Position.thread_data ()) ^ advice); |
|
269 in Syntax.free x end |
|
270 | NONE => raise TERM ("struct_tr", [t])) |
271 | NONE => raise TERM ("struct_tr", [t])) |
271 | struct_tr _ ts = raise TERM ("struct_tr", ts); |
272 | struct_tr _ ts = raise TERM ("struct_tr", ts); |
272 |
273 |
273 |
274 |
274 |
275 |