src/Pure/ProofGeneral/parsing.ML
changeset 22101 6d13239d5f52
parent 21971 513e1d82640d
child 22160 27cdecde8c2b
equal deleted inserted replaced
22100:33d7468302bb 22101:6d13239d5f52
   127 
   127 
   128             val opt_overloaded = P.opt_keyword "overloaded";
   128             val opt_overloaded = P.opt_keyword "overloaded";
   129 
   129 
   130             val thmnameP = (* see isar_syn.ML/theoremsP *)
   130             val thmnameP = (* see isar_syn.ML/theoremsP *)
   131                 let
   131                 let
   132                     val name_facts = P.and_list1 ((P.opt_thm_name "=" --| P.xthms1) >> #1)
   132                     val name_facts = P.and_list1 ((SpecParse.opt_thm_name "=" --| SpecParse.xthms1) >> #1)
   133                     val theoremsP = P.opt_locale_target |-- name_facts >> (fn [] => "" | x::_ => x)
   133                     val theoremsP = P.opt_target |-- name_facts >> (fn [] => "" | x::_ => x)
   134                 in
   134                 in
   135                     theoremsP
   135                     theoremsP
   136                 end
   136                 end
   137         in
   137         in
   138             (* TODO: ideally we would like to render terms properly, just as they are
   138             (* TODO: ideally we would like to render terms properly, just as they are
   148                    | "typedecl"  => named_item (P.type_args |-- P.name) "type"
   148                    | "typedecl"  => named_item (P.type_args |-- P.name) "type"
   149                    | "types"     => named_item (P.type_args |-- P.name) "type"
   149                    | "types"     => named_item (P.type_args |-- P.name) "type"
   150                    | "classes"   => named_item P.name "class"
   150                    | "classes"   => named_item P.name "class"
   151                    | "classrel"  => named_item P.name "class"
   151                    | "classrel"  => named_item P.name "class"
   152                    | "consts"    => named_item (P.const >> #1) "term"
   152                    | "consts"    => named_item (P.const >> #1) "term"
   153                    | "axioms"    => named_item (P.spec_name >> (#1 o #1)) "theorem"
   153                    | "axioms"    => named_item (SpecParse.spec_name >> (#1 o #1)) "theorem"
   154                    | "defs"      => named_item (opt_overloaded |-- P.spec_name >> (#1 o #1)) "theorem"
   154                    | "defs"      => named_item (opt_overloaded |-- SpecParse.spec_name >> (#1 o #1)) "theorem"
   155                    | "constdefs" => named_item P.name (* FIXME: heavily simplified/wrong *) "term"
   155                    | "constdefs" => named_item P.name (* FIXME: heavily simplified/wrong *) "term"
   156                    | "theorems"  => named_item thmnameP "thmset"
   156                    | "theorems"  => named_item thmnameP "thmset"
   157                    | "lemmas"    => named_item thmnameP "thmset"
   157                    | "lemmas"    => named_item thmnameP "thmset"
   158                    | "oracle"    => named_item P.name "oracle"
   158                    | "oracle"    => named_item P.name "oracle"
   159                    | "locale"    => named_item ((P.opt_keyword "open" >> not) |-- P.name) "locale"
   159                    | "locale"    => named_item ((P.opt_keyword "open" >> not) |-- P.name) "locale"
   162         end
   162         end
   163 
   163 
   164     fun xmls_of_thy_goal (name,toks,str) =
   164     fun xmls_of_thy_goal (name,toks,str) =
   165         let
   165         let
   166             (* see isar_syn.ML/gen_theorem *)
   166             (* see isar_syn.ML/gen_theorem *)
   167          val statement = P.and_list1 (P.opt_thm_name ":" -- Scan.repeat1 P.propp);
   167          val statement = P.and_list1 (SpecParse.opt_thm_name ":" -- Scan.repeat1 P.propp);
   168          val general_statement =
   168          val general_statement =
   169             statement >> pair [] || Scan.repeat P.locale_element -- (P.$$$ "shows" |-- statement);
   169             statement >> pair [] || Scan.repeat SpecParse.locale_element -- (P.$$$ "shows" |-- statement);
   170 
   170 
   171             val gen_theoremP =
   171             val gen_theoremP =
   172                 P.opt_locale_target -- Scan.optional (P.opt_thm_name ":" --|
   172                 P.opt_target -- Scan.optional (SpecParse.opt_thm_name ":" --|
   173                  Scan.ahead (P.locale_keyword || P.$$$ "shows")) ("", []) --
   173                  Scan.ahead (SpecParse.locale_keyword || P.$$$ "shows")) ("", []) --
   174                                  general_statement >> (fn ((locale, a), (elems, concl)) =>
   174                                  general_statement >> (fn ((locale, a), (elems, concl)) =>
   175                                                          fst a) (* a : (bstring * Args.src list) *)
   175                                                          fst a) (* a : (bstring * Args.src list) *)
   176 
   176 
   177             val nameP = P.opt_locale_target |-- (Scan.optional ((P.opt_thm_name ":") >> #1) "")
   177             val nameP = P.opt_target |-- (Scan.optional ((SpecParse.opt_thm_name ":") >> #1) "")
   178 	    val thmname = nameparse "opengoal" "theorem" nameP toks
   178 	    val thmname = nameparse "opengoal" "theorem" nameP toks
   179         in
   179         in
   180             [D.Opengoal {thmname=SOME thmname, text=str},
   180             [D.Opengoal {thmname=SOME thmname, text=str},
   181              D.Openblock {metavarid=NONE,name=NONE,objtype=SOME "theorem-proof"}]
   181              D.Openblock {metavarid=NONE,name=NONE,objtype=SOME "theorem-proof"}]
   182         end
   182         end