src/Pure/Syntax/syn_trans.ML
changeset 31542 3371a3c19bb1
parent 30146 a77fc0209723
child 32120 53a21a5e6889
equal deleted inserted replaced
31541:4ed9d9dc17ee 31542:3371a3c19bb1
   221 
   221 
   222 (* implicit structures *)
   222 (* implicit structures *)
   223 
   223 
   224 fun the_struct structs i =
   224 fun the_struct structs i =
   225   if 1 <= i andalso i <= length structs then nth structs (i - 1)
   225   if 1 <= i andalso i <= length structs then nth structs (i - 1)
   226   else raise error ("Illegal reference to implicit structure #" ^ string_of_int i);
   226   else error ("Illegal reference to implicit structure #" ^ string_of_int i);
   227 
   227 
   228 fun struct_tr structs (*"_struct"*) [Const ("_indexdefault", _)] =
   228 fun struct_tr structs (*"_struct"*) [Const ("_indexdefault", _)] =
   229       Lexicon.free (the_struct structs 1)
   229       Lexicon.free (the_struct structs 1)
   230   | struct_tr structs (*"_struct"*) [t as (Const ("_indexnum", _) $ Const (s, _))] =
   230   | struct_tr structs (*"_struct"*) [t as (Const ("_indexnum", _) $ Const (s, _))] =
   231       Lexicon.free (the_struct structs
   231       Lexicon.free (the_struct structs
   501       | ast_of (Parser.Tip tok) = Ast.Variable (Lexicon.str_of_token tok);
   501       | ast_of (Parser.Tip tok) = Ast.Variable (Lexicon.str_of_token tok);
   502 
   502 
   503     val exn_results = map (Exn.capture ast_of) pts;
   503     val exn_results = map (Exn.capture ast_of) pts;
   504     val exns = map_filter Exn.get_exn exn_results;
   504     val exns = map_filter Exn.get_exn exn_results;
   505     val results = map_filter Exn.get_result exn_results
   505     val results = map_filter Exn.get_result exn_results
   506   in (case (results, exns) of ([], exn :: _) => raise exn | _ => results) end;
   506   in (case (results, exns) of ([], exn :: _) => reraise exn | _ => results) end;
   507 
   507 
   508 
   508 
   509 
   509 
   510 (** asts_to_terms **)
   510 (** asts_to_terms **)
   511 
   511 
   532         | t => t);
   532         | t => t);
   533 
   533 
   534     val exn_results = map (Exn.capture (term_of #> free_fixed)) asts;
   534     val exn_results = map (Exn.capture (term_of #> free_fixed)) asts;
   535     val exns = map_filter Exn.get_exn exn_results;
   535     val exns = map_filter Exn.get_exn exn_results;
   536     val results = map_filter Exn.get_result exn_results
   536     val results = map_filter Exn.get_result exn_results
   537   in (case (results, exns) of ([], exn :: _) => raise exn | _ => results) end;
   537   in (case (results, exns) of ([], exn :: _) => reraise exn | _ => results) end;
   538 
   538 
   539 end;
   539 end;