equal
deleted
inserted
replaced
12 type T |
12 type T |
13 val syn_of: T -> Syntax.syntax |
13 val syn_of: T -> Syntax.syntax |
14 val structs_of: T -> string list |
14 val structs_of: T -> string list |
15 val init: theory -> T |
15 val init: theory -> T |
16 val rebuild: theory -> T -> T |
16 val rebuild: theory -> T -> T |
|
17 val add_syntax: theory -> (bool * (string * typ * mixfix)) list -> T -> T |
17 val set_mode: string * bool -> T -> T |
18 val set_mode: string * bool -> T -> T |
18 val restore_mode: T -> T -> T |
19 val restore_mode: T -> T -> T |
19 val add_syntax: theory -> (bool * (string * typ * mixfix)) list -> T -> T |
20 val add_modesyntax: theory -> string * bool -> (bool * (string * typ * mixfix)) list -> T -> T |
20 val extern_term: T -> term -> term |
21 val extern_term: T -> term -> term |
21 end; |
22 end; |
22 |
23 |
23 structure LocalSyntax: LOCAL_SYNTAX = |
24 structure LocalSyntax: LOCAL_SYNTAX = |
24 struct |
25 struct |
71 fun rebuild thy (syntax as Syntax {mode, mixfixes, idents, ...}) = |
72 fun rebuild thy (syntax as Syntax {mode, mixfixes, idents, ...}) = |
72 if is_consistent thy syntax then syntax |
73 if is_consistent thy syntax then syntax |
73 else build_syntax thy mode mixfixes idents; |
74 else build_syntax thy mode mixfixes idents; |
74 |
75 |
75 |
76 |
76 (* syntax mode *) |
|
77 |
|
78 fun set_mode mode = map_syntax (fn (thy_syntax, local_syntax, _, mixfixes, idents) => |
|
79 (thy_syntax, local_syntax, mode, mixfixes, idents)); |
|
80 |
|
81 fun restore_mode (Syntax {mode, ...}) = set_mode mode; |
|
82 |
|
83 |
|
84 (* mixfix declarations *) |
77 (* mixfix declarations *) |
85 |
78 |
86 local |
79 local |
87 |
80 |
88 fun mixfix_nosyn (_, (_, _, mx)) = mx = NoSyn; |
81 fun mixfix_nosyn (_, (_, _, mx)) = mx = NoSyn; |
118 in build_syntax thy mode mixfixes' (structs', fixes') end); |
111 in build_syntax thy mode mixfixes' (structs', fixes') end); |
119 |
112 |
120 end; |
113 end; |
121 |
114 |
122 |
115 |
|
116 (* syntax mode *) |
|
117 |
|
118 fun set_mode mode = map_syntax (fn (thy_syntax, local_syntax, _, mixfixes, idents) => |
|
119 (thy_syntax, local_syntax, mode, mixfixes, idents)); |
|
120 |
|
121 fun restore_mode (Syntax {mode, ...}) = set_mode mode; |
|
122 |
|
123 fun add_modesyntax thy mode args syntax = |
|
124 syntax |> set_mode mode |> add_syntax thy args |> restore_mode syntax; |
|
125 |
|
126 |
123 (* extern_term *) |
127 (* extern_term *) |
124 |
128 |
125 fun extern_term syntax = |
129 fun extern_term syntax = |
126 let |
130 let |
127 val (structs, fixes) = idents_of syntax; |
131 val (structs, fixes) = idents_of syntax; |