src/Pure/Isar/attrib.ML
changeset 15801 d2f5ca3c048d
parent 15798 016f3be5a5ec
child 15828 ad483e324b59
equal deleted inserted replaced
15800:f2215ed00438 15801:d2f5ca3c048d
    38   val local_thmss: ProofContext.context * Args.T list -> thm list * (ProofContext.context * Args.T list)
    38   val local_thmss: ProofContext.context * Args.T list -> thm list * (ProofContext.context * Args.T list)
    39   val syntax: ('a * Args.T list -> 'a attribute * ('a * Args.T list)) -> src -> 'a attribute
    39   val syntax: ('a * Args.T list -> 'a attribute * ('a * Args.T list)) -> src -> 'a attribute
    40   val no_args: 'a attribute -> src -> 'a attribute
    40   val no_args: 'a attribute -> src -> 'a attribute
    41   val add_del_args: 'a attribute -> 'a attribute -> src -> 'a attribute
    41   val add_del_args: 'a attribute -> 'a attribute -> src -> 'a attribute
    42   val attribute: (theory attribute * ProofContext.context attribute) -> src
    42   val attribute: (theory attribute * ProofContext.context attribute) -> src
    43   val setup: (theory -> theory) list
       
    44 end;
    43 end;
    45 
    44 
    46 structure Attrib: ATTRIB =
    45 structure Attrib: ATTRIB =
    47 struct
    46 struct
    48 
    47 
    80       |> Pretty.chunks |> Pretty.writeln
    79       |> Pretty.chunks |> Pretty.writeln
    81     end;
    80     end;
    82 end;
    81 end;
    83 
    82 
    84 structure AttributesData = TheoryDataFun(AttributesDataArgs);
    83 structure AttributesData = TheoryDataFun(AttributesDataArgs);
       
    84 val _ = Context.add_setup [AttributesData.init];
    85 val print_attributes = AttributesData.print;
    85 val print_attributes = AttributesData.print;
    86 
    86 
    87 
    87 
    88 (* interning *)
    88 (* interning *)
    89 
    89 
   485 fun attribute att = Args.src ((attributeN, [Args.mk_attribute att]), Position.none);
   485 fun attribute att = Args.src ((attributeN, [Args.mk_attribute att]), Position.none);
   486 
   486 
   487 fun attribute_global x = (syntax (Scan.lift Args.internal_attribute >> #1)) x;
   487 fun attribute_global x = (syntax (Scan.lift Args.internal_attribute >> #1)) x;
   488 fun attribute_local x = (syntax (Scan.lift Args.internal_attribute >> #2)) x;
   488 fun attribute_local x = (syntax (Scan.lift Args.internal_attribute >> #2)) x;
   489 
   489 
   490 val setup_internal_attribute =
   490 val _ = Context.add_setup
   491  [PureThy.global_path,
   491  [PureThy.global_path,
   492   add_attributes [(attributeN, (attribute_global, attribute_local), "internal attribute")],
   492   add_attributes [(attributeN, (attribute_global, attribute_local), "internal attribute")],
   493   PureThy.local_path];
   493   PureThy.local_path];
   494 
   494 
   495 
       
   496 
       
   497 (** theory setup **)
       
   498 
   495 
   499 (* pure_attributes *)
   496 (* pure_attributes *)
   500 
   497 
   501 val pure_attributes =
   498 val pure_attributes =
   502  [("tagged", (gen_tagged, gen_tagged), "tagged theorem"),
   499  [("tagged", (gen_tagged, gen_tagged), "tagged theorem"),
   520   ("rulify", (no_args ObjectLogic.declare_rulify, no_args undef_local_attribute),
   517   ("rulify", (no_args ObjectLogic.declare_rulify, no_args undef_local_attribute),
   521     "declaration of rulify rule"),
   518     "declaration of rulify rule"),
   522   ("rule_format", (rule_format_att, rule_format_att), "result put into standard rule format")] @
   519   ("rule_format", (rule_format_att, rule_format_att), "result put into standard rule format")] @
   523   rule_atts;
   520   rule_atts;
   524 
   521 
   525 
   522 val _ = Context.add_setup [add_attributes pure_attributes];
   526 (* setup *)
   523 
   527 
       
   528 val setup =
       
   529  AttributesData.init :: setup_internal_attribute @ [add_attributes pure_attributes];
       
   530 
   524 
   531 end;
   525 end;
   532 
   526 
   533 structure BasicAttrib: BASIC_ATTRIB = Attrib;
   527 structure BasicAttrib: BASIC_ATTRIB = Attrib;
   534 open BasicAttrib;
   528 open BasicAttrib;
   535