author  wenzelm 
Mon, 23 Jul 2007 14:06:14 +0200  
changeset 23923  8c10f3515633 
parent 23660  18765718cf62 
child 24247  9d0bb01f6634 
permissions  rwrr 
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 

260  8 
signature BASIC_SYNTAX = 
2383  9 
sig 
260  10 
include AST0 
556  11 
include SYN_TRANS0 
12 
include MIXFIX0 

260  13 
include PRINTER0 
2383  14 
end; 
260  15 

0  16 
signature SYNTAX = 
2383  17 
sig 
260  18 
include AST1 
0  19 
include LEXICON0 
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

20 
include SYN_EXT0 
0  21 
include TYPE_EXT0 
556  22 
include SYN_TRANS1 
23 
include MIXFIX1 

0  24 
include PRINTER0 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

25 
val extend_trtab: string > (string * ('a * stamp)) list > 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

26 
('a * stamp) Symtab.table > ('a * stamp) Symtab.table 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

27 
val merge_trtabs: string > ('a * stamp) Symtab.table > ('a * stamp) Symtab.table > 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

28 
('a * stamp) Symtab.table 
14648
0e67b385a6df
tuned interfaces to accomodate advanced translation functions;
wenzelm
parents:
14598
diff
changeset

29 
val merge_tr'tabs: ('a * stamp) list Symtab.table > ('a * stamp) list Symtab.table 
0e67b385a6df
tuned interfaces to accomodate advanced translation functions;
wenzelm
parents:
14598
diff
changeset

30 
> ('a * stamp) list Symtab.table 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

31 
val extend_tr'tab: (string * ('a * stamp)) list > 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

32 
('a * stamp) list Symtab.table > ('a * stamp) list Symtab.table 
1158  33 
datatype 'a trrule = 
3526  34 
ParseRule of 'a * 'a  
35 
PrintRule of 'a * 'a  

36 
ParsePrintRule of 'a * 'a 

556  37 
type syntax 
17079  38 
val eq_syntax: syntax * syntax > bool 
14687  39 
val is_keyword: syntax > string > bool 
20784  40 
type mode 
41 
val default_mode: mode 

21702  42 
val input_mode: mode 
21826  43 
val internalM: string 
12073
b4401452928e
extend_XXX: sane argument order ... > syntax > syntax;
wenzelm
parents:
11546
diff
changeset

44 
val extend_type_gram: (string * int * mixfix) list > syntax > syntax 
14904
7d8dc92fcb7f
removed separate logtypes field of syntax; removed test_read, simple_str_of_sort, simple_string_of_typ; provide default_mode;
wenzelm
parents:
14798
diff
changeset

45 
val extend_const_gram: (string > bool) > 
20784  46 
mode > (string * typ * mixfix) list > syntax > syntax 
12073
b4401452928e
extend_XXX: sane argument order ... > syntax > syntax;
wenzelm
parents:
11546
diff
changeset

47 
val extend_consts: string list > syntax > syntax 
b4401452928e
extend_XXX: sane argument order ... > syntax > syntax;
wenzelm
parents:
11546
diff
changeset

48 
val extend_trfuns: 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

49 
(string * ((ast list > ast) * stamp)) list * 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

50 
(string * ((term list > term) * stamp)) list * 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

51 
(string * ((bool > typ > term list > term) * stamp)) list * 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

52 
(string * ((ast list > ast) * stamp)) list > syntax > syntax 
16613
76e57e08dcb5
proper treatment of advanced trfuns: pass thy argument;
wenzelm
parents:
15833
diff
changeset

53 
val extend_advanced_trfuns: 
21772  54 
(string * ((Proof.context > ast list > ast) * stamp)) list * 
55 
(string * ((Proof.context > term list > term) * stamp)) list * 

56 
(string * ((Proof.context > bool > typ > term list > term) * stamp)) list * 

57 
(string * ((Proof.context > ast list > ast) * stamp)) list > syntax > syntax 

23660
18765718cf62
type output = string indicates raw system output;
wenzelm
parents:
23655
diff
changeset

58 
val extend_tokentrfuns: (string * string * (string > output * int)) list > syntax > syntax 
19262  59 
val remove_const_gram: (string > bool) > 
20784  60 
mode > (string * typ * mixfix) list > syntax > syntax 
21772  61 
val extend_trrules: Proof.context > (string > bool) > syntax > 
14904
7d8dc92fcb7f
removed separate logtypes field of syntax; removed test_read, simple_str_of_sort, simple_string_of_typ; provide default_mode;
wenzelm
parents:
14798
diff
changeset

62 
(string * string) trrule list > syntax > syntax 
21772  63 
val remove_trrules: Proof.context > (string > bool) > syntax > 
19262  64 
(string * string) trrule list > syntax > syntax 
65 
val extend_trrules_i: ast trrule list > syntax > syntax 

66 
val remove_trrules_i: ast trrule list > syntax > syntax 

4618  67 
val map_trrule: ('a > 'b) > 'a trrule > 'b trrule 
556  68 
val merge_syntaxes: syntax > syntax > syntax 
18720  69 
val basic_syn: syntax 
70 
val basic_nonterms: string list 

71 
val appl_syntax: (string * string * mixfix) list 

72 
val applC_syntax: (string * string * mixfix) list 

556  73 
val print_gram: syntax > unit 
74 
val print_trans: syntax > unit 

75 
val print_syntax: syntax > unit 

21772  76 
val read: Proof.context > (string > bool) > syntax > typ > string > term list 
22703  77 
val read_term: 
78 
(((string * int) * sort) list > string * int > Term.sort) > 

79 
(string > string option) > (string > string option) > 

80 
(typ > typ) > (sort > sort) > Proof.context > 

81 
(string > bool) > syntax > typ > string > term list 

21772  82 
val read_typ: Proof.context > syntax > ((indexname * sort) list > indexname > sort) > 
16613
76e57e08dcb5
proper treatment of advanced trfuns: pass thy argument;
wenzelm
parents:
15833
diff
changeset

83 
(sort > sort) > string > typ 
22703  84 
val read_sort: Proof.context > syntax > (sort > sort) > string > sort 
21772  85 
val pretty_term: (string > xstring) > Proof.context > syntax > bool > term > Pretty.T 
86 
val pretty_typ: Proof.context > syntax > typ > Pretty.T 

87 
val pretty_sort: Proof.context > syntax > sort > Pretty.T 

882
b118d1ea0dfd
moved ambiguity_level from sign.ML to Syntax/syntax.ML
clasohm
parents:
865
diff
changeset

88 
val ambiguity_level: int ref 
14177
06b19a7e675a
Added 'ambiguity_is_error' flag, which, if set, makes the parser fail,
skalberg
parents:
12785
diff
changeset

89 
val ambiguity_is_error: bool ref 
2383  90 
end; 
0  91 

12094  92 
structure Syntax: SYNTAX = 
0  93 
struct 
94 

237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

95 
(** tables of translation functions **) 
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

96 

5692  97 
(* parse (ast) translations *) 
98 

17412  99 
fun lookup_tr tab c = Option.map fst (Symtab.lookup tab c); 
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

100 

23655
d2d1138e0ddc
replaced exception TableFun/GraphFun.DUPS by TableFun/GraphFun.DUP;
wenzelm
parents:
23631
diff
changeset

101 
fun err_dup_trfun name c = 
d2d1138e0ddc
replaced exception TableFun/GraphFun.DUPS by TableFun/GraphFun.DUP;
wenzelm
parents:
23631
diff
changeset

102 
error ("More than one " ^ name ^ " for " ^ quote c); 
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

103 

21536
f119c730f509
extend_trtab: allow identical trfuns to be overwritten;
wenzelm
parents:
20784
diff
changeset

104 
fun remove_trtab trfuns = fold (Symtab.remove SynExt.eq_trfun) trfuns; 
f119c730f509
extend_trtab: allow identical trfuns to be overwritten;
wenzelm
parents:
20784
diff
changeset

105 

f119c730f509
extend_trtab: allow identical trfuns to be overwritten;
wenzelm
parents:
20784
diff
changeset

106 
fun extend_trtab name trfuns tab = Symtab.extend (remove_trtab trfuns tab, trfuns) 
23655
d2d1138e0ddc
replaced exception TableFun/GraphFun.DUPS by TableFun/GraphFun.DUP;
wenzelm
parents:
23631
diff
changeset

107 
handle Symtab.DUP c => err_dup_trfun name c; 
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

108 

15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

109 
fun merge_trtabs name tab1 tab2 = Symtab.merge SynExt.eq_trfun (tab1, tab2) 
23655
d2d1138e0ddc
replaced exception TableFun/GraphFun.DUPS by TableFun/GraphFun.DUP;
wenzelm
parents:
23631
diff
changeset

110 
handle Symtab.DUP c => err_dup_trfun name c; 
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

111 

a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

112 

5692  113 
(* print (ast) translations *) 
114 

18931  115 
fun lookup_tr' tab c = map fst (Symtab.lookup_list tab c); 
116 
fun extend_tr'tab trfuns = fold_rev Symtab.update_list trfuns; 

117 
fun remove_tr'tab trfuns = fold (Symtab.remove_list SynExt.eq_trfun) trfuns; 

118 
fun merge_tr'tabs tab1 tab2 = Symtab.merge_list SynExt.eq_trfun (tab1, tab2); 

5692  119 

120 

237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

121 

2700  122 
(** tables of token translation functions **) 
123 

124 
fun lookup_tokentr tabs modes = 

19482
9f11af8f7ef9
tuned basic list operators (flat, maps, map_filter);
wenzelm
parents:
19375
diff
changeset

125 
let val trs = distinct (eq_fst (op =)) (maps (these o AList.lookup (op =) tabs) (modes @ [""])) 
17314  126 
in fn c => Option.map fst (AList.lookup (op =) trs c) end; 
2700  127 

128 
fun merge_tokentrtabs tabs1 tabs2 = 

129 
let 

130 
fun eq_tr ((c1, (_, s1)), (c2, (_, s2))) = c1 = c2 andalso s1 = s2; 

131 

4703  132 
fun name (s, _) = implode (tl (Symbol.explode s)); 
2706  133 

2700  134 
fun merge mode = 
135 
let 

17213  136 
val trs1 = these (AList.lookup (op =) tabs1 mode); 
137 
val trs2 = these (AList.lookup (op =) tabs2 mode); 

19046
bc5c6c9b114e
removed distinct, renamed gen_distinct to distinct;
wenzelm
parents:
18977
diff
changeset

138 
val trs = distinct eq_tr (trs1 @ trs2); 
2700  139 
in 
18964  140 
(case duplicates (eq_fst (op =)) trs of 
2700  141 
[] => (mode, trs) 
142 
 dups => error ("More than one token translation function in mode " ^ 

2706  143 
quote mode ^ " for " ^ commas_quote (map name dups))) 
2700  144 
end; 
19046
bc5c6c9b114e
removed distinct, renamed gen_distinct to distinct;
wenzelm
parents:
18977
diff
changeset

145 
in map merge (distinct (op =) (map fst (tabs1 @ tabs2))) end; 
2700  146 

15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

147 
fun extend_tokentrtab tokentrs tabs = 
2700  148 
let 
17213  149 
fun ins_tokentr (m, c, f) = 
150 
AList.default (op =) (m, []) 

151 
#> AList.map_entry (op =) m (cons ("_" ^ c, (f, stamp ()))); 

15759  152 
in merge_tokentrtabs tabs (fold ins_tokentr tokentrs []) end; 
2700  153 

154 

155 

237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

156 
(** tables of translation rules **) 
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

157 

5692  158 
type ruletab = (Ast.ast * Ast.ast) list Symtab.table; 
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

159 

19482
9f11af8f7ef9
tuned basic list operators (flat, maps, map_filter);
wenzelm
parents:
19375
diff
changeset

160 
fun dest_ruletab tab = maps snd (Symtab.dest tab); 
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

161 

a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

162 

a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

163 
(* empty, extend, merge ruletabs *) 
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

164 

18931  165 
val extend_ruletab = fold_rev (fn r => Symtab.update_list (Ast.head_of_rule r, r)); 
166 
val remove_ruletab = fold (fn r => Symtab.remove_list (op =) (Ast.head_of_rule r, r)); 

167 
fun merge_ruletabs tab1 tab2 = Symtab.merge_list (op =) (tab1, tab2); 

0  168 

169 

170 

171 
(** datatype syntax **) 

172 

237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

173 
datatype syntax = 
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

174 
Syntax of { 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

175 
input: SynExt.xprod list, 
4703  176 
lexicon: Scan.lexicon, 
5692  177 
gram: Parser.gram, 
18  178 
consts: string list, 
2913  179 
prmodes: string list, 
21772  180 
parse_ast_trtab: ((Proof.context > Ast.ast list > Ast.ast) * stamp) Symtab.table, 
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

181 
parse_ruletab: ruletab, 
21772  182 
parse_trtab: ((Proof.context > term list > term) * stamp) Symtab.table, 
183 
print_trtab: ((Proof.context > bool > typ > term list > term) * stamp) list Symtab.table, 

237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

184 
print_ruletab: ruletab, 
21772  185 
print_ast_trtab: ((Proof.context > Ast.ast list > Ast.ast) * stamp) list Symtab.table, 
23660
18765718cf62
type output = string indicates raw system output;
wenzelm
parents:
23655
diff
changeset

186 
tokentrtab: (string * (string * ((string > output * int) * stamp)) list) list, 
17079  187 
prtabs: Printer.prtabs} * stamp; 
0  188 

17079  189 
fun eq_syntax (Syntax (_, s1), Syntax (_, s2)) = s1 = s2; 
190 

191 
fun is_keyword (Syntax ({lexicon, ...}, _)) = Scan.is_literal lexicon o Symbol.explode; 

14687  192 

20784  193 
type mode = string * bool; 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

194 
val default_mode = ("", true); 
21702  195 
val input_mode = ("input", true); 
21826  196 
val internalM = "internal"; 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

197 

18  198 

237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

199 
(* empty_syntax *) 
18  200 

17079  201 
val empty_syntax = Syntax 
202 
({input = [], 

4703  203 
lexicon = Scan.empty_lexicon, 
5692  204 
gram = Parser.empty_gram, 
167  205 
consts = [], 
2913  206 
prmodes = [], 
5692  207 
parse_ast_trtab = Symtab.empty, 
208 
parse_ruletab = Symtab.empty, 

209 
parse_trtab = Symtab.empty, 

210 
print_trtab = Symtab.empty, 

211 
print_ruletab = Symtab.empty, 

212 
print_ast_trtab = Symtab.empty, 

2700  213 
tokentrtab = [], 
17079  214 
prtabs = Printer.empty_prtabs}, stamp ()); 
167  215 

216 

237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

217 
(* extend_syntax *) 
167  218 

17079  219 
fun extend_syntax (mode, inout) syn_ext (Syntax (tabs, _)) = 
167  220 
let 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

221 
val {input, lexicon, gram, consts = consts1, prmodes = prmodes1, 
2366  222 
parse_ast_trtab, parse_ruletab, parse_trtab, print_trtab, print_ruletab, 
2700  223 
print_ast_trtab, tokentrtab, prtabs} = tabs; 
14904
7d8dc92fcb7f
removed separate logtypes field of syntax; removed test_read, simple_str_of_sort, simple_string_of_typ; provide default_mode;
wenzelm
parents:
14798
diff
changeset

224 
val SynExt.SynExt {xprods, consts = consts2, prmodes = prmodes2, 
2913  225 
parse_ast_translation, parse_rules, parse_translation, print_translation, print_rules, 
2700  226 
print_ast_translation, token_translation} = syn_ext; 
19546
00d5c7c7ce07
extend/remove_syntax: observe inout flag for translations, too;
wenzelm
parents:
19482
diff
changeset

227 
fun if_inout xs = if inout then xs else []; 
167  228 
in 
17079  229 
Syntax 
19546
00d5c7c7ce07
extend/remove_syntax: observe inout flag for translations, too;
wenzelm
parents:
19482
diff
changeset

230 
({input = if_inout xprods @ input, 
22121  231 
lexicon = Scan.extend_lexicon (if_inout (SynExt.delims_of xprods)) lexicon, 
19546
00d5c7c7ce07
extend/remove_syntax: observe inout flag for translations, too;
wenzelm
parents:
19482
diff
changeset

232 
gram = Parser.extend_gram gram (if_inout xprods), 
00d5c7c7ce07
extend/remove_syntax: observe inout flag for translations, too;
wenzelm
parents:
19482
diff
changeset

233 
consts = Library.merge (op =) (consts1, filter_out NameSpace.is_qualified consts2), 
18921  234 
prmodes = insert (op =) mode (Library.merge (op =) (prmodes1, prmodes2)), 
167  235 
parse_ast_trtab = 
19546
00d5c7c7ce07
extend/remove_syntax: observe inout flag for translations, too;
wenzelm
parents:
19482
diff
changeset

236 
extend_trtab "parse ast translation" (if_inout parse_ast_translation) parse_ast_trtab, 
00d5c7c7ce07
extend/remove_syntax: observe inout flag for translations, too;
wenzelm
parents:
19482
diff
changeset

237 
parse_ruletab = extend_ruletab (if_inout parse_rules) parse_ruletab, 
00d5c7c7ce07
extend/remove_syntax: observe inout flag for translations, too;
wenzelm
parents:
19482
diff
changeset

238 
parse_trtab = extend_trtab "parse translation" (if_inout parse_translation) parse_trtab, 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

239 
print_trtab = extend_tr'tab print_translation print_trtab, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

240 
print_ruletab = extend_ruletab print_rules print_ruletab, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

241 
print_ast_trtab = extend_tr'tab print_ast_translation print_ast_trtab, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

242 
tokentrtab = extend_tokentrtab token_translation tokentrtab, 
17079  243 
prtabs = Printer.extend_prtabs mode xprods prtabs}, stamp ()) 
18  244 
end; 
245 

15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

246 

50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

247 
(* remove_syntax *) 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

248 

17079  249 
fun remove_syntax (mode, inout) syn_ext (Syntax (tabs, _)) = 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

250 
let 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

251 
val SynExt.SynExt {xprods, consts = _, prmodes = _, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

252 
parse_ast_translation, parse_rules, parse_translation, print_translation, print_rules, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

253 
print_ast_translation, token_translation = _} = syn_ext; 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

254 
val {input, lexicon, gram, consts, prmodes, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

255 
parse_ast_trtab, parse_ruletab, parse_trtab, print_trtab, print_ruletab, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

256 
print_ast_trtab, tokentrtab, prtabs} = tabs; 
19300  257 
val input' = if inout then subtract (op =) xprods input else input; 
19546
00d5c7c7ce07
extend/remove_syntax: observe inout flag for translations, too;
wenzelm
parents:
19482
diff
changeset

258 
fun if_inout xs = if inout then xs else []; 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

259 
in 
17079  260 
Syntax 
261 
({input = input', 

15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

262 
lexicon = if inout then Scan.make_lexicon (SynExt.delims_of input') else lexicon, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

263 
gram = if inout then Parser.make_gram input' else gram, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

264 
consts = consts, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

265 
prmodes = prmodes, 
19546
00d5c7c7ce07
extend/remove_syntax: observe inout flag for translations, too;
wenzelm
parents:
19482
diff
changeset

266 
parse_ast_trtab = remove_trtab (if_inout parse_ast_translation) parse_ast_trtab, 
00d5c7c7ce07
extend/remove_syntax: observe inout flag for translations, too;
wenzelm
parents:
19482
diff
changeset

267 
parse_ruletab = remove_ruletab (if_inout parse_rules) parse_ruletab, 
00d5c7c7ce07
extend/remove_syntax: observe inout flag for translations, too;
wenzelm
parents:
19482
diff
changeset

268 
parse_trtab = remove_trtab (if_inout parse_translation) parse_trtab, 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

269 
print_trtab = remove_tr'tab print_translation print_trtab, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

270 
print_ruletab = remove_ruletab print_rules print_ruletab, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

271 
print_ast_trtab = remove_tr'tab print_ast_translation print_ast_trtab, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

272 
tokentrtab = tokentrtab, 
17079  273 
prtabs = Printer.remove_prtabs mode xprods prtabs}, stamp ()) 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

274 
end; 
14904
7d8dc92fcb7f
removed separate logtypes field of syntax; removed test_read, simple_str_of_sort, simple_string_of_typ; provide default_mode;
wenzelm
parents:
14798
diff
changeset

275 

18  276 

237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

277 
(* merge_syntaxes *) 
0  278 

17079  279 
fun merge_syntaxes (Syntax (tabs1, _)) (Syntax (tabs2, _)) = 
0  280 
let 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

281 
val {input = input1, lexicon = lexicon1, gram = gram1, consts = consts1, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

282 
prmodes = prmodes1, parse_ast_trtab = parse_ast_trtab1, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

283 
parse_ruletab = parse_ruletab1, parse_trtab = parse_trtab1, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

284 
print_trtab = print_trtab1, print_ruletab = print_ruletab1, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

285 
print_ast_trtab = print_ast_trtab1, tokentrtab = tokentrtab1, prtabs = prtabs1} = tabs1; 
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

286 

15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

287 
val {input = input2, lexicon = lexicon2, gram = gram2, consts = consts2, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

288 
prmodes = prmodes2, parse_ast_trtab = parse_ast_trtab2, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

289 
parse_ruletab = parse_ruletab2, parse_trtab = parse_trtab2, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

290 
print_trtab = print_trtab2, print_ruletab = print_ruletab2, 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

291 
print_ast_trtab = print_ast_trtab2, tokentrtab = tokentrtab2, prtabs = prtabs2} = tabs2; 
0  292 
in 
17079  293 
Syntax 
18921  294 
({input = Library.merge (op =) (input1, input2), 
4703  295 
lexicon = Scan.merge_lexicons lexicon1 lexicon2, 
5692  296 
gram = Parser.merge_grams gram1 gram2, 
18428  297 
consts = sort_distinct string_ord (consts1 @ consts2), 
18921  298 
prmodes = Library.merge (op =) (prmodes1, prmodes2), 
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

299 
parse_ast_trtab = 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

300 
merge_trtabs "parse ast translation" parse_ast_trtab1 parse_ast_trtab2, 
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

301 
parse_ruletab = merge_ruletabs parse_ruletab1 parse_ruletab2, 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

302 
parse_trtab = merge_trtabs "parse translation" parse_trtab1 parse_trtab2, 
5692  303 
print_trtab = merge_tr'tabs print_trtab1 print_trtab2, 
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

304 
print_ruletab = merge_ruletabs print_ruletab1 print_ruletab2, 
5692  305 
print_ast_trtab = merge_tr'tabs print_ast_trtab1 print_ast_trtab2, 
2700  306 
tokentrtab = merge_tokentrtabs tokentrtab1 tokentrtab2, 
17079  307 
prtabs = Printer.merge_prtabs prtabs1 prtabs2}, stamp ()) 
0  308 
end; 
309 

310 

18720  311 
(* basic syntax *) 
260  312 

18720  313 
val basic_syn = 
17168  314 
empty_syntax 
315 
> extend_syntax default_mode TypeExt.type_ext 

316 
> extend_syntax default_mode SynExt.pure_ext; 

260  317 

18720  318 
val basic_nonterms = 
319 
(Lexicon.terminals @ [SynExt.logic, "type", "types", "sort", "classes", 

320 
SynExt.args, SynExt.cargs, "pttrn", "pttrns", "idt", "idts", "aprop", 

22573  321 
"asms", SynExt.any_, SynExt.sprop, "num_const", "index", "struct"]); 
18720  322 

323 
val appl_syntax = 

324 
[("_appl", "[('b => 'a), args] => logic", Mixfix.Mixfix ("(1_/(1'(_')))", [1000, 0], 1000)), 

325 
("_appl", "[('b => 'a), args] => aprop", Mixfix.Mixfix ("(1_/(1'(_')))", [1000, 0], 1000))]; 

326 

327 
val applC_syntax = 

328 
[("", "'a => cargs", Mixfix.Delimfix "_"), 

329 
("_cargs", "['a, cargs] => cargs", Mixfix.Mixfix ("_/ _", [1000, 1000], 1000)), 

330 
("_applC", "[('b => 'a), cargs] => logic", Mixfix.Mixfix ("(1_/ _)", [1000, 1000], 999)), 

331 
("_applC", "[('b => 'a), cargs] => aprop", Mixfix.Mixfix ("(1_/ _)", [1000, 1000], 999))]; 

332 

0  333 

4887  334 

15759  335 
(** print syntax **) 
336 

337 
local 

0  338 

260  339 
fun pretty_strs_qs name strs = 
14598
7009f59711e3
Replaced quote by Library.quote, since quote now refers to Symbol.quote
berghofe
parents:
14177
diff
changeset

340 
Pretty.strs (name :: map Library.quote (sort_strings strs)); 
0  341 

17079  342 
fun pretty_gram (Syntax (tabs, _)) = 
0  343 
let 
14904
7d8dc92fcb7f
removed separate logtypes field of syntax; removed test_read, simple_str_of_sort, simple_string_of_typ; provide default_mode;
wenzelm
parents:
14798
diff
changeset

344 
val {lexicon, prmodes, gram, prtabs, ...} = tabs; 
2913  345 
val prmodes' = sort_strings (filter_out (equal "") prmodes); 
0  346 
in 
8720  347 
[pretty_strs_qs "lexicon:" (Scan.dest_lexicon lexicon), 
348 
Pretty.big_list "prods:" (Parser.pretty_gram gram), 

349 
pretty_strs_qs "print modes:" prmodes'] 

0  350 
end; 
351 

17079  352 
fun pretty_trans (Syntax (tabs, _)) = 
0  353 
let 
260  354 
fun pretty_trtab name tab = 
5692  355 
pretty_strs_qs name (Symtab.keys tab); 
0  356 

260  357 
fun pretty_ruletab name tab = 
5692  358 
Pretty.big_list name (map Ast.pretty_rule (dest_ruletab tab)); 
0  359 

14598
7009f59711e3
Replaced quote by Library.quote, since quote now refers to Symbol.quote
berghofe
parents:
14177
diff
changeset

360 
fun pretty_tokentr (mode, trs) = Pretty.strs (Library.quote mode ^ ":" :: map fst trs); 
4703  361 

237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

362 
val {consts, parse_ast_trtab, parse_ruletab, parse_trtab, print_trtab, 
4703  363 
print_ruletab, print_ast_trtab, tokentrtab, ...} = tabs; 
0  364 
in 
8720  365 
[pretty_strs_qs "consts:" consts, 
366 
pretty_trtab "parse_ast_translation:" parse_ast_trtab, 

367 
pretty_ruletab "parse_rules:" parse_ruletab, 

368 
pretty_trtab "parse_translation:" parse_trtab, 

369 
pretty_trtab "print_translation:" print_trtab, 

370 
pretty_ruletab "print_rules:" print_ruletab, 

371 
pretty_trtab "print_ast_translation:" print_ast_trtab, 

372 
Pretty.big_list "token_translation:" (map pretty_tokentr tokentrtab)] 

0  373 
end; 
374 

15759  375 
in 
0  376 

15759  377 
fun print_gram syn = Pretty.writeln (Pretty.chunks (pretty_gram syn)); 
378 
fun print_trans syn = Pretty.writeln (Pretty.chunks (pretty_trans syn)); 

379 
fun print_syntax syn = Pretty.writeln (Pretty.chunks (pretty_gram syn @ pretty_trans syn)); 

0  380 

15759  381 
end; 
0  382 

383 

384 

237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

385 
(** read **) 
18  386 

260  387 
(* read_ast *) 
388 

882
b118d1ea0dfd
moved ambiguity_level from sign.ML to Syntax/syntax.ML
clasohm
parents:
865
diff
changeset

389 
val ambiguity_level = ref 1; 
15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

390 
val ambiguity_is_error = ref false 
882
b118d1ea0dfd
moved ambiguity_level from sign.ML to Syntax/syntax.ML
clasohm
parents:
865
diff
changeset

391 

21772  392 
fun read_asts ctxt is_logtype (Syntax (tabs, _)) xids root str = 
260  393 
let 
14904
7d8dc92fcb7f
removed separate logtypes field of syntax; removed test_read, simple_str_of_sort, simple_string_of_typ; provide default_mode;
wenzelm
parents:
14798
diff
changeset

394 
val {lexicon, gram, parse_ast_trtab, ...} = tabs; 
7d8dc92fcb7f
removed separate logtypes field of syntax; removed test_read, simple_str_of_sort, simple_string_of_typ; provide default_mode;
wenzelm
parents:
14798
diff
changeset

395 
val root' = if root <> "prop" andalso is_logtype root then SynExt.logic else root; 
4703  396 
val chars = Symbol.explode str; 
5692  397 
val pts = Parser.parse gram root' (Lexicon.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

398 

12292  399 
fun show_pt pt = 
21772  400 
Pretty.string_of (Ast.pretty_ast (hd (SynTrans.pts_to_asts ctxt (K NONE) [pt]))); 
260  401 
in 
21962  402 
if length pts > ! ambiguity_level then 
16613
76e57e08dcb5
proper treatment of advanced trfuns: pass thy argument;
wenzelm
parents:
15833
diff
changeset

403 
if ! ambiguity_is_error then error ("Ambiguous input " ^ quote str) 
16661
507438b27f66
use tracing for potentially voluminous ambiguity output;
wenzelm
parents:
16613
diff
changeset

404 
else (warning ("Ambiguous input " ^ quote str ^ "\n" ^ 
16716  405 
"produces " ^ string_of_int (length pts) ^ " parse trees."); 
21962  406 
List.app (warning o show_pt) pts) 
407 
else (); 

21772  408 
SynTrans.pts_to_asts ctxt (lookup_tr parse_ast_trtab) pts 
260  409 
end; 
410 

411 

237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

412 
(* read *) 
0  413 

21772  414 
fun read ctxt is_logtype (syn as Syntax (tabs, _)) ty str = 
0  415 
let 
237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

416 
val {parse_ruletab, parse_trtab, ...} = tabs; 
21772  417 
val asts = read_asts ctxt is_logtype syn false (SynExt.typ_to_nonterm ty) str; 
0  418 
in 
21772  419 
SynTrans.asts_to_terms ctxt (lookup_tr parse_trtab) 
18931  420 
(map (Ast.normalize_ast (Symtab.lookup_list parse_ruletab)) asts) 
0  421 
end; 
422 

423 

22703  424 
(* read terms *) 
425 

426 
fun read_term get_sort map_const map_free map_type map_sort ctxt is_logtype syn ty str = 

22764  427 
map (TypeExt.decode_term get_sort map_const map_free map_type map_sort) 
22703  428 
(read ctxt is_logtype syn ty str); 
429 

430 

237
a7d3e712767a
MAJOR INTERNAL CHANGE: extend and merge operations of syntax tables
wenzelm
parents:
175
diff
changeset

431 
(* read types *) 
0  432 

21772  433 
fun read_typ ctxt syn get_sort map_sort str = 
434 
(case read ctxt (K false) syn SynExt.typeT str of 

22703  435 
[t] => TypeExt.typ_of_term (get_sort (TypeExt.term_sorts map_sort t)) map_sort t 
8894  436 
 _ => error "read_typ: ambiguous syntax"); 
144  437 

438 

8894  439 
(* read sorts *) 
440 

22703  441 
fun read_sort ctxt syn map_sort str = 
21772  442 
(case read ctxt (K false) syn TypeExt.sortT str of 
22703  443 
[t] => TypeExt.sort_of_term map_sort t 
8894  444 
 _ => error "read_sort: ambiguous syntax"); 
445 

446 

18  447 

1158  448 
(** prepare translation rules **) 
449 

450 
datatype 'a trrule = 

3526  451 
ParseRule of 'a * 'a  
452 
PrintRule of 'a * 'a  

453 
ParsePrintRule of 'a * 'a; 

888
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset

454 

4618  455 
fun map_trrule f (ParseRule (x, y)) = ParseRule (f x, f y) 
456 
 map_trrule f (PrintRule (x, y)) = PrintRule (f x, f y) 

457 
 map_trrule f (ParsePrintRule (x, y)) = ParsePrintRule (f x, f y); 

1158  458 

15531  459 
fun parse_rule (ParseRule pats) = SOME pats 
460 
 parse_rule (PrintRule _) = NONE 

461 
 parse_rule (ParsePrintRule pats) = SOME pats; 

1158  462 

15531  463 
fun print_rule (ParseRule _) = NONE 
464 
 print_rule (PrintRule pats) = SOME (swap pats) 

465 
 print_rule (ParsePrintRule pats) = SOME (swap pats); 

1158  466 

467 

19262  468 
local 
469 

1158  470 
fun check_rule (rule as (lhs, rhs)) = 
5692  471 
(case Ast.rule_error rule of 
15531  472 
SOME msg => 
1158  473 
error ("Error in syntax translation rule: " ^ msg ^ "\n" ^ 
5692  474 
Ast.str_of_ast lhs ^ " > " ^ Ast.str_of_ast rhs) 
15531  475 
 NONE => rule); 
888
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset

476 

3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset

477 

21772  478 
fun read_pattern ctxt is_logtype syn (root, str) = 
18  479 
let 
17079  480 
val Syntax ({consts, ...}, _) = syn; 
18  481 

5692  482 
fun constify (ast as Ast.Constant _) = ast 
483 
 constify (ast as Ast.Variable x) = 

20664  484 
if member (op =) consts x orelse NameSpace.is_qualified x then Ast.Constant x 
3830  485 
else ast 
5692  486 
 constify (Ast.Appl asts) = Ast.Appl (map constify asts); 
18  487 
in 
21772  488 
(case read_asts ctxt is_logtype syn true root str of 
888
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset

489 
[ast] => constify ast 
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset

490 
 _ => error ("Syntactically ambiguous input: " ^ quote str)) 
18678  491 
end handle ERROR msg => 
492 
cat_error msg ("The error(s) above occurred in translation pattern " ^ 

888
3a1de9454d13
improved read_xrules: patterns no longer read twice;
wenzelm
parents:
882
diff
changeset

493 
quote str); 
0  494 

1158  495 
fun prep_rules rd_pat raw_rules = 
4618  496 
let val rules = map (map_trrule rd_pat) raw_rules in 
19482
9f11af8f7ef9
tuned basic list operators (flat, maps, map_filter);
wenzelm
parents:
19375
diff
changeset

497 
(map check_rule (map_filter parse_rule rules), 
9f11af8f7ef9
tuned basic list operators (flat, maps, map_filter);
wenzelm
parents:
19375
diff
changeset

498 
map check_rule (map_filter print_rule rules)) 
1158  499 
end 
18  500 

19262  501 
in 
502 

503 
val cert_rules = prep_rules I; 

504 

21772  505 
fun read_rules ctxt is_logtype syn = 
506 
prep_rules (read_pattern ctxt is_logtype syn); 

19262  507 

508 
end; 

509 

18  510 

511 

3779  512 
(** pretty terms, typs, sorts **) 
18  513 

23631  514 
fun pretty_t t_to_ast prt_t markup ctxt (syn as Syntax (tabs, _)) curried t = 
0  515 
let 
2700  516 
val {print_trtab, print_ruletab, print_ast_trtab, tokentrtab, prtabs, ...} = tabs; 
21772  517 
val ast = t_to_ast ctxt (lookup_tr' print_trtab) t; 
0  518 
in 
23631  519 
Pretty.markup markup (prt_t ctxt curried prtabs (lookup_tr' print_ast_trtab) 
6167
2f354020efc3
corrected output of symbols for several (probably not all) relevant functions
oheimb
parents:
5702
diff
changeset

520 
(lookup_tokentr tokentrtab (! print_mode)) 
23631  521 
(Ast.normalize_ast (Symtab.lookup_list print_ruletab) ast)) 
0  522 
end; 
523 

23631  524 
fun pretty_term extern = 
525 
pretty_t Printer.term_to_ast (Printer.pretty_term_ast extern) Markup.term; 

526 
fun pretty_typ ctxt syn = 

527 
pretty_t Printer.typ_to_ast Printer.pretty_typ_ast Markup.typ ctxt syn false; 

528 
fun pretty_sort ctxt syn = 

529 
pretty_t Printer.sort_to_ast Printer.pretty_typ_ast Markup.sort ctxt syn false; 

0  530 

531 

532 

19262  533 
(** modify syntax **) 
383
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset

534 

14904
7d8dc92fcb7f
removed separate logtypes field of syntax; removed test_read, simple_str_of_sort, simple_string_of_typ; provide default_mode;
wenzelm
parents:
14798
diff
changeset

535 
fun ext_syntax' f is_logtype prmode decls = extend_syntax prmode (f is_logtype decls); 
7d8dc92fcb7f
removed separate logtypes field of syntax; removed test_read, simple_str_of_sort, simple_string_of_typ; provide default_mode;
wenzelm
parents:
14798
diff
changeset

536 
fun ext_syntax f = ext_syntax' (K f) (K false) default_mode; 
383
fcea89074e4c
added incremental extension functions: extend_log_types, extend_type_gram,
wenzelm
parents:
330
diff
changeset

537 

16613
76e57e08dcb5
proper treatment of advanced trfuns: pass thy argument;
wenzelm
parents:
15833
diff
changeset

538 
val extend_type_gram = ext_syntax Mixfix.syn_ext_types; 
76e57e08dcb5
proper treatment of advanced trfuns: pass thy argument;
wenzelm
parents:
15833
diff
changeset

539 
val extend_const_gram = ext_syntax' Mixfix.syn_ext_consts; 
76e57e08dcb5
proper treatment of advanced trfuns: pass thy argument;
wenzelm
parents:
15833
diff
changeset

540 
val extend_consts = ext_syntax SynExt.syn_ext_const_names; 
76e57e08dcb5
proper treatment of advanced trfuns: pass thy argument;
wenzelm
parents:
15833
diff
changeset

541 
val extend_trfuns = ext_syntax SynExt.syn_ext_trfuns; 
76e57e08dcb5
proper treatment of advanced trfuns: pass thy argument;
wenzelm
parents:
15833
diff
changeset

542 
val extend_advanced_trfuns = ext_syntax SynExt.syn_ext_advanced_trfuns; 
76e57e08dcb5
proper treatment of advanced trfuns: pass thy argument;
wenzelm
parents:
15833
diff
changeset

543 
val extend_tokentrfuns = ext_syntax SynExt.syn_ext_tokentrfuns; 
5692  544 

15755
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

545 
fun remove_const_gram is_logtype prmode decls = 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

546 
remove_syntax prmode (Mixfix.syn_ext_consts is_logtype decls); 
50ac97ebe7d8
expect translations functions to be stamped already;
wenzelm
parents:
15574
diff
changeset

547 

21772  548 
fun extend_trrules ctxt is_logtype syn = 
549 
ext_syntax SynExt.syn_ext_rules o read_rules ctxt is_logtype syn; 

19262  550 

21772  551 
fun remove_trrules ctxt is_logtype syn = 
552 
remove_syntax default_mode o SynExt.syn_ext_rules o read_rules ctxt is_logtype syn; 

19262  553 

554 
val extend_trrules_i = ext_syntax SynExt.syn_ext_rules o cert_rules; 

555 
val remove_trrules_i = remove_syntax default_mode o SynExt.syn_ext_rules o cert_rules; 

5692  556 

557 

15833
78109c7012ed
removed token_trans.ML (some content moved to syn_ext.ML);
wenzelm
parents:
15759
diff
changeset

558 
(*export parts of internal Syntax structures*) 
78109c7012ed
removed token_trans.ML (some content moved to syn_ext.ML);
wenzelm
parents:
15759
diff
changeset

559 
open Lexicon SynExt Ast Parser TypeExt SynTrans Mixfix Printer; 
2366  560 

0  561 
end; 
5692  562 

563 
structure BasicSyntax: BASIC_SYNTAX = Syntax; 

564 
open BasicSyntax; 

23923  565 

566 
structure Hidden = struct end; 

567 
structure Lexicon = Hidden; 

568 
structure Ast = Hidden; 

569 
structure SynExt = Hidden; 

570 
structure Parser = Hidden; 

571 
structure TypeExt = Hidden; 

572 
structure SynTrans = Hidden; 

573 
structure Mixfix = Hidden; 

574 
structure Printer = Hidden; 