author | wenzelm |
Sun, 22 Sep 2024 16:04:44 +0200 | |
changeset 80922 | e0b958719301 |
parent 80920 | bbe2c56fe255 |
child 81121 | 7cacedbddba7 |
permissions | -rw-r--r-- |
42288
2074b31650e6
discontinued special treatment of structure Syntax_Ext (formerly Syn_Ext);
wenzelm
parents:
42268
diff
changeset
|
1 |
(* Title: Pure/Syntax/syntax_ext.ML |
80893 | 2 |
Author: Makarius |
240 | 3 |
|
80893 | 4 |
Syntax extension as internal record. |
240 | 5 |
*) |
6 |
||
42288
2074b31650e6
discontinued special treatment of structure Syntax_Ext (formerly Syn_Ext);
wenzelm
parents:
42268
diff
changeset
|
7 |
signature SYNTAX_EXT = |
4050 | 8 |
sig |
62753 | 9 |
datatype mfix = Mfix of Symbol_Pos.T list * typ * string * int list * int * Position.T |
80905
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
10 |
type block = {markup: Markup.T list, consistent: bool, unbreakable: bool, indent: int} |
80893 | 11 |
val block_indent: int -> block |
1510 | 12 |
datatype xsymb = |
13 |
Delim of string | |
|
14 |
Argument of string * int | |
|
15 |
Space of string | |
|
80893 | 16 |
Bg of block | |
62783 | 17 |
Brk of int | |
18 |
En |
|
1510 | 19 |
datatype xprod = XProd of string * xsymb list * string * int |
20 |
val chain_pri: int |
|
77999 | 21 |
val delims_of: xprod list -> Symbol.symbol list list |
1510 | 22 |
datatype syn_ext = |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
35429
diff
changeset
|
23 |
Syn_Ext of { |
1510 | 24 |
xprods: xprod list, |
80748
43c4817375bf
support for syntax const dependencies, with minimal integrity checks;
wenzelm
parents:
77999
diff
changeset
|
25 |
consts: (string * string list) list, |
21772 | 26 |
parse_ast_translation: (string * ((Proof.context -> Ast.ast list -> Ast.ast) * stamp)) list, |
1510 | 27 |
parse_rules: (Ast.ast * Ast.ast) list, |
21772 | 28 |
parse_translation: (string * ((Proof.context -> term list -> term) * stamp)) list, |
42247
12fe41a92cd5
typed_print_translation: discontinued show_sorts argument;
wenzelm
parents:
42245
diff
changeset
|
29 |
print_translation: (string * ((Proof.context -> typ -> term list -> term) * stamp)) list, |
1510 | 30 |
print_rules: (Ast.ast * Ast.ast) list, |
42268 | 31 |
print_ast_translation: (string * ((Proof.context -> Ast.ast list -> Ast.ast) * stamp)) list} |
80920
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
32 |
val block_annotation: int -> Markup.T -> string -> string |
80911
8ad5e6df050b
block markup for specific notation, notably infix and binder;
wenzelm
parents:
80909
diff
changeset
|
33 |
val mfix_name: Proof.context -> Symbol_Pos.T list -> string |
80897
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
34 |
val mfix_args: Proof.context -> Symbol_Pos.T list -> int |
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
35 |
val mixfix_args: Proof.context -> Input.source -> int |
42288
2074b31650e6
discontinued special treatment of structure Syntax_Ext (formerly Syn_Ext);
wenzelm
parents:
42268
diff
changeset
|
36 |
val escape: string -> string |
80897
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
37 |
val syn_ext: Proof.context -> string list -> mfix list -> |
80748
43c4817375bf
support for syntax const dependencies, with minimal integrity checks;
wenzelm
parents:
77999
diff
changeset
|
38 |
(string * string list) list -> (string * ((Proof.context -> Ast.ast list -> Ast.ast) * stamp)) list * |
21772 | 39 |
(string * ((Proof.context -> term list -> term) * stamp)) list * |
42247
12fe41a92cd5
typed_print_translation: discontinued show_sorts argument;
wenzelm
parents:
42245
diff
changeset
|
40 |
(string * ((Proof.context -> typ -> term list -> term) * stamp)) list * |
42268 | 41 |
(string * ((Proof.context -> Ast.ast list -> Ast.ast) * stamp)) list -> |
42 |
(Ast.ast * Ast.ast) list * (Ast.ast * Ast.ast) list -> syn_ext |
|
80897
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
43 |
val syn_ext_consts: Proof.context -> (string * string list) list -> syn_ext |
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
44 |
val syn_ext_rules: Proof.context -> (Ast.ast * Ast.ast) list * (Ast.ast * Ast.ast) list -> syn_ext |
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
45 |
val syn_ext_trfuns: Proof.context -> |
21772 | 46 |
(string * ((Proof.context -> Ast.ast list -> Ast.ast) * stamp)) list * |
47 |
(string * ((Proof.context -> term list -> term) * stamp)) list * |
|
42247
12fe41a92cd5
typed_print_translation: discontinued show_sorts argument;
wenzelm
parents:
42245
diff
changeset
|
48 |
(string * ((Proof.context -> typ -> term list -> term) * stamp)) list * |
21772 | 49 |
(string * ((Proof.context -> Ast.ast list -> Ast.ast) * stamp)) list -> syn_ext |
42288
2074b31650e6
discontinued special treatment of structure Syntax_Ext (formerly Syn_Ext);
wenzelm
parents:
42268
diff
changeset
|
50 |
val stamp_trfun: stamp -> string * 'a -> string * ('a * stamp) |
2074b31650e6
discontinued special treatment of structure Syntax_Ext (formerly Syn_Ext);
wenzelm
parents:
42268
diff
changeset
|
51 |
val mk_trfun: string * 'a -> string * ('a * stamp) |
2074b31650e6
discontinued special treatment of structure Syntax_Ext (formerly Syn_Ext);
wenzelm
parents:
42268
diff
changeset
|
52 |
val eq_trfun: ('a * stamp) * ('a * stamp) -> bool |
4050 | 53 |
end; |
240 | 54 |
|
42288
2074b31650e6
discontinued special treatment of structure Syntax_Ext (formerly Syn_Ext);
wenzelm
parents:
42268
diff
changeset
|
55 |
structure Syntax_Ext: SYNTAX_EXT = |
240 | 56 |
struct |
57 |
||
58 |
(** datatype xprod **) |
|
59 |
||
60 |
(*Delim s: delimiter s |
|
61 |
Argument (s, p): nonterminal s requiring priority >= p, or valued token |
|
62 |
Space s: some white space for printing |
|
63 |
Bg, Brk, En: blocks and breaks for pretty printing*) |
|
64 |
||
80905
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
65 |
type block = {markup: Markup.T list, consistent: bool, unbreakable: bool, indent: int}; |
62789 | 66 |
|
80893 | 67 |
fun block_indent indent : block = |
80905
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
68 |
{markup = [], consistent = false, unbreakable = false, indent = indent}; |
62783 | 69 |
|
240 | 70 |
datatype xsymb = |
71 |
Delim of string | |
|
72 |
Argument of string * int | |
|
73 |
Space of string | |
|
80893 | 74 |
Bg of block | |
62783 | 75 |
Brk of int | |
76 |
En; |
|
240 | 77 |
|
12513
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
78 |
fun is_delim (Delim _) = true |
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
79 |
| is_delim _ = false; |
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
80 |
|
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
81 |
fun is_terminal (Delim _) = true |
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
82 |
| is_terminal (Argument (s, _)) = Lexicon.is_terminal s |
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
83 |
| is_terminal _ = false; |
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
84 |
|
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
85 |
fun is_argument (Argument _) = true |
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
86 |
| is_argument _ = false; |
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
87 |
|
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
88 |
fun is_index (Argument ("index", _)) = true |
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
89 |
| is_index _ = false; |
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
90 |
|
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
91 |
val index = Argument ("index", 1000); |
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
92 |
|
240 | 93 |
|
94 |
(*XProd (lhs, syms, c, p): |
|
95 |
lhs: name of nonterminal on the lhs of the production |
|
96 |
syms: list of symbols on the rhs of the production |
|
97 |
c: head of parse tree |
|
98 |
p: priority of this production*) |
|
99 |
||
100 |
datatype xprod = XProd of string * xsymb list * string * int; |
|
101 |
||
102 |
val chain_pri = ~1; (*dummy for chain productions*) |
|
103 |
||
104 |
fun delims_of xprods = |
|
19004 | 105 |
fold (fn XProd (_, xsymbs, _, _) => |
106 |
fold (fn Delim s => insert (op =) s | _ => I) xsymbs) xprods [] |
|
107 |
|> map Symbol.explode; |
|
240 | 108 |
|
109 |
||
110 |
||
111 |
(** datatype mfix **) |
|
112 |
||
62753 | 113 |
(*Mfix (sy, ty, c, ps, p, pos): |
62752 | 114 |
sy: rhs of production as symbolic text |
240 | 115 |
ty: type description of production |
116 |
c: head of parse tree |
|
117 |
ps: priorities of arguments in sy |
|
62753 | 118 |
p: priority of production |
119 |
pos: source position*) |
|
240 | 120 |
|
62753 | 121 |
datatype mfix = Mfix of Symbol_Pos.T list * typ * string * int list * int * Position.T; |
12513
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
122 |
|
240 | 123 |
|
62786 | 124 |
(* properties *) |
125 |
||
80920
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
126 |
fun block_annotation indent notation_markup notation_name = |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
127 |
let |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
128 |
val (elem, props) = notation_markup |> notation_name <> "" ? Markup.name notation_name; |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
129 |
val kind = Properties.get props Markup.kindN; |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
130 |
val name = Properties.get props Markup.nameN; |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
131 |
val s1 = if indent = 0 then [] else ["indent=" ^ Value.print_int indent]; |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
132 |
val s2 = |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
133 |
if elem = Markup.notationN then |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
134 |
[Properties.print_eq (elem, cartouche (implode_space (the_list kind @ the_list name)))] |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
135 |
else raise Fail ("Bad markup element for notatio: " ^ quote elem) |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
136 |
in cartouche (implode_space (s1 @ s2)) end; |
80911
8ad5e6df050b
block markup for specific notation, notably infix and binder;
wenzelm
parents:
80909
diff
changeset
|
137 |
|
80904 | 138 |
fun show_names names = |
139 |
commas_quote (map (fn (name, pos) => Markup.markup (Position.markup pos) name) names); |
|
140 |
||
62786 | 141 |
local |
142 |
||
143 |
open Basic_Symbol_Pos; |
|
144 |
||
145 |
val err_prefix = "Error in mixfix block properties: "; |
|
62801
f9d102ef13f1
clarified errors -- disallow cartouche fragments as delimiter;
wenzelm
parents:
62795
diff
changeset
|
146 |
val !!! = Symbol_Pos.!!! (fn () => err_prefix ^ "atom expected (identifier, numeral, cartouche)"); |
62786 | 147 |
|
148 |
val scan_atom = |
|
149 |
Symbol_Pos.scan_ident || |
|
150 |
($$$ "-" @@@ (Symbol_Pos.scan_float || Symbol_Pos.scan_nat)) || |
|
151 |
Symbol_Pos.scan_float || Symbol_Pos.scan_nat || |
|
152 |
Symbol_Pos.scan_cartouche_content err_prefix; |
|
153 |
||
154 |
val scan_blanks = Scan.many (Symbol.is_blank o Symbol_Pos.symbol); |
|
155 |
val scan_item = |
|
156 |
scan_blanks |-- scan_atom --| scan_blanks |
|
157 |
>> (fn ss => (Symbol_Pos.content ss, #1 (Symbol_Pos.range ss))); |
|
158 |
||
80904 | 159 |
val scan_prop = scan_item -- Scan.option ($$ "=" |-- !!! scan_item); |
62786 | 160 |
|
80904 | 161 |
fun get_property default0 default1 parse name props = |
162 |
(case find_first (fn ((a, _), _) => a = name) props of |
|
163 |
NONE => default0 |
|
164 |
| SOME (_, NONE) => default1 |
|
165 |
| SOME ((_, pos1), SOME (b, pos2)) => |
|
166 |
(parse (b, pos2) handle Fail msg => |
|
167 |
error (msg ^ " for property " ^ quote name ^ Position.here_list [pos1, pos2]))); |
|
62786 | 168 |
|
80920
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
169 |
fun parse_notation ctxt (s, pos) = |
80911
8ad5e6df050b
block markup for specific notation, notably infix and binder;
wenzelm
parents:
80909
diff
changeset
|
170 |
let |
8ad5e6df050b
block markup for specific notation, notably infix and binder;
wenzelm
parents:
80909
diff
changeset
|
171 |
val (kind, name) = |
8ad5e6df050b
block markup for specific notation, notably infix and binder;
wenzelm
parents:
80909
diff
changeset
|
172 |
(case Symbol.explode_words s of |
8ad5e6df050b
block markup for specific notation, notably infix and binder;
wenzelm
parents:
80909
diff
changeset
|
173 |
[] => ("", "") |
8ad5e6df050b
block markup for specific notation, notably infix and binder;
wenzelm
parents:
80909
diff
changeset
|
174 |
| a :: bs => (a, space_implode " " bs)); |
80920
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
175 |
val markup = |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
176 |
(case try (fn () => Markup_Kind.check_notation ctxt (kind, Position.none)) () of |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
177 |
SOME m => m |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
178 |
| NONE => |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
179 |
error ("Bad notation kind " ^ quote kind ^ Position.here pos ^ |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
180 |
", expected: " ^ commas_quote (Markup_Kind.get_notation_kinds ctxt))); |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
181 |
in markup |> Markup.properties (Markup.name_proper name) end; |
80911
8ad5e6df050b
block markup for specific notation, notably infix and binder;
wenzelm
parents:
80909
diff
changeset
|
182 |
|
62786 | 183 |
in |
184 |
||
185 |
fun read_properties ss = |
|
186 |
let |
|
62801
f9d102ef13f1
clarified errors -- disallow cartouche fragments as delimiter;
wenzelm
parents:
62795
diff
changeset
|
187 |
val props = |
f9d102ef13f1
clarified errors -- disallow cartouche fragments as delimiter;
wenzelm
parents:
62795
diff
changeset
|
188 |
(case Scan.error (Scan.finite Symbol_Pos.stopper (Scan.repeat scan_prop)) ss of |
f9d102ef13f1
clarified errors -- disallow cartouche fragments as delimiter;
wenzelm
parents:
62795
diff
changeset
|
189 |
(props, []) => props |
f9d102ef13f1
clarified errors -- disallow cartouche fragments as delimiter;
wenzelm
parents:
62795
diff
changeset
|
190 |
| (_, (_, pos) :: _) => error (err_prefix ^ "bad input" ^ Position.here pos)); |
80904 | 191 |
fun ok (_, bs) = length bs <= 1; |
62786 | 192 |
val _ = |
80904 | 193 |
(case AList.group (eq_fst op =) props |> filter_out ok of |
62786 | 194 |
[] => () |
80904 | 195 |
| dups => error ("Duplicate properties: " ^ show_names (map #1 dups))); |
62786 | 196 |
in props end; |
197 |
||
80904 | 198 |
val get_string = get_property "" "" #1; |
199 |
val get_bool = get_property false true (Value.parse_bool o #1); |
|
200 |
val get_nat = get_property 0 1 (Value.parse_nat o #1); |
|
62786 | 201 |
|
80920
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
202 |
fun get_notation_markup ctxt = |
bbe2c56fe255
more uniform treatment of Markup.notation and Markup.expression: manage kinds via context;
wenzelm
parents:
80919
diff
changeset
|
203 |
get_property NONE (SOME Markup.notation0) (SOME o parse_notation ctxt) Markup.notationN; |
80911
8ad5e6df050b
block markup for specific notation, notably infix and binder;
wenzelm
parents:
80909
diff
changeset
|
204 |
|
62786 | 205 |
end; |
206 |
||
207 |
||
19004 | 208 |
(* read mixfix annotations *) |
4050 | 209 |
|
210 |
local |
|
19004 | 211 |
|
80919 | 212 |
val markup_block_begin = Markup_Kind.setup_expression (Binding.make ("mixfix_block_begin", \<^here>)); |
213 |
val markup_block_end = Markup_Kind.setup_expression (Binding.make ("mixfix_block_end", \<^here>)); |
|
214 |
val markup_delimiter = Markup_Kind.setup_expression (Binding.make ("mixfix_delimiter", \<^here>)); |
|
215 |
val markup_argument = Markup_Kind.setup_expression (Binding.make ("mixfix_argument", \<^here>)); |
|
216 |
val markup_space = Markup_Kind.setup_expression (Binding.make ("mixfix_space", \<^here>)); |
|
217 |
val markup_break = Markup_Kind.setup_expression (Binding.make ("mixfix_break", \<^here>)); |
|
80889 | 218 |
|
62752 | 219 |
open Basic_Symbol_Pos; |
220 |
||
62801
f9d102ef13f1
clarified errors -- disallow cartouche fragments as delimiter;
wenzelm
parents:
62795
diff
changeset
|
221 |
val err_prefix = "Error in mixfix annotation: "; |
f9d102ef13f1
clarified errors -- disallow cartouche fragments as delimiter;
wenzelm
parents:
62795
diff
changeset
|
222 |
|
62752 | 223 |
fun scan_one pred = Scan.one (pred o Symbol_Pos.symbol); |
224 |
fun scan_many pred = Scan.many (pred o Symbol_Pos.symbol); |
|
225 |
fun scan_many1 pred = Scan.many1 (pred o Symbol_Pos.symbol); |
|
226 |
||
80889 | 227 |
fun reports_of_block pos = [(pos, markup_block_begin), (pos, Markup.keyword3)]; |
62806 | 228 |
|
62808 | 229 |
fun reports_of (xsym, pos) = |
62806 | 230 |
(case xsym of |
80889 | 231 |
Delim _ => [(pos, markup_delimiter), (pos, Markup.literal)] |
232 |
| Argument _ => [(pos, markup_argument)] |
|
233 |
| Space _ => [(pos, markup_space)] |
|
62806 | 234 |
| Bg _ => reports_of_block pos |
80889 | 235 |
| Brk _ => [(pos, markup_break), (pos, Markup.keyword3)] |
236 |
| En => [(pos, markup_block_end), (pos, Markup.keyword3)]); |
|
62806 | 237 |
|
80891 | 238 |
fun reports_text_of (Delim s, pos) = |
62808 | 239 |
if Position.is_reported pos andalso exists Symbol.is_utf8 (Symbol.explode s) then |
64677
8dc24130e8fe
more uniform treatment of "bad" like other messages (with serial number);
wenzelm
parents:
63933
diff
changeset
|
240 |
[((pos, Markup.bad ()), |
62808 | 241 |
"Mixfix delimiter contains raw Unicode -- this is non-portable and unreliable")] |
242 |
else [] |
|
80891 | 243 |
| reports_text_of _ = []; |
62808 | 244 |
|
80905
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
245 |
fun read_block_properties ctxt ss = |
62786 | 246 |
let |
247 |
val props = read_properties ss; |
|
62783 | 248 |
|
80922
e0b958719301
remove specific support for "expression" block markup: prefer "notation";
wenzelm
parents:
80920
diff
changeset
|
249 |
val more_markups = the_list (get_notation_markup ctxt props); |
80905
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
250 |
|
62786 | 251 |
val markup_name = get_string Markup.markupN props; |
80904 | 252 |
val markup_props = props |> map_filter (fn (a, opt_b) => |
253 |
if member (op =) Markup.block_properties (#1 a) then NONE |
|
80905
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
254 |
else SOME (a, the_default ("true", Position.none) opt_b)); |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
255 |
val markups = |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
256 |
if markup_name <> "" then [(markup_name, map (apply2 #1) markup_props)] |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
257 |
else if null markup_props then [] |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
258 |
else error ("Markup name required for block properties: " ^ show_names (map #1 markup_props)); |
62783 | 259 |
|
80905
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
260 |
val block: block = |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
261 |
{markup = more_markups @ markups, |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
262 |
consistent = get_bool Markup.consistentN props, |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
263 |
unbreakable = get_bool Markup.unbreakableN props, |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
264 |
indent = get_nat Markup.indentN props}; |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
265 |
in Bg block end |
62806 | 266 |
handle ERROR msg => |
267 |
let |
|
268 |
val reported_texts = |
|
269 |
reports_of_block (#1 (Symbol_Pos.range ss)) |
|
270 |
|> map (fn (p, m) => Markup.markup_report (Position.reported_text p m "")) |
|
271 |
in error (msg ^ implode reported_texts) end; |
|
62783 | 272 |
|
273 |
val read_block_indent = |
|
62789 | 274 |
Bg o block_indent o #1 o Library.read_int o map Symbol_Pos.symbol; |
62783 | 275 |
|
71545
b0b16088ccf2
allow slightly odd "' " in mixfix as documented (introduced in 55754d6d399c, but broken in be8a8d60d962);
wenzelm
parents:
69584
diff
changeset
|
276 |
val is_meta = member (op =) ["'", "(", ")", "/", "_", "\<index>", Symbol.open_, Symbol.close]; |
19004 | 277 |
|
63933 | 278 |
val scan_delim = |
279 |
scan_one Symbol.is_control ::: Symbol_Pos.scan_cartouche "Mixfix error: " || |
|
280 |
$$ "'" |-- scan_one ((not o Symbol.is_blank) andf Symbol.not_eof) >> single || |
|
281 |
scan_one ((not o is_meta) andf (not o Symbol.is_blank) andf Symbol.not_eof) >> single; |
|
19004 | 282 |
|
80905
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
283 |
fun scan_symbs ctxt = |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
284 |
let |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
285 |
val scan_sym = |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
286 |
$$ "_" >> K (Argument ("", 0)) || |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
287 |
$$ "\<index>" >> K index || |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
288 |
$$ "(" |-- |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
289 |
(Symbol_Pos.scan_cartouche_content err_prefix >> read_block_properties ctxt || |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
290 |
scan_many Symbol.is_digit >> read_block_indent) || |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
291 |
$$ ")" >> K En || |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
292 |
$$ "/" -- $$ "/" >> K (Brk ~1) || |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
293 |
$$ "/" |-- scan_many Symbol.is_space >> (Brk o length) || |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
294 |
scan_many1 Symbol.is_space >> (Space o Symbol_Pos.content) || |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
295 |
Scan.repeat1 scan_delim >> (Delim o Symbol_Pos.content o flat); |
14819 | 296 |
|
80905
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
297 |
val scan_symb = |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
298 |
Scan.trace scan_sym >> (fn (syms, trace) => SOME (syms, #1 (Symbol_Pos.range trace))) || |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
299 |
$$ "'" -- scan_one Symbol.is_space >> K NONE; |
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
300 |
in Scan.repeat scan_symb --| Scan.ahead (~$$ "'") end; |
4050 | 301 |
|
19004 | 302 |
in |
12513
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
303 |
|
80897
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
304 |
fun read_mfix ctxt ss = |
62764 | 305 |
let |
62801
f9d102ef13f1
clarified errors -- disallow cartouche fragments as delimiter;
wenzelm
parents:
62795
diff
changeset
|
306 |
val xsymbs = |
80905
47793a46d06c
support for Markup.expression properties in pretty-blocks;
wenzelm
parents:
80904
diff
changeset
|
307 |
(case Scan.error (Scan.finite Symbol_Pos.stopper (scan_symbs ctxt)) ss of |
62801
f9d102ef13f1
clarified errors -- disallow cartouche fragments as delimiter;
wenzelm
parents:
62795
diff
changeset
|
308 |
(res, []) => map_filter I res |
f9d102ef13f1
clarified errors -- disallow cartouche fragments as delimiter;
wenzelm
parents:
62795
diff
changeset
|
309 |
| (_, (_, pos) :: _) => error (err_prefix ^ "bad input" ^ Position.here pos)); |
80897
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
310 |
val _ = Context_Position.reports ctxt (maps reports_of xsymbs); |
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
311 |
val _ = Context_Position.reports_text ctxt (maps reports_text_of xsymbs); |
62764 | 312 |
in xsymbs end; |
19004 | 313 |
|
80908 | 314 |
val read_mfix0 = read_mfix o Context_Position.set_visible false; |
315 |
||
80911
8ad5e6df050b
block markup for specific notation, notably infix and binder;
wenzelm
parents:
80909
diff
changeset
|
316 |
fun mfix_name ctxt = |
8ad5e6df050b
block markup for specific notation, notably infix and binder;
wenzelm
parents:
80909
diff
changeset
|
317 |
read_mfix0 ctxt #> map_filter (fn (Delim s, _) => SOME s | _ => NONE) #> space_implode " "; |
8ad5e6df050b
block markup for specific notation, notably infix and binder;
wenzelm
parents:
80909
diff
changeset
|
318 |
|
80908 | 319 |
fun mfix_args ctxt ss = |
320 |
Integer.build (read_mfix0 ctxt ss |> fold (fn (xsymb, _) => is_argument xsymb ? Integer.add 1)); |
|
80897
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
321 |
|
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
322 |
fun mixfix_args ctxt = mfix_args ctxt o Input.source_explode; |
19004 | 323 |
|
35390 | 324 |
val escape = implode o map (fn s => if is_meta s then "'" ^ s else s) o Symbol.explode; |
19004 | 325 |
|
4050 | 326 |
end; |
327 |
||
328 |
||
240 | 329 |
(* mfix_to_xprod *) |
330 |
||
80897
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
331 |
fun mfix_to_xprod ctxt logical_types (Mfix (sy, typ, const, pris, pri, pos)) = |
240 | 332 |
let |
80895 | 333 |
val nonterm_for_lhs = the_default "logic" o try dest_Type_name; |
334 |
val nonterm_for_rhs = the_default "any" o try dest_Type_name; |
|
335 |
||
80899
51c338103975
proper Context_Position.report, following 5328d67ec647;
wenzelm
parents:
80897
diff
changeset
|
336 |
val _ = Context_Position.report ctxt pos Markup.language_mixfix; |
80897
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
337 |
val symbs0 = read_mfix ctxt sy; |
62764 | 338 |
|
62762 | 339 |
fun err_in_mixfix msg = error (msg ^ " in mixfix annotation" ^ Position.here pos); |
240 | 340 |
|
62762 | 341 |
fun check_blocks [] pending bad = pending @ bad |
342 |
| check_blocks ((Bg _, pos) :: rest) pending bad = check_blocks rest (pos :: pending) bad |
|
343 |
| check_blocks ((En, pos) :: rest) [] bad = check_blocks rest [] (pos :: bad) |
|
344 |
| check_blocks ((En, _) :: rest) (_ :: pending) bad = check_blocks rest pending bad |
|
345 |
| check_blocks (_ :: rest) pending bad = check_blocks rest pending bad; |
|
240 | 346 |
|
80895 | 347 |
fun add_args [] ty [] = ([], nonterm_for_lhs ty) |
62762 | 348 |
| add_args [] _ _ = err_in_mixfix "Too many precedences" |
349 |
| add_args ((sym as (Argument ("index", _), _)) :: syms) ty ps = |
|
350 |
add_args syms ty ps |>> cons sym |
|
351 |
| add_args ((Argument _, pos) :: syms) (Type ("fun", [ty, tys])) [] = |
|
80895 | 352 |
add_args syms tys [] |>> cons (Argument (nonterm_for_rhs ty, 0), pos) |
62762 | 353 |
| add_args ((Argument _, pos) :: syms) (Type ("fun", [ty, tys])) (p :: ps) = |
80895 | 354 |
add_args syms tys ps |>> cons (Argument (nonterm_for_rhs ty, p), pos) |
62762 | 355 |
| add_args ((Argument _, _) :: _) _ _ = |
356 |
err_in_mixfix "More arguments than in corresponding type" |
|
357 |
| add_args (sym :: syms) ty ps = add_args syms ty ps |>> cons sym; |
|
358 |
||
359 |
fun logical_args (a as (Argument (s, p))) = |
|
360 |
if s <> "prop" andalso member (op =) logical_types s then Argument ("logic", p) else a |
|
361 |
| logical_args a = a; |
|
240 | 362 |
|
363 |
fun rem_pri (Argument (s, _)) = Argument (s, chain_pri) |
|
364 |
| rem_pri sym = sym; |
|
365 |
||
62764 | 366 |
val indexes = filter (is_index o #1) symbs0; |
62762 | 367 |
val _ = |
368 |
if length indexes <= 1 then () |
|
369 |
else error ("More than one index argument" ^ Position.here_list (map #2 indexes)); |
|
2364 | 370 |
|
62764 | 371 |
val args = map_filter (fn (arg as Argument _, _) => SOME arg | _ => NONE) symbs0; |
44470
6c6c31ef6bb2
more accurate treatment of index syntax constants, for proper entity references in concrete notation (e.g. infix "\<oplus>\<index>");
wenzelm
parents:
43329
diff
changeset
|
372 |
val (const', typ', syntax_consts, parse_rules) = |
6c6c31ef6bb2
more accurate treatment of index syntax constants, for proper entity references in concrete notation (e.g. infix "\<oplus>\<index>");
wenzelm
parents:
43329
diff
changeset
|
373 |
if not (exists is_index args) then (const, typ, NONE, NONE) |
12513
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
374 |
else |
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
375 |
let |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35390
diff
changeset
|
376 |
val indexed_const = |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35390
diff
changeset
|
377 |
if const <> "" then const ^ "_indexed" |
62762 | 378 |
else err_in_mixfix "Missing constant name for indexed syntax"; |
14697 | 379 |
val rangeT = Term.range_type typ handle Match => |
62762 | 380 |
err_in_mixfix "Missing structure argument for indexed syntax"; |
12513
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
381 |
|
43329
84472e198515
tuned signature: Name.invent and Name.invent_names;
wenzelm
parents:
43323
diff
changeset
|
382 |
val xs = map Ast.Variable (Name.invent Name.context "xa" (length args - 1)); |
19012 | 383 |
val (xs1, xs2) = chop (find_index is_index args) xs; |
12513
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
384 |
val i = Ast.Variable "i"; |
62762 | 385 |
val lhs = |
386 |
Ast.mk_appl (Ast.Constant indexed_const) |
|
387 |
(xs1 @ [Ast.mk_appl (Ast.Constant "_index") [i]] @ xs2); |
|
14697 | 388 |
val rhs = Ast.mk_appl (Ast.Constant const) (i :: xs); |
80748
43c4817375bf
support for syntax const dependencies, with minimal integrity checks;
wenzelm
parents:
77999
diff
changeset
|
389 |
in (indexed_const, rangeT, SOME (indexed_const, [const]), SOME (lhs, rhs)) end; |
12513
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
390 |
|
62764 | 391 |
val (symbs1, lhs) = add_args symbs0 typ' pris; |
12513
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
392 |
|
2364 | 393 |
val copy_prod = |
20675 | 394 |
(lhs = "prop" orelse lhs = "logic") |
2364 | 395 |
andalso const <> "" |
62764 | 396 |
andalso not (null symbs1) |
397 |
andalso not (exists (is_delim o #1) symbs1); |
|
2364 | 398 |
val lhs' = |
62764 | 399 |
if copy_prod orelse lhs = "prop" andalso map #1 symbs1 = [Argument ("prop'", 0)] then lhs |
42293
6cca0343ea48
renamed sprop "prop#" to "prop'" -- proper identifier;
wenzelm
parents:
42288
diff
changeset
|
400 |
else if lhs = "prop" then "prop'" |
62762 | 401 |
else if member (op =) logical_types lhs then "logic" |
2364 | 402 |
else lhs; |
62764 | 403 |
val symbs2 = map (apfst logical_args) symbs1; |
240 | 404 |
|
62762 | 405 |
val _ = |
406 |
(pri :: pris) |> List.app (fn p => |
|
407 |
if p >= 0 andalso p <= 1000 then () |
|
408 |
else err_in_mixfix ("Precedence " ^ string_of_int p ^ " out of range")); |
|
409 |
val _ = |
|
62764 | 410 |
(case check_blocks symbs2 [] [] of |
62762 | 411 |
[] => () |
412 |
| bad => error ("Unbalanced block parentheses" ^ Position.here_list bad)); |
|
413 |
||
62764 | 414 |
val xprod = XProd (lhs', map #1 symbs2, const', pri); |
12513
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
415 |
val xprod' = |
62762 | 416 |
if Lexicon.is_terminal lhs' then |
417 |
err_in_mixfix ("Illegal use of terminal " ^ quote lhs' ^ " as nonterminal") |
|
12513
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
418 |
else if const <> "" then xprod |
62764 | 419 |
else if length (filter (is_argument o #1) symbs2) <> 1 then |
62762 | 420 |
err_in_mixfix "Copy production must have exactly one argument" |
62764 | 421 |
else if exists (is_terminal o #1) symbs2 then xprod |
422 |
else XProd (lhs', map (rem_pri o #1) symbs2, "", chain_pri); |
|
12513
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
423 |
|
44470
6c6c31ef6bb2
more accurate treatment of index syntax constants, for proper entity references in concrete notation (e.g. infix "\<oplus>\<index>");
wenzelm
parents:
43329
diff
changeset
|
424 |
in (xprod', syntax_consts, parse_rules) end; |
12513
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
425 |
|
240 | 426 |
|
427 |
||
428 |
(** datatype syn_ext **) |
|
429 |
||
430 |
datatype syn_ext = |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
35429
diff
changeset
|
431 |
Syn_Ext of { |
240 | 432 |
xprods: xprod list, |
80748
43c4817375bf
support for syntax const dependencies, with minimal integrity checks;
wenzelm
parents:
77999
diff
changeset
|
433 |
consts: (string * string list) list, |
21772 | 434 |
parse_ast_translation: (string * ((Proof.context -> Ast.ast list -> Ast.ast) * stamp)) list, |
1510 | 435 |
parse_rules: (Ast.ast * Ast.ast) list, |
21772 | 436 |
parse_translation: (string * ((Proof.context -> term list -> term) * stamp)) list, |
42247
12fe41a92cd5
typed_print_translation: discontinued show_sorts argument;
wenzelm
parents:
42245
diff
changeset
|
437 |
print_translation: (string * ((Proof.context -> typ -> term list -> term) * stamp)) list, |
1510 | 438 |
print_rules: (Ast.ast * Ast.ast) list, |
42268 | 439 |
print_ast_translation: (string * ((Proof.context -> Ast.ast list -> Ast.ast) * stamp)) list}; |
240 | 440 |
|
441 |
||
442 |
(* syn_ext *) |
|
443 |
||
80897
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
444 |
fun syn_ext ctxt logical_types mfixes consts trfuns (parse_rules, print_rules) = |
240 | 445 |
let |
446 |
val (parse_ast_translation, parse_translation, print_translation, |
|
447 |
print_ast_translation) = trfuns; |
|
448 |
||
80897
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
449 |
val xprod_results = map (mfix_to_xprod ctxt logical_types) mfixes; |
44470
6c6c31ef6bb2
more accurate treatment of index syntax constants, for proper entity references in concrete notation (e.g. infix "\<oplus>\<index>");
wenzelm
parents:
43329
diff
changeset
|
450 |
val xprods = map #1 xprod_results; |
6c6c31ef6bb2
more accurate treatment of index syntax constants, for proper entity references in concrete notation (e.g. infix "\<oplus>\<index>");
wenzelm
parents:
43329
diff
changeset
|
451 |
val consts' = map_filter #2 xprod_results; |
6c6c31ef6bb2
more accurate treatment of index syntax constants, for proper entity references in concrete notation (e.g. infix "\<oplus>\<index>");
wenzelm
parents:
43329
diff
changeset
|
452 |
val parse_rules' = rev (map_filter #3 xprod_results); |
80748
43c4817375bf
support for syntax const dependencies, with minimal integrity checks;
wenzelm
parents:
77999
diff
changeset
|
453 |
val mfix_consts = map (fn Mfix x => (#3 x, [])) mfixes @ map (fn XProd x => (#3 x, [])) xprods; |
240 | 454 |
in |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
35429
diff
changeset
|
455 |
Syn_Ext { |
624 | 456 |
xprods = xprods, |
44470
6c6c31ef6bb2
more accurate treatment of index syntax constants, for proper entity references in concrete notation (e.g. infix "\<oplus>\<index>");
wenzelm
parents:
43329
diff
changeset
|
457 |
consts = mfix_consts @ consts' @ consts, |
240 | 458 |
parse_ast_translation = parse_ast_translation, |
12513
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
459 |
parse_rules = parse_rules' @ parse_rules, |
240 | 460 |
parse_translation = parse_translation, |
461 |
print_translation = print_translation, |
|
12513
0ffb824dc95c
support for ``indexed syntax'' (using "\<index>" argument instead of "_");
wenzelm
parents:
11546
diff
changeset
|
462 |
print_rules = map swap parse_rules' @ print_rules, |
42268 | 463 |
print_ast_translation = print_ast_translation} |
240 | 464 |
end; |
465 |
||
2382 | 466 |
|
80897
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
467 |
fun syn_ext_consts ctxt consts = syn_ext ctxt [] [] consts ([], [], [], []) ([], []); |
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
468 |
fun syn_ext_rules ctxt rules = syn_ext ctxt [] [] [] ([], [], [], []) rules; |
5328d67ec647
more explicit context for syn_ext/mixfix operations, but it often degenerates to background theory;
wenzelm
parents:
80895
diff
changeset
|
469 |
fun syn_ext_trfuns ctxt trfuns = syn_ext ctxt [] [] [] trfuns ([], []); |
16610 | 470 |
|
15754 | 471 |
fun stamp_trfun s (c, f) = (c, (f, s)); |
472 |
fun mk_trfun tr = stamp_trfun (stamp ()) tr; |
|
29318
6337d1cb2ba0
added numeral, which supercedes num, xnum, float;
wenzelm
parents:
28904
diff
changeset
|
473 |
fun eq_trfun ((_, s1: stamp), (_, s2)) = s1 = s2; |
15754 | 474 |
|
240 | 475 |
end; |