src/Pure/Thy/thy_parse.ML
changeset 586 201e115d8031
parent 570 6333c181a3f7
child 587 3ba470399605
equal deleted inserted replaced
585:409c9ee7a9f3 586:201e115d8031
   348 
   348 
   349 
   349 
   350 (* header *)
   350 (* header *)
   351 
   351 
   352 fun mk_header (thy_name, bases) =
   352 fun mk_header (thy_name, bases) =
   353   (thy_name, "base_on " ^ mk_list bases ^ " " ^ quote thy_name);
   353   (thy_name, "mk_base " ^ mk_list bases ^ " " ^ quote thy_name);
   354 
   354 
   355 val base =
   355 val base =
   356   ident >> (cat "Thy" o quote) ||
   356   ident >> (cat "Thy" o quote) ||
   357   string >> cat "File";
   357   string >> cat "File";
   358 
   358 
   387     error ("Filename \"" ^ tname ^ ".thy\" and theory name "
   387     error ("Filename \"" ^ tname ^ ".thy\" and theory name "
   388       ^ quote thy_name ^ " are different")
   388       ^ quote thy_name ^ " are different")
   389   else
   389   else
   390     (case opt_txts of
   390     (case opt_txts of
   391       Some (extxt, postxt, mltxt) =>
   391       Some (extxt, postxt, mltxt) =>
   392         "structure " ^ thy_name ^ " =\n\
   392         "val base = " ^ old_thys ^ " true;\n\n\
       
   393         \structure " ^ thy_name ^ " =\n\
   393         \struct\n\
   394         \struct\n\
   394         \\n\
   395         \\n\
   395         \local\n"
   396         \local\n"
   396         ^ trfun_defs ^ "\n\
   397         ^ trfun_defs ^ "\n\
   397         \in\n\
   398         \in\n\
   398         \\n"
   399         \\n"
   399         ^ mltxt ^ "\n\
   400         ^ mltxt ^ "\n\
   400         \\n\
   401         \\n\
   401         \val thy = (" ^ old_thys ^ " true)\n\n\
   402         \val thy = base\n\n\
   402         \|> add_trfuns\n"
   403         \|> add_trfuns\n"
   403         ^ trfun_args ^ "\n\
   404         ^ trfun_args ^ "\n\
   404         \\n"
   405         \\n"
   405         ^ extxt ^ "\n\
   406         ^ extxt ^ "\n\
   406         \\n\
   407         \\n\
   410         ^ postxt ^ "\n\
   411         ^ postxt ^ "\n\
   411         \\n\
   412         \\n\
   412         \end;\n\
   413         \end;\n\
   413         \end;\n"
   414         \end;\n"
   414     | None =>
   415     | None =>
   415         "structure " ^ thy_name ^ " =\n\
   416         "val base = " ^ old_thys ^ " false;\n\n\
       
   417         \structure " ^ thy_name ^ " =\n\
   416         \struct\n\
   418         \struct\n\
   417         \\n\
   419         \\n\
   418         \val thy = (" ^ old_thys ^ " false);\n\
   420         \val thy = base\n\
   419         \\n\
   421         \\n\
   420         \end;\n");
   422         \end;\n");
   421 
   423 
   422 fun theory_defn sectab tname =
   424 fun theory_defn sectab tname =
   423   header -- optional (extension sectab >> Some) None -- eof
   425   header -- optional (extension sectab >> Some) None -- eof