author | wenzelm |
Fri, 28 Feb 1997 16:46:26 +0100 | |
changeset 2700 | 80e6b48c5204 |
parent 2585 | 8b92caca102c |
child 2706 | 91a640a91c6e |
permissions | -rw-r--r-- |
18 | 1 |
(* Title: Pure/Syntax/syntax.ML |
0 | 2 |
ID: $Id$ |
3 |
Author: Tobias Nipkow and Markus Wenzel, TU Muenchen |
|
18 | 4 |
|
5 |
Root of Isabelle's syntax module. |
|
0 | 6 |
*) |
7 |
||
556 | 8 |
infix |-> <-| <->; |
9 |
||
260 | 10 |
signature BASIC_SYNTAX = |
2383 | 11 |
sig |
260 | 12 |
include AST0 |
556 | 13 |
include SYN_TRANS0 |
14 |
include MIXFIX0 |
|
260 | 15 |
include PRINTER0 |
2383 | 16 |
end; |
260 | 17 |
|
0 | 18 |
signature SYNTAX = |
2383 | 19 |
sig |
260 | 20 |
include AST1 |
0 | 21 |
include LEXICON0 |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
22 |
include SYN_EXT0 |
0 | 23 |
include TYPE_EXT0 |
556 | 24 |
include SYN_TRANS1 |
25 |
include MIXFIX1 |
|
0 | 26 |
include PRINTER0 |
1158 | 27 |
datatype 'a trrule = |
2287 | 28 |
|-> of 'a * 'a | |
29 |
<-| of 'a * 'a | |
|
30 |
<-> of 'a * 'a |
|
556 | 31 |
type syntax |
32 |
val extend_log_types: syntax -> string list -> syntax |
|
33 |
val extend_type_gram: syntax -> (string * int * mixfix) list -> syntax |
|
2366 | 34 |
val extend_const_gram: syntax -> string * bool -> (string * typ * mixfix) list -> syntax |
556 | 35 |
val extend_consts: syntax -> string list -> syntax |
36 |
val extend_trfuns: syntax -> |
|
37 |
(string * (ast list -> ast)) list * |
|
38 |
(string * (term list -> term)) list * |
|
39 |
(string * (term list -> term)) list * |
|
40 |
(string * (ast list -> ast)) list -> syntax |
|
2383 | 41 |
val extend_trfunsT: syntax -> (string * (typ -> term list -> term)) list -> syntax |
2700 | 42 |
val extend_tokentrfuns: syntax -> (string * string * (string -> string * int)) list -> syntax |
1158 | 43 |
val extend_trrules: syntax -> (string * string) trrule list -> syntax |
44 |
val extend_trrules_i: syntax -> ast trrule list -> syntax |
|
556 | 45 |
val merge_syntaxes: syntax -> syntax -> syntax |
46 |
val type_syn: syntax |
|
764
b60e77395d1a
changed Pure's grammar and the way types are converted to nonterminals
clasohm
parents:
624
diff
changeset
|
47 |
val pure_syn: syntax |
556 | 48 |
val print_gram: syntax -> unit |
49 |
val print_trans: syntax -> unit |
|
50 |
val print_syntax: syntax -> unit |
|
51 |
val test_read: syntax -> string -> string -> unit |
|
624 | 52 |
val read: syntax -> typ -> string -> term list |
2585 | 53 |
val read_typ: syntax -> (sort * sort -> bool) |
54 |
-> ((indexname * sort) list -> indexname -> sort) -> string -> typ |
|
556 | 55 |
val simple_read_typ: string -> typ |
922
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
888
diff
changeset
|
56 |
val pretty_term: bool -> syntax -> term -> Pretty.T |
556 | 57 |
val pretty_typ: syntax -> typ -> Pretty.T |
922
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
888
diff
changeset
|
58 |
val string_of_term: bool -> syntax -> term -> string |
556 | 59 |
val string_of_typ: syntax -> typ -> string |
60 |
val simple_string_of_typ: typ -> string |
|
61 |
val simple_pprint_typ: typ -> pprint_args -> unit |
|
882
b118d1ea0dfd
moved ambiguity_level from sign.ML to Syntax/syntax.ML
clasohm
parents:
865
diff
changeset
|
62 |
val ambiguity_level: int ref |
2383 | 63 |
end; |
0 | 64 |
|
1511 | 65 |
structure Syntax : SYNTAX = |
0 | 66 |
struct |
67 |
||
1511 | 68 |
open Lexicon SynExt Ast Parser TypeExt SynTrans Mixfix Printer; |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
69 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
70 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
71 |
(** tables of translation functions **) |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
72 |
|
2383 | 73 |
(*does not subsume typed print translations*) |
2504 | 74 |
type 'a trtab = (('a list -> 'a) * stamp) Symtab.table; |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
75 |
|
383
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
76 |
val dest_trtab = Symtab.dest; |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
77 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
78 |
fun lookup_trtab tab c = |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
79 |
apsome fst (Symtab.lookup (tab, c)); |
0 | 80 |
|
81 |
||
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
82 |
(* empty, extend, merge trtabs *) |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
83 |
|
383
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
84 |
fun err_dup_trfuns name cs = |
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
85 |
error ("More than one " ^ name ^ " for " ^ commas_quote cs); |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
86 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
87 |
val empty_trtab = Symtab.null; |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
88 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
89 |
fun extend_trtab tab trfuns name = |
2504 | 90 |
Symtab.extend_new (tab, map (fn (c, f) => (c, (f, stamp ()))) trfuns) |
383
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
91 |
handle Symtab.DUPS cs => err_dup_trfuns name cs; |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
92 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
93 |
fun merge_trtabs tab1 tab2 name = |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
94 |
Symtab.merge eq_snd (tab1, tab2) |
383
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
95 |
handle Symtab.DUPS cs => err_dup_trfuns name cs; |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
96 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
97 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
98 |
|
2700 | 99 |
(** tables of token translation functions **) |
100 |
||
101 |
fun lookup_tokentr tabs modes = |
|
102 |
let val trs = gen_distinct eq_fst (flat (map (assocs tabs) (modes @ [""]))) |
|
103 |
in fn c => apsome fst (assoc (trs, c)) end; |
|
104 |
||
105 |
fun merge_tokentrtabs tabs1 tabs2 = |
|
106 |
let |
|
107 |
fun eq_tr ((c1, (_, s1)), (c2, (_, s2))) = c1 = c2 andalso s1 = s2; |
|
108 |
||
109 |
fun merge mode = |
|
110 |
let |
|
111 |
val trs1 = assocs tabs1 mode; |
|
112 |
val trs2 = assocs tabs2 mode; |
|
113 |
val trs = gen_distinct eq_tr (trs1 @ trs2); |
|
114 |
in |
|
115 |
(case gen_duplicates eq_fst trs of |
|
116 |
[] => (mode, trs) |
|
117 |
| dups => error ("More than one token translation function in mode " ^ |
|
118 |
quote mode ^ " for " ^ commas_quote (map fst dups))) |
|
119 |
end; |
|
120 |
in |
|
121 |
map merge (distinct (map fst (tabs1 @ tabs2))) |
|
122 |
end; |
|
123 |
||
124 |
fun extend_tokentrtab tabs tokentrs = |
|
125 |
let |
|
126 |
fun ins_tokentr (ts, (m, c, f)) = |
|
127 |
overwrite (ts, (m, ("_" ^ c, (f, stamp ())) :: assocs ts m)); |
|
128 |
in |
|
129 |
merge_tokentrtabs tabs (foldl ins_tokentr ([], tokentrs)) |
|
130 |
end; |
|
131 |
||
132 |
||
133 |
||
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
134 |
(** tables of translation rules **) |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
135 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
136 |
type ruletab = (ast * ast) list Symtab.table; |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
137 |
|
383
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
138 |
fun dest_ruletab tab = flat (map snd (Symtab.dest tab)); |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
139 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
140 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
141 |
(* lookup_ruletab *) |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
142 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
143 |
fun lookup_ruletab tab = |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
144 |
if Symtab.is_null tab then None |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
145 |
else Some (fn a => Symtab.lookup_multi (tab, a)); |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
146 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
147 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
148 |
(* empty, extend, merge ruletabs *) |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
149 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
150 |
val empty_ruletab = Symtab.null; |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
151 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
152 |
fun extend_ruletab tab rules = |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
153 |
generic_extend (op =) Symtab.dest_multi Symtab.make_multi tab |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
154 |
(map (fn r => (head_of_rule r, r)) (distinct rules)); |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
155 |
|
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
156 |
fun merge_ruletabs tab1 tab2 = |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
157 |
generic_merge (op =) Symtab.dest_multi Symtab.make_multi tab1 tab2; |
0 | 158 |
|
159 |
||
160 |
||
161 |
(** datatype syntax **) |
|
162 |
||
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
163 |
datatype syntax = |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
164 |
Syntax of { |
18 | 165 |
lexicon: lexicon, |
764
b60e77395d1a
changed Pure's grammar and the way types are converted to nonterminals
clasohm
parents:
624
diff
changeset
|
166 |
logtypes: string list, |
18 | 167 |
gram: gram, |
168 |
consts: string list, |
|
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
169 |
parse_ast_trtab: ast trtab, |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
170 |
parse_ruletab: ruletab, |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
171 |
parse_trtab: term trtab, |
2504 | 172 |
print_trtab: ((typ -> term list -> term) * stamp) Symtab.table, |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
173 |
print_ruletab: ruletab, |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
174 |
print_ast_trtab: ast trtab, |
2700 | 175 |
tokentrtab: (string * (string * ((string -> string * int) * stamp)) list) list, |
2202
cc15a7bfbe12
extend_const_gram now supports multiple disjoint printer tables;
wenzelm
parents:
1813
diff
changeset
|
176 |
prtabs: prtabs}; |
0 | 177 |
|
18 | 178 |
|
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
179 |
(* empty_syntax *) |
18 | 180 |
|
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
181 |
val empty_syntax = |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
182 |
Syntax { |
167 | 183 |
lexicon = empty_lexicon, |
764
b60e77395d1a
changed Pure's grammar and the way types are converted to nonterminals
clasohm
parents:
624
diff
changeset
|
184 |
logtypes = [], |
171 | 185 |
gram = empty_gram, |
167 | 186 |
consts = [], |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
187 |
parse_ast_trtab = empty_trtab, |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
188 |
parse_ruletab = empty_ruletab, |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
189 |
parse_trtab = empty_trtab, |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
190 |
print_trtab = empty_trtab, |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
191 |
print_ruletab = empty_ruletab, |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
192 |
print_ast_trtab = empty_trtab, |
2700 | 193 |
tokentrtab = [], |
2202
cc15a7bfbe12
extend_const_gram now supports multiple disjoint printer tables;
wenzelm
parents:
1813
diff
changeset
|
194 |
prtabs = empty_prtabs}; |
167 | 195 |
|
196 |
||
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
197 |
(* extend_syntax *) |
167 | 198 |
|
2366 | 199 |
fun extend_syntax (mode, inout) (Syntax tabs) syn_ext = |
167 | 200 |
let |
2383 | 201 |
val {lexicon, logtypes = logtypes1, gram, consts = consts1, |
2366 | 202 |
parse_ast_trtab, parse_ruletab, parse_trtab, print_trtab, print_ruletab, |
2700 | 203 |
print_ast_trtab, tokentrtab, prtabs} = tabs; |
764
b60e77395d1a
changed Pure's grammar and the way types are converted to nonterminals
clasohm
parents:
624
diff
changeset
|
204 |
val SynExt {logtypes = logtypes2, xprods, consts = consts2, parse_ast_translation, |
167 | 205 |
parse_rules, parse_translation, print_translation, print_rules, |
2700 | 206 |
print_ast_translation, token_translation} = syn_ext; |
167 | 207 |
in |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
208 |
Syntax { |
2366 | 209 |
lexicon = if inout then extend_lexicon lexicon (delims_of xprods) else lexicon, |
764
b60e77395d1a
changed Pure's grammar and the way types are converted to nonterminals
clasohm
parents:
624
diff
changeset
|
210 |
logtypes = extend_list logtypes1 logtypes2, |
2366 | 211 |
gram = if inout then extend_gram gram xprods else gram, |
167 | 212 |
consts = consts2 union consts1, |
213 |
parse_ast_trtab = |
|
214 |
extend_trtab parse_ast_trtab parse_ast_translation "parse ast translation", |
|
215 |
parse_ruletab = extend_ruletab parse_ruletab parse_rules, |
|
216 |
parse_trtab = extend_trtab parse_trtab parse_translation "parse translation", |
|
217 |
print_trtab = extend_trtab print_trtab print_translation "print translation", |
|
218 |
print_ruletab = extend_ruletab print_ruletab print_rules, |
|
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
219 |
print_ast_trtab = |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
220 |
extend_trtab print_ast_trtab print_ast_translation "print ast translation", |
2700 | 221 |
tokentrtab = extend_tokentrtab tokentrtab token_translation, |
2383 | 222 |
prtabs = extend_prtabs prtabs mode xprods} |
18 | 223 |
end; |
224 |
||
225 |
||
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
226 |
(* merge_syntaxes *) |
0 | 227 |
|
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
228 |
fun merge_syntaxes (Syntax tabs1) (Syntax tabs2) = |
0 | 229 |
let |
2383 | 230 |
val {lexicon = lexicon1, logtypes = logtypes1, gram = gram1, |
2366 | 231 |
consts = consts1, parse_ast_trtab = parse_ast_trtab1, parse_ruletab = parse_ruletab1, |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
232 |
parse_trtab = parse_trtab1, print_trtab = print_trtab1, |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
233 |
print_ruletab = print_ruletab1, print_ast_trtab = print_ast_trtab1, |
2700 | 234 |
tokentrtab = tokentrtab1, prtabs = prtabs1} = tabs1; |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
235 |
|
2383 | 236 |
val {lexicon = lexicon2, logtypes = logtypes2, gram = gram2, |
2366 | 237 |
consts = consts2, parse_ast_trtab = parse_ast_trtab2, parse_ruletab = parse_ruletab2, |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
238 |
parse_trtab = parse_trtab2, print_trtab = print_trtab2, |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
239 |
print_ruletab = print_ruletab2, print_ast_trtab = print_ast_trtab2, |
2700 | 240 |
tokentrtab = tokentrtab2, prtabs = prtabs2} = tabs2; |
0 | 241 |
in |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
242 |
Syntax { |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
243 |
lexicon = merge_lexicons lexicon1 lexicon2, |
764
b60e77395d1a
changed Pure's grammar and the way types are converted to nonterminals
clasohm
parents:
624
diff
changeset
|
244 |
logtypes = merge_lists logtypes1 logtypes2, |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
245 |
gram = merge_grams gram1 gram2, |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
246 |
consts = merge_lists consts1 consts2, |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
247 |
parse_ast_trtab = |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
248 |
merge_trtabs parse_ast_trtab1 parse_ast_trtab2 "parse ast translation", |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
249 |
parse_ruletab = merge_ruletabs parse_ruletab1 parse_ruletab2, |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
250 |
parse_trtab = merge_trtabs parse_trtab1 parse_trtab2 "parse translation", |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
251 |
print_trtab = merge_trtabs print_trtab1 print_trtab2 "print translation", |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
252 |
print_ruletab = merge_ruletabs print_ruletab1 print_ruletab2, |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
253 |
print_ast_trtab = |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
254 |
merge_trtabs print_ast_trtab1 print_ast_trtab2 "print ast translation", |
2700 | 255 |
tokentrtab = merge_tokentrtabs tokentrtab1 tokentrtab2, |
2383 | 256 |
prtabs = merge_prtabs prtabs1 prtabs2} |
0 | 257 |
end; |
258 |
||
259 |
||
260 | 260 |
(* type_syn *) |
261 |
||
2700 | 262 |
val type_syn = |
263 |
extend_syntax ("", true) empty_syntax type_ext; |
|
264 |
||
2366 | 265 |
val pure_syn = extend_syntax ("", true) type_syn pure_ext; |
260 | 266 |
|
0 | 267 |
|
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
268 |
(** inspect syntax **) |
0 | 269 |
|
260 | 270 |
fun pretty_strs_qs name strs = |
271 |
Pretty.strs (name :: map quote (sort_strings strs)); |
|
0 | 272 |
|
18 | 273 |
|
274 |
(* print_gram *) |
|
0 | 275 |
|
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
276 |
fun print_gram (Syntax tabs) = |
0 | 277 |
let |
2383 | 278 |
val {lexicon, logtypes, gram, prtabs, ...} = tabs; |
0 | 279 |
in |
260 | 280 |
Pretty.writeln (pretty_strs_qs "lexicon:" (dest_lexicon lexicon)); |
764
b60e77395d1a
changed Pure's grammar and the way types are converted to nonterminals
clasohm
parents:
624
diff
changeset
|
281 |
Pretty.writeln (Pretty.strs ("logtypes:" :: logtypes)); |
2202
cc15a7bfbe12
extend_const_gram now supports multiple disjoint printer tables;
wenzelm
parents:
1813
diff
changeset
|
282 |
Pretty.writeln (Pretty.big_list "prods:" (pretty_gram gram)); |
2383 | 283 |
Pretty.writeln (pretty_strs_qs "print modes:" (prmodes_of prtabs)) |
0 | 284 |
end; |
285 |
||
286 |
||
18 | 287 |
(* print_trans *) |
0 | 288 |
|
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
289 |
fun print_trans (Syntax tabs) = |
0 | 290 |
let |
260 | 291 |
fun pretty_trtab name tab = |
292 |
pretty_strs_qs name (map fst (dest_trtab tab)); |
|
0 | 293 |
|
260 | 294 |
fun pretty_ruletab name tab = |
295 |
Pretty.big_list name (map pretty_rule (dest_ruletab tab)); |
|
0 | 296 |
|
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
297 |
val {consts, parse_ast_trtab, parse_ruletab, parse_trtab, print_trtab, |
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
298 |
print_ruletab, print_ast_trtab, ...} = tabs; |
0 | 299 |
in |
260 | 300 |
Pretty.writeln (pretty_strs_qs "consts:" consts); |
301 |
Pretty.writeln (pretty_trtab "parse_ast_translation:" parse_ast_trtab); |
|
302 |
Pretty.writeln (pretty_ruletab "parse_rules:" parse_ruletab); |
|
303 |
Pretty.writeln (pretty_trtab "parse_translation:" parse_trtab); |
|
304 |
Pretty.writeln (pretty_trtab "print_translation:" print_trtab); |
|
305 |
Pretty.writeln (pretty_ruletab "print_rules:" print_ruletab); |
|
306 |
Pretty.writeln (pretty_trtab "print_ast_translation:" print_ast_trtab) |
|
0 | 307 |
end; |
308 |
||
309 |
||
310 |
(* print_syntax *) |
|
311 |
||
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
312 |
fun print_syntax syn = (print_gram syn; print_trans syn); |
0 | 313 |
|
314 |
||
315 |
||
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
316 |
(** read **) |
18 | 317 |
|
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
318 |
(* test_read *) |
18 | 319 |
|
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
320 |
fun test_read (Syntax tabs) root str = |
18 | 321 |
let |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
322 |
val {lexicon, gram, parse_ast_trtab, parse_ruletab, ...} = tabs; |
18 | 323 |
|
2366 | 324 |
val chars = SymbolFont.read_charnames (explode str); |
325 |
val toks = tokenize lexicon false chars; |
|
624 | 326 |
val _ = writeln ("tokens: " ^ space_implode " " (map display_token toks)); |
18 | 327 |
|
383
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
328 |
fun show_pt pt = |
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
329 |
let |
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
330 |
val raw_ast = pt_to_ast (K None) pt; |
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
331 |
val _ = writeln ("raw: " ^ str_of_ast raw_ast); |
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
332 |
val pre_ast = pt_to_ast (lookup_trtab parse_ast_trtab) pt; |
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
333 |
val _ = normalize true true (lookup_ruletab parse_ruletab) pre_ast; |
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
334 |
in () end; |
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
335 |
in |
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
336 |
seq show_pt (parse gram root toks) |
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
337 |
end; |
18 | 338 |
|
339 |
||
260 | 340 |
(* read_ast *) |
341 |
||
882
b118d1ea0dfd
moved ambiguity_level from sign.ML to Syntax/syntax.ML
clasohm
parents:
865
diff
changeset
|
342 |
val ambiguity_level = ref 1; |
b118d1ea0dfd
moved ambiguity_level from sign.ML to Syntax/syntax.ML
clasohm
parents:
865
diff
changeset
|
343 |
|
865 | 344 |
fun read_asts (Syntax tabs) xids root str = |
260 | 345 |
let |
764
b60e77395d1a
changed Pure's grammar and the way types are converted to nonterminals
clasohm
parents:
624
diff
changeset
|
346 |
val {lexicon, gram, parse_ast_trtab, logtypes, ...} = tabs; |
b60e77395d1a
changed Pure's grammar and the way types are converted to nonterminals
clasohm
parents:
624
diff
changeset
|
347 |
val root' = if root mem logtypes then logic else root; |
2366 | 348 |
val chars = SymbolFont.read_charnames (explode str); |
349 |
val pts = parse gram root' (tokenize lexicon xids chars); |
|
330
2fda15dd1e0f
changed the way a grammar is generated to allow the new parser to work;
clasohm
parents:
260
diff
changeset
|
350 |
|
624 | 351 |
fun show_pt pt = writeln (str_of_ast (pt_to_ast (K None) pt)); |
260 | 352 |
in |
888
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
353 |
if length pts > ! ambiguity_level then |
1580
e3fd931e6095
Added some functions which allow redirection of Isabelle's output
berghofe
parents:
1511
diff
changeset
|
354 |
(warning ("Ambiguous input " ^ quote str); |
882
b118d1ea0dfd
moved ambiguity_level from sign.ML to Syntax/syntax.ML
clasohm
parents:
865
diff
changeset
|
355 |
writeln "produces the following parse trees:"; |
b118d1ea0dfd
moved ambiguity_level from sign.ML to Syntax/syntax.ML
clasohm
parents:
865
diff
changeset
|
356 |
seq show_pt pts) |
624 | 357 |
else (); |
358 |
map (pt_to_ast (lookup_trtab parse_ast_trtab)) pts |
|
260 | 359 |
end; |
360 |
||
361 |
||
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
362 |
(* read *) |
0 | 363 |
|
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
364 |
fun read (syn as Syntax tabs) ty str = |
0 | 365 |
let |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
366 |
val {parse_ruletab, parse_trtab, ...} = tabs; |
865 | 367 |
val asts = read_asts syn false (typ_to_nonterm ty) str; |
0 | 368 |
in |
624 | 369 |
map (ast_to_term (lookup_trtab parse_trtab)) |
370 |
(map (normalize_ast (lookup_ruletab parse_ruletab)) asts) |
|
0 | 371 |
end; |
372 |
||
373 |
||
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
374 |
(* read types *) |
0 | 375 |
|
2585 | 376 |
fun read_typ syn eq_sort get_sort str = |
888
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
377 |
(case read syn typeT str of |
2585 | 378 |
[t] => typ_of_term (get_sort (raw_term_sorts eq_sort t)) t |
379 |
| _ => error "read_typ: ambiguous type syntax"); |
|
144 | 380 |
|
2585 | 381 |
fun simple_read_typ str = |
382 |
let fun get_sort env xi = if_none (assoc (env, xi)) [] in |
|
383 |
read_typ type_syn eq_set_string get_sort str |
|
384 |
end; |
|
144 | 385 |
|
386 |
||
18 | 387 |
|
1158 | 388 |
(** prepare translation rules **) |
389 |
||
390 |
datatype 'a trrule = |
|
888
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
391 |
op |-> of 'a * 'a | |
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
392 |
op <-| of 'a * 'a | |
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
393 |
op <-> of 'a * 'a; |
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
394 |
|
1158 | 395 |
fun map_rule f (x |-> y) = (f x |-> f y) |
396 |
| map_rule f (x <-| y) = (f x <-| f y) |
|
397 |
| map_rule f (x <-> y) = (f x <-> f y); |
|
398 |
||
399 |
fun right_rule (pat1 |-> pat2) = Some (pat1, pat2) |
|
400 |
| right_rule (pat1 <-| pat2) = None |
|
401 |
| right_rule (pat1 <-> pat2) = Some (pat1, pat2); |
|
402 |
||
403 |
fun left_rule (pat1 |-> pat2) = None |
|
404 |
| left_rule (pat1 <-| pat2) = Some (pat2, pat1) |
|
405 |
| left_rule (pat1 <-> pat2) = Some (pat2, pat1); |
|
406 |
||
407 |
||
408 |
fun check_rule (rule as (lhs, rhs)) = |
|
409 |
(case rule_error rule of |
|
410 |
Some msg => |
|
411 |
error ("Error in syntax translation rule: " ^ msg ^ "\n" ^ |
|
412 |
str_of_ast lhs ^ " -> " ^ str_of_ast rhs) |
|
413 |
| None => rule); |
|
888
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
414 |
|
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
415 |
|
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
416 |
fun read_pattern syn (root, str) = |
18 | 417 |
let |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
418 |
val Syntax {consts, ...} = syn; |
18 | 419 |
|
888
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
420 |
fun constify (ast as Constant _) = ast |
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
421 |
| constify (ast as Variable x) = |
18 | 422 |
if x mem consts then Constant x else ast |
888
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
423 |
| constify (Appl asts) = Appl (map constify asts); |
18 | 424 |
in |
888
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
425 |
(case read_asts syn true root str of |
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
426 |
[ast] => constify ast |
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
427 |
| _ => error ("Syntactically ambiguous input: " ^ quote str)) |
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
428 |
end handle ERROR => |
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
429 |
error ("The error(s) above occurred in translation pattern " ^ |
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
430 |
quote str); |
0 | 431 |
|
556 | 432 |
|
1158 | 433 |
fun prep_rules rd_pat raw_rules = |
434 |
let val rules = map (map_rule rd_pat) raw_rules in |
|
888
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
435 |
(map check_rule (mapfilter right_rule rules), |
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset
|
436 |
map check_rule (mapfilter left_rule rules)) |
1158 | 437 |
end |
18 | 438 |
|
439 |
||
440 |
||
441 |
(** pretty terms or typs **) |
|
442 |
||
2202
cc15a7bfbe12
extend_const_gram now supports multiple disjoint printer tables;
wenzelm
parents:
1813
diff
changeset
|
443 |
fun pretty_t t_to_ast prt_t curried (syn as Syntax tabs) t = |
0 | 444 |
let |
2700 | 445 |
val {print_trtab, print_ruletab, print_ast_trtab, tokentrtab, prtabs, ...} = tabs; |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
446 |
val ast = t_to_ast (lookup_trtab print_trtab) t; |
0 | 447 |
in |
2202
cc15a7bfbe12
extend_const_gram now supports multiple disjoint printer tables;
wenzelm
parents:
1813
diff
changeset
|
448 |
prt_t curried prtabs (lookup_trtab print_ast_trtab) |
2700 | 449 |
(lookup_tokentr tokentrtab (! print_mode)) |
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset
|
450 |
(normalize_ast (lookup_ruletab print_ruletab) ast) |
0 | 451 |
end; |
452 |
||
453 |
val pretty_term = pretty_t term_to_ast pretty_term_ast; |
|
922
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
888
diff
changeset
|
454 |
val pretty_typ = pretty_t typ_to_ast pretty_typ_ast false; |
0 | 455 |
|
922
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
888
diff
changeset
|
456 |
fun string_of_term curried syn t = |
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
clasohm
parents:
888
diff
changeset
|
457 |
Pretty.string_of (pretty_term curried syn t); |
260 | 458 |
fun string_of_typ syn ty = Pretty.string_of (pretty_typ syn ty); |
0 | 459 |
|
260 | 460 |
val simple_string_of_typ = string_of_typ type_syn; |
461 |
val simple_pprint_typ = Pretty.pprint o Pretty.quote o (pretty_typ type_syn); |
|
0 | 462 |
|
463 |
||
464 |
||
383
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
465 |
(** extend syntax (external interfaces) **) |
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
466 |
|
2202
cc15a7bfbe12
extend_const_gram now supports multiple disjoint printer tables;
wenzelm
parents:
1813
diff
changeset
|
467 |
fun ext_syntax mk_syn_ext prmode (syn as Syntax {logtypes, ...}) decls = |
cc15a7bfbe12
extend_const_gram now supports multiple disjoint printer tables;
wenzelm
parents:
1813
diff
changeset
|
468 |
extend_syntax prmode syn (mk_syn_ext logtypes decls); |
383
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
469 |
|
167 | 470 |
|
764
b60e77395d1a
changed Pure's grammar and the way types are converted to nonterminals
clasohm
parents:
624
diff
changeset
|
471 |
fun extend_log_types syn logtypes = |
2366 | 472 |
extend_syntax ("", true) syn (syn_ext_logtypes logtypes); |
383
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
473 |
|
2366 | 474 |
val extend_type_gram = ext_syntax syn_ext_types ("", true); |
383
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
475 |
|
2202
cc15a7bfbe12
extend_const_gram now supports multiple disjoint printer tables;
wenzelm
parents:
1813
diff
changeset
|
476 |
fun extend_const_gram syn prmode = ext_syntax syn_ext_consts prmode syn; |
383
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
477 |
|
2366 | 478 |
val extend_consts = ext_syntax syn_ext_const_names ("", true); |
383
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
479 |
|
2366 | 480 |
val extend_trfuns = ext_syntax syn_ext_trfuns ("", true); |
383
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset
|
481 |
|
2383 | 482 |
val extend_trfunsT = ext_syntax syn_ext_trfunsT ("", true); |
483 |
||
2700 | 484 |
val extend_tokentrfuns = ext_syntax syn_ext_tokentrfuns ("", true); |
485 |
||
1158 | 486 |
fun extend_trrules syn rules = |
2366 | 487 |
ext_syntax syn_ext_rules ("", true) syn (prep_rules (read_pattern syn) rules); |
1158 | 488 |
|
489 |
fun extend_trrules_i syn rules = |
|
2366 | 490 |
ext_syntax syn_ext_rules ("", true) syn (prep_rules I rules); |
491 |
||
492 |
||
0 | 493 |
end; |