equal
deleted
inserted
replaced
10 type binding = binding * src list |
10 type binding = binding * src list |
11 val empty_binding: binding |
11 val empty_binding: binding |
12 val is_empty_binding: binding -> bool |
12 val is_empty_binding: binding -> bool |
13 val print_attributes: Proof.context -> unit |
13 val print_attributes: Proof.context -> unit |
14 val check_name_generic: Context.generic -> xstring * Position.T -> string |
14 val check_name_generic: Context.generic -> xstring * Position.T -> string |
15 val check_src_generic: Context.generic -> src -> src |
|
16 val check_name: Proof.context -> xstring * Position.T -> string |
15 val check_name: Proof.context -> xstring * Position.T -> string |
17 val check_src: Proof.context -> src -> src |
16 val check_src: Proof.context -> src -> src |
18 val pretty_attribs: Proof.context -> src list -> Pretty.T list |
17 val pretty_attribs: Proof.context -> src list -> Pretty.T list |
19 val attribute: Proof.context -> src -> attribute |
18 val attribute: Proof.context -> src -> attribute |
20 val attribute_global: theory -> src -> attribute |
19 val attribute_global: theory -> src -> attribute |
116 |
115 |
117 |
116 |
118 (* check *) |
117 (* check *) |
119 |
118 |
120 fun check_name_generic context = #1 o Name_Space.check context (get_attributes context); |
119 fun check_name_generic context = #1 o Name_Space.check context (get_attributes context); |
121 fun check_src_generic context src = #1 (Args.check_src context (get_attributes context) src); |
|
122 |
|
123 val check_name = check_name_generic o Context.Proof; |
120 val check_name = check_name_generic o Context.Proof; |
124 val check_src = check_src_generic o Context.Proof; |
121 |
|
122 fun check_src ctxt src = #1 (Args.check_src ctxt (get_attributes (Context.Proof ctxt)) src); |
125 |
123 |
126 |
124 |
127 (* pretty printing *) |
125 (* pretty printing *) |
128 |
126 |
129 fun pretty_attrib ctxt = |
|
130 Args.pretty_src (Name_Space.pretty ctxt (attribute_space ctxt)) ctxt; |
|
131 |
|
132 fun pretty_attribs _ [] = [] |
127 fun pretty_attribs _ [] = [] |
133 | pretty_attribs ctxt srcs = [Pretty.enum "," "[" "]" (map (pretty_attrib ctxt) srcs)]; |
128 | pretty_attribs ctxt srcs = [Pretty.enum "," "[" "]" (map (Args.pretty_src ctxt) srcs)]; |
134 |
129 |
135 |
130 |
136 (* get attributes *) |
131 (* get attributes *) |
137 |
132 |
138 fun attribute_generic context = |
133 fun attribute_generic context = |
141 |
136 |
142 val attribute = attribute_generic o Context.Proof; |
137 val attribute = attribute_generic o Context.Proof; |
143 val attribute_global = attribute_generic o Context.Theory; |
138 val attribute_global = attribute_generic o Context.Theory; |
144 |
139 |
145 fun attribute_cmd ctxt = attribute ctxt o check_src ctxt; |
140 fun attribute_cmd ctxt = attribute ctxt o check_src ctxt; |
146 fun attribute_cmd_global thy = attribute_global thy o check_src_generic (Context.Theory thy); |
141 fun attribute_cmd_global thy = attribute_global thy o check_src (Proof_Context.init_global thy); |
147 |
142 |
148 |
143 |
149 (* attributed declarations *) |
144 (* attributed declarations *) |
150 |
145 |
151 fun map_specs f = map (apfst (apsnd f)); |
146 fun map_specs f = map (apfst (apsnd f)); |
172 |> fst |> maps snd; |
167 |> fst |> maps snd; |
173 |
168 |
174 |
169 |
175 (* attribute setup *) |
170 (* attribute setup *) |
176 |
171 |
177 fun syntax scan = Args.syntax "attribute" scan; |
|
178 |
|
179 fun setup name scan = |
172 fun setup name scan = |
180 add_attribute name |
173 add_attribute name |
181 (fn src => fn (ctxt, th) => let val (a, ctxt') = syntax scan src ctxt in a (ctxt', th) end); |
174 (fn src => fn (ctxt, th) => |
|
175 let val (a, ctxt') = Args.syntax_generic scan src ctxt in a (ctxt', th) end); |
182 |
176 |
183 fun attribute_setup name source cmt = |
177 fun attribute_setup name source cmt = |
184 Context.theory_map (ML_Context.expression (#pos source) |
178 Context.theory_map (ML_Context.expression (#pos source) |
185 "val (name, scan, comment): binding * attribute context_parser * string" |
179 "val (name, scan, comment): binding * attribute context_parser * string" |
186 "Context.map_theory (Attrib.setup name scan comment)" |
180 "Context.map_theory (Attrib.setup name scan comment)" |