src/Pure/Isar/outer_parse.ML
changeset 12268 28e60c998eee
parent 12263 6f2acf10e2a2
child 12272 9bc50336dab6
equal deleted inserted replaced
12267:50e2bca71c9d 12268:28e60c998eee
    42   val and_list: (token list -> 'a * token list) -> token list -> 'a list * token list
    42   val and_list: (token list -> 'a * token list) -> token list -> 'a list * token list
    43   val and_list1: (token list -> 'a * token list) -> token list -> 'a list * token list
    43   val and_list1: (token list -> 'a * token list) -> token list -> 'a list * token list
    44   val name: token list -> bstring * token list
    44   val name: token list -> bstring * token list
    45   val xname: token list -> xstring * token list
    45   val xname: token list -> xstring * token list
    46   val text: token list -> string * token list
    46   val text: token list -> string * token list
       
    47   val uname: token list -> string option * token list
    47   val comment: token list -> Comment.text * token list
    48   val comment: token list -> Comment.text * token list
    48   val marg_comment: token list -> Comment.text * token list
    49   val marg_comment: token list -> Comment.text * token list
    49   val interest: token list -> Comment.interest * token list
    50   val interest: token list -> Comment.interest * token list
    50   val sort: token list -> string * token list
    51   val sort: token list -> string * token list
    51   val arity: token list -> (string list * string) * token list
    52   val arity: token list -> (string list * string) * token list
   170 
   171 
   171 val name = group "name declaration" (short_ident || sym_ident || string || number);
   172 val name = group "name declaration" (short_ident || sym_ident || string || number);
   172 val xname = group "name reference" (short_ident || long_ident || sym_ident || string || number);
   173 val xname = group "name reference" (short_ident || long_ident || sym_ident || string || number);
   173 val text = group "text" (short_ident || long_ident || sym_ident || string || number || verbatim);
   174 val text = group "text" (short_ident || long_ident || sym_ident || string || number || verbatim);
   174 
   175 
       
   176 val uname = underscore >> K None || name >> Some;
       
   177 
   175 
   178 
   176 (* formal comments *)
   179 (* formal comments *)
   177 
   180 
   178 val comment = text >> (Comment.plain o Library.single);
   181 val comment = text >> (Comment.plain o Library.single);
   179 val marg_comment = Scan.repeat ($$$ "--" |-- text) >> Comment.plain;
   182 val marg_comment = Scan.repeat ($$$ "--" |-- text) >> Comment.plain;
   300 val xthm = xname -- opt_attribs;
   303 val xthm = xname -- opt_attribs;
   301 val xthms1 = Scan.repeat1 xthm;
   304 val xthms1 = Scan.repeat1 xthm;
   302 
   305 
   303 
   306 
   304 (* locale elements *)
   307 (* locale elements *)
       
   308 
       
   309 (* FIXME
       
   310 fun expr2 x = (xname >> Locale.Locale || $$$ "(" |-- !!! (expr0 --| $$$ ")")) x
       
   311 and expr1 x = (expr2 -- Scan.repeat1 uname >> Locale.Rename || expr2) x
       
   312 and expr0 x = (enum1 "+" expr1 >> (fn [e] => e | es => Locale.Merge es)) x;
       
   313 *)
       
   314 val expr0 = xname;
   305 
   315 
   306 val loc_mixfix = $$$ "(" -- $$$ "structure" -- !!! ($$$ ")") >> K None || opt_mixfix >> Some;
   316 val loc_mixfix = $$$ "(" -- $$$ "structure" -- !!! ($$$ ")") >> K None || opt_mixfix >> Some;
   307 
   317 
   308 val locale_element = group "locale element"
   318 val locale_element = group "locale element"
   309   ($$$ "fixes" |-- !!! (and_list1 (name -- Scan.option ($$$ "::" |-- typ) -- loc_mixfix
   319   ($$$ "fixes" |-- !!! (and_list1 (name -- Scan.option ($$$ "::" |-- typ) -- loc_mixfix
   311   $$$ "assumes" |-- !!! (and_list1 (opt_thm_name ":" -- Scan.repeat1 propp))
   321   $$$ "assumes" |-- !!! (and_list1 (opt_thm_name ":" -- Scan.repeat1 propp))
   312     >> Locale.Assumes ||
   322     >> Locale.Assumes ||
   313   $$$ "defines" |-- !!! (and_list1 (opt_thm_name ":" -- propp'))
   323   $$$ "defines" |-- !!! (and_list1 (opt_thm_name ":" -- propp'))
   314     >> Locale.Defines ||
   324     >> Locale.Defines ||
   315   $$$ "notes" |-- !!! (and_list1 (opt_thm_name "=" -- xthms1)) >> Locale.Notes ||
   325   $$$ "notes" |-- !!! (and_list1 (opt_thm_name "=" -- xthms1)) >> Locale.Notes ||
   316   $$$ "uses" |-- !!! xname >> (Locale.Uses o Locale.Locale));
   326   $$$ "uses" |-- !!! expr0 >> (Locale.Uses o Locale.Locale));
   317 
   327 
   318 
   328 
   319 (* proof methods *)
   329 (* proof methods *)
   320 
   330 
   321 fun is_symid_meth s =
   331 fun is_symid_meth s =