Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | /** |
2 | * Name: sml_simple | |
3 | * Description: Standard ML programming language. | |
4 | * Author: Matthew Fluet <mfluet@acm.org> | |
5 | */ | |
6 | ||
7 | /* | |
8 | builtin_face --- | |
9 | comment_face --- comments | |
10 | function_name_face --- | |
11 | highlight_face --- | |
12 | keyword_face --- keywords | |
13 | reference_face --- | |
14 | string_face --- strings | |
15 | type_face --- | |
16 | variable_name_face --- | |
17 | */ | |
18 | ||
19 | sml_keywords_re = | |
20 | /* Keywords: | |
21 | (build-re '(; Core | |
22 | abstype and andalso as case do datatype else | |
23 | end exception fn fun handle if in infix | |
24 | infixr let local nonfix of op open orelse | |
25 | raise rec then type val with withtype while | |
26 | ; Modules | |
27 | eqtype functor include sharing sig | |
28 | signature struct structure where)) ;' | |
29 | */ | |
30 | /\b(a(bstype|nd(|also)|s)|case|d(atatype|o)|e(lse|nd|qtype|xception)|f(n|un(|ctor))|handle|i(f|n(|clude|fix(|r)))|l(et|ocal)|nonfix|o(f|p(|en)|relse)|r(aise|ec)|s(haring|ig(|nature)|truct(|ure))|t(hen|ype)|val|w(h(ere|ile)|ith(|type)))\b/; | |
31 | ||
32 | state sml_simple | |
33 | { | |
34 | BEGIN { | |
35 | header (); | |
36 | } | |
37 | END { | |
38 | trailer (); | |
39 | } | |
40 | ||
41 | /* | |
42 | * Keywords | |
43 | */ | |
44 | sml_keywords_re { | |
45 | keyword_face (true); | |
46 | language_print ($0); | |
47 | keyword_face (false); | |
48 | } | |
49 | ||
50 | /* | |
51 | * Special constants (strings) | |
52 | */ | |
53 | /\"/ { | |
54 | string_face (true); | |
55 | language_print ($0); | |
56 | call (sml_string); | |
57 | string_face (false); | |
58 | } | |
59 | ||
60 | /* | |
61 | * Special constants (chars) | |
62 | */ | |
63 | /(#)(\")/ { | |
64 | language_print ($1); | |
65 | string_face (true); | |
66 | language_print ($2); | |
67 | call (sml_string); | |
68 | string_face (false); | |
69 | } | |
70 | ||
71 | /* | |
72 | * Comments | |
73 | */ | |
74 | /\(\*/ { | |
75 | comment_face (true); | |
76 | language_print ($0); | |
77 | call (sml_comment); | |
78 | comment_face (false); | |
79 | } | |
80 | ||
81 | LANGUAGE_SPECIALS { | |
82 | language_print ($0); | |
83 | } | |
84 | } | |
85 | ||
86 | /* | |
87 | * Strings | |
88 | */ | |
89 | state sml_string | |
90 | { | |
91 | /\\\\(\s|\n)/ { | |
92 | language_print ($0); | |
93 | call (sml_string_gap); | |
94 | } | |
95 | ||
96 | /\\\\./ { | |
97 | language_print ($0); | |
98 | } | |
99 | ||
100 | /\"/ { | |
101 | language_print ($0); | |
102 | return; | |
103 | } | |
104 | ||
105 | LANGUAGE_SPECIALS { | |
106 | language_print ($0); | |
107 | } | |
108 | } | |
109 | ||
110 | state sml_string_gap | |
111 | { | |
112 | /(\s|\n)/ { | |
113 | language_print ($0); | |
114 | } | |
115 | ||
116 | /\\\\/ { | |
117 | language_print ($0); | |
118 | return; | |
119 | } | |
120 | ||
121 | LANGUAGE_SPECIALS { | |
122 | language_print ($0); | |
123 | } | |
124 | } | |
125 | ||
126 | /* | |
127 | * Nested comments | |
128 | */ | |
129 | state sml_comment | |
130 | { | |
131 | BEGIN { | |
132 | sml_comment_depth = 1; | |
133 | } | |
134 | ||
135 | /\(\*/ { | |
136 | sml_comment_depth += 1; | |
137 | language_print ($0); | |
138 | } | |
139 | ||
140 | /\*\)/ { | |
141 | sml_comment_depth -= 1; | |
142 | language_print ($0); | |
143 | if (sml_comment_depth == 0) | |
144 | return; | |
145 | } | |
146 | ||
147 | LANGUAGE_SPECIALS { | |
148 | language_print ($0); | |
149 | } | |
150 | } | |
151 | ||
152 | \f | |
153 | /* | |
154 | Local variables: | |
155 | mode: c | |
156 | End: | |
157 | */ | |
158 | ||
159 | /** | |
160 | * Name: sml_verbose | |
161 | * Description: Standard ML programming language. | |
162 | * Author: Matthew Fluet <mfluet@acm.org> | |
163 | */ | |
164 | ||
165 | /* | |
166 | builtin_face --- | |
167 | comment_face --- comments | |
168 | function_name_face --- | |
169 | highlight_face --- | |
170 | keyword_face --- keywords | |
171 | reference_face --- special constants (nums) | |
172 | string_face --- strings | |
173 | type_face --- | |
174 | variable_name_face --- | |
175 | */ | |
176 | ||
177 | /* | |
178 | require_state (sml_simple); | |
179 | */ | |
180 | ||
181 | /* | |
182 | formatting = [\ \t\n\011\012\013]+; | |
183 | */ | |
184 | sml_formatting_str = "[ \\t\\n\\011\\012\\013]+"; | |
185 | sml_formatting_re = regexp(sml_formatting_str); | |
186 | /* | |
187 | letter = [A-Za-z]; | |
188 | */ | |
189 | sml_letter_str = "[A-Za-z]"; | |
190 | sml_letter_re = regexp(sml_letter_str); | |
191 | /* | |
192 | symbol = [-!%&$#+/:<=>?@\\~`|*^]; | |
193 | */ | |
194 | sml_symbol_str = "[-!%&$#+/:<=>?@\\\\~`|*^]"; | |
195 | sml_symbol_re = regexp(sml_symbol_str); | |
196 | /* | |
197 | digit = [0-9]; | |
198 | */ | |
199 | sml_digit_str = "[0-9]"; | |
200 | sml_digit_re = regexp(sml_digit_str); | |
201 | /* | |
202 | hexdigit = [0-9a-fA-F]; | |
203 | */ | |
204 | sml_hexdigit_str = "[0-9a-fA-F]"; | |
205 | sml_hexdigit_re = regexp(sml_hexdigit_str); | |
206 | ||
207 | /* | |
208 | posdecint = {digit}+; | |
209 | */ | |
210 | sml_posdecint_str = sprintf("(%s)+",sml_digit_str); | |
211 | sml_posdecint_re = regexp(sml_posdecint_str); | |
212 | /* | |
213 | poshexint = "0x"{hexdigit}+; | |
214 | */ | |
215 | sml_poshexint_str = sprintf("0x(%s)+",sml_hexdigit_str); | |
216 | sml_poshexint_re = regexp(sml_poshexint_str); | |
217 | /* | |
218 | negdecint = "~"{posdecint}; | |
219 | */ | |
220 | sml_negdecint_str = sprintf("~(%s)",sml_posdecint_str); | |
221 | sml_negdecint_re = regexp(sml_negdecint_str); | |
222 | /* | |
223 | neghexint = "~"{poshexint}; | |
224 | */ | |
225 | sml_neghexint_str = sprintf("~(%s)",sml_poshexint_str); | |
226 | sml_neghexint_re = regexp(sml_neghexint_str); | |
227 | /* | |
228 | decint = {posdecint} | {negdecint}; | |
229 | */ | |
230 | sml_decint_str = sprintf("(%s)|(%s)",sml_posdecint_str,sml_negdecint_str); | |
231 | sml_decint_re = regexp(sml_decint_str); | |
232 | /* | |
233 | hexint = {poshexint} | {neghexint}; | |
234 | */ | |
235 | sml_hexint_str = sprintf("(%s)|(%s)",sml_poshexint_str,sml_negdecint_str); | |
236 | sml_hexint_re = regexp(sml_hexint_str); | |
237 | /* | |
238 | decword = "0w"{digit}+; | |
239 | */ | |
240 | sml_decword_str = sprintf("0w(%s)+",sml_digit_str); | |
241 | sml_decword_re = regexp(sml_decword_str); | |
242 | /* | |
243 | hexword = "0wx"{hexdigit}+; | |
244 | */ | |
245 | sml_hexword_str = sprintf("0wx(%s)+",sml_hexdigit_str); | |
246 | sml_hexword_re = regexp(sml_hexword_str); | |
247 | ||
248 | /* | |
249 | exp = "E" | "e"; | |
250 | */ | |
251 | sml_exp_str = "E|e"; | |
252 | sml_exp_re = regexp(sml_exp_str); | |
253 | /* | |
254 | real = ({decint}"."{digit}+ ({exp}{decint})?) | ({decint}{exp}{decint}); | |
255 | */ | |
256 | sml_real_str = sprintf("((%s)\\.(%s)+((%s)(%s))?)|((%s)(%s)(%s))", | |
257 | sml_decint_str,sml_digit_str,sml_exp_str,sml_decint_str, | |
258 | sml_decint_str,sml_exp_str,sml_decint_str); | |
259 | sml_real_re = regexp(sml_real_str); | |
260 | ||
261 | /* | |
262 | scon_num = {decint} | {hexint} | {decword} | {hexword} | {real} | |
263 | */ | |
264 | sml_scon_num_str = sprintf("\\b((%s)|(%s)|(%s)|(%s)|(%s))\\b", | |
265 | sml_decint_str,sml_hexint_str, | |
266 | sml_decword_str,sml_hexword_str, | |
267 | sml_real_str); | |
268 | sml_scon_num_re = regexp(sml_scon_num_str); | |
269 | ||
270 | /* | |
271 | numericlab = [1-9]{digit}*; | |
272 | */ | |
273 | sml_numericlab_str = sprintf("[1-9](%s)*",sml_digit_str); | |
274 | sml_numericlab_re = regexp(sml_numericlab_str); | |
275 | /* | |
276 | alphanumid = {letter}({letter} | {digit} | [_'])*; | |
277 | */ | |
278 | sml_alphanumid_str = sprintf("(%s)((%s)|(%s)|[_'])*", | |
279 | sml_letter_str,sml_letter_str,sml_digit_str); | |
280 | /* | |
281 | symbolicid = {symbol}+; | |
282 | */ | |
283 | sml_symbolicid_str = sprintf("(%s)+",sml_symbol_str); | |
284 | sml_symbolicid_re = regexp(sml_symbolicid_str); | |
285 | /* | |
286 | id = {alphanumid} | {symbolicid}; | |
287 | */ | |
288 | sml_id_str = sprintf("(%s)|(%s)",sml_alphanumid_str,sml_symbolicid_str); | |
289 | sml_id_re = regexp(sml_id_str); | |
290 | /* | |
291 | tyvar = "'"({letter} | {digit} | [_'])*; | |
292 | */ | |
293 | sml_tyvar_str = sprintf("'((%s)|(%s)|[_'])*",sml_letter_str,sml_digit_str); | |
294 | sml_tyvar_re = regexp(sml_tyvar_str); | |
295 | /* | |
296 | longid = ({alphanumid}".")+ {id}; | |
297 | */ | |
298 | sml_longid_str = sprintf("((%s)\\.)+(%s)",sml_alphanumid_str,sml_id_str); | |
299 | sml_longid_re = regexp(sml_longid_str); | |
300 | ||
301 | /* | |
302 | lab = {id} | {numericlab} | |
303 | */ | |
304 | sml_lab_str = sprintf("(%s)|(%s)",sml_id_str,sml_numericlab_str); | |
305 | sml_lab_re = regexp(sml_lab_str); | |
306 | /* | |
307 | sel = "#" {formatting} {lab} | |
308 | */ | |
309 | sml_sel_str = sprintf("#(%s)(%s)",sml_formatting_str,sml_lab_str); | |
310 | sml_sel_re = regexp(sml_sel_str); | |
311 | /* | |
312 | infix = "infix"("r")? {formatting} ({digit})? | |
313 | */ | |
314 | sml_infix_str = sprintf("(infix(r?))(%s)(%s)?",sml_formatting_str,sml_digit_str); | |
315 | sml_infix_re = regexp(sml_infix_str); | |
316 | ||
317 | /* | |
318 | val_with_tyvar = "val" {formatting} {tyvar} | |
319 | val_with_tyvarseq = "val" {formatting} "(" {formatting} {tyvar} | |
320 | fun_with_tyvar = "fun" {formatting} {tyvar} | |
321 | fun_with_tyvarseq = "fun" {formatting} "(" {formatting} {tyvar} | |
322 | */ | |
323 | sml_val_with_tyvar_str = sprintf("(val)(%s)(%s)",sml_formatting_str,sml_tyvar_str); | |
324 | sml_val_with_tyvar_re = regexp(sml_val_with_tyvar_str); | |
325 | sml_val_with_tyvarseq_str = sprintf("(val)(%s)(\\\()(%s)(%s)",sml_formatting_str,sml_formatting_str,sml_tyvar_str); | |
326 | sml_val_with_tyvarseq_re = regexp(sml_val_with_tyvarseq_str); | |
327 | sml_fun_with_tyvar_str = sprintf("(fun)(%s)(%s)",sml_formatting_str,sml_tyvar_str); | |
328 | sml_fun_with_tyvar_re = regexp(sml_fun_with_tyvar_str); | |
329 | sml_fun_with_tyvarseq_str = sprintf("(fun)(%s)(\\\()(%s)(%s)",sml_formatting_str,sml_formatting_str,sml_tyvar_str); | |
330 | sml_fun_with_tyvarseq_re = regexp(sml_fun_with_tyvarseq_str); | |
331 | ||
332 | ||
333 | state sml_verbose /* extends sml_simple */ | |
334 | { | |
335 | sml_infix_re { | |
336 | keyword_face (true); | |
337 | language_print ($1); | |
338 | keyword_face (false); | |
339 | language_print ($3); | |
340 | language_print ($4); | |
341 | } | |
342 | sml_sel_re { | |
343 | language_print ($0); | |
344 | } | |
345 | ||
346 | /* | |
347 | * Special constants (nums) | |
348 | */ | |
349 | sml_scon_num_re { | |
350 | reference_face (true); | |
351 | language_print ($0); | |
352 | reference_face (false); | |
353 | } | |
354 | ||
355 | /* extend sml_simple */ | |
356 | BEGIN { | |
357 | header (); | |
358 | } | |
359 | END { | |
360 | trailer (); | |
361 | } | |
362 | ||
363 | /* | |
364 | * Keywords | |
365 | */ | |
366 | sml_keywords_re { | |
367 | keyword_face (true); | |
368 | language_print ($0); | |
369 | keyword_face (false); | |
370 | } | |
371 | ||
372 | /* | |
373 | * Special constants (strings) | |
374 | */ | |
375 | /\"/ { | |
376 | string_face (true); | |
377 | language_print ($0); | |
378 | call (sml_string); | |
379 | string_face (false); | |
380 | } | |
381 | ||
382 | /* | |
383 | * Special constants (chars) | |
384 | */ | |
385 | /(#)(\")/ { | |
386 | language_print ($1); | |
387 | string_face (true); | |
388 | language_print ($2); | |
389 | call (sml_string); | |
390 | string_face (false); | |
391 | } | |
392 | ||
393 | /* | |
394 | * Comments | |
395 | */ | |
396 | /\(\*/ { | |
397 | comment_face (true); | |
398 | language_print ($0); | |
399 | call (sml_comment); | |
400 | comment_face (false); | |
401 | } | |
402 | ||
403 | LANGUAGE_SPECIALS { | |
404 | language_print ($0); | |
405 | } | |
406 | } | |
407 | ||
408 | /* | |
409 | * Binding tyvar seqs | |
410 | */ | |
411 | state sml_tyvarseq | |
412 | { | |
413 | /,/ { | |
414 | language_print($0); | |
415 | } | |
416 | sml_tyvar_re { | |
417 | type_face(true); | |
418 | language_print($0); | |
419 | type_face(false); | |
420 | } | |
421 | /\)/ { | |
422 | language_print($0); | |
423 | return; | |
424 | } | |
425 | ||
426 | LANGUAGE_SPECIALS { | |
427 | language_print ($0); | |
428 | } | |
429 | } | |
430 | ||
431 | \f | |
432 | /* | |
433 | Local variables: | |
434 | mode: c | |
435 | End: | |
436 | */ | |
437 | ||
438 | /** | |
439 | * Name: sml_fancy | |
440 | * Description: Standard ML programming language. | |
441 | * Author: Matthew Fluet <mfluet@acm.org> | |
442 | */ | |
443 | ||
444 | /* | |
445 | builtin_face --- | |
446 | comment_face --- comments | |
447 | function_name_face --- modules keywords | |
448 | highlight_face --- | |
449 | keyword_face --- core keywords | |
450 | reference_face --- special constants (nums) | |
451 | string_face --- strings | |
452 | type_face --- type bindings | |
453 | variable_name_face --- constructor bindings | |
454 | */ | |
455 | ||
456 | /* | |
457 | require_state (sml_verbose); | |
458 | */ | |
459 | ||
460 | TRUE = 1; | |
461 | FALSE = 0; | |
462 | ||
463 | sml_typctxt = -1; | |
464 | sml_typctxt_expected_eqs = -1; | |
465 | SML_DATBIND_UNKNOWN = 1; | |
466 | SML_DATBIND_REPL = 2; | |
467 | SML_DATBIND_DECL = 3; | |
468 | sml_datbind = FALSE; | |
469 | sml_exbind = FALSE; | |
470 | sml_conbind = FALSE; | |
471 | ||
472 | SML_AND_NUL = -1; | |
473 | SML_AND_VALBIND = 1; | |
474 | SML_AND_TYPBIND = 2; | |
475 | SML_AND_DATBIND = 3; | |
476 | SML_AND_EXBIND = 4; | |
477 | SML_AND_STRBIND = 5; | |
478 | SML_AND_SIGBIND = 6; | |
479 | SML_AND_FUNBIND = 7; | |
480 | SML_AND_WHERETYPE = 8; | |
481 | sml_andbind = list (SML_AND_NUL); | |
482 | ||
483 | SML_CORE_LEVEL = 0; | |
484 | SML_MODULES_LEVEL = 1; | |
485 | ||
486 | sml_endmatch = list (SML_MODULES_LEVEL); | |
487 | ||
488 | sml_last_keyword = ""; | |
489 | sub sml_keyword (s, lvl) { | |
490 | sml_last_keyword = s; | |
491 | if (lvl == SML_CORE_LEVEL) | |
492 | keyword_face (true); | |
493 | else if (lvl = SML_MODULES_LEVEL) | |
494 | function_name_face (true); | |
495 | language_print (s); | |
496 | if (lvl == SML_CORE_LEVEL) | |
497 | keyword_face (false); | |
498 | else if (lvl = SML_MODULES_LEVEL) | |
499 | function_name_face (false); | |
500 | } | |
501 | ||
502 | sml_scopes = list (list ("",SML_MODULES_LEVEL)); | |
503 | sml_scope = 0; | |
504 | sub sml_enter_scope (s, lvl) { | |
505 | sml_andbind = list(SML_AND_NUL, sml_andbind); | |
506 | sml_endmatch = list(-1, sml_endmatch); | |
507 | sml_scopes = list (list (s,lvl), sml_scopes); | |
508 | sml_scope++; | |
509 | return; | |
510 | } | |
511 | sub sml_leave_scope () { | |
512 | sml_scope--; | |
513 | sml_scopes = sml_scopes[1]; | |
514 | sml_endmatch = sml_endmatch[1]; | |
515 | sml_andbind = sml_andbind[1]; | |
516 | return; | |
517 | } | |
518 | sub sml_let_level () { | |
519 | local scopes = sml_scopes; | |
520 | if (sml_andbind[0] == SML_AND_STRBIND || | |
521 | sml_andbind[0] == SML_AND_FUNBIND) { | |
522 | return TRUE; | |
523 | } | |
524 | if ((strcmp(scopes[0][0],"let") == 0 || | |
525 | strcmp(scopes[0][0],"(") == 0) && | |
526 | scopes[0][1] == SML_MODULES_LEVEL) | |
527 | return TRUE; | |
528 | return FALSE; | |
529 | } | |
530 | sub sml_local_level () { | |
531 | local scopes = sml_scopes; | |
532 | ||
533 | if ((strcmp(scopes[0][0],"let") == 0 || | |
534 | strcmp(scopes[0][0],"(") == 0) && | |
535 | scopes[0][1] == SML_MODULES_LEVEL) | |
536 | return TRUE; | |
537 | while (length(scopes) == 2) { | |
538 | if (strcmp(scopes[0][0],"local") == 0 && | |
539 | scopes[0][1] == SML_MODULES_LEVEL) | |
540 | scopes = scopes[1]; | |
541 | else if (strcmp(scopes[0][0],"let") == 0 && | |
542 | scopes[0][1] == SML_MODULES_LEVEL) | |
543 | return TRUE; | |
544 | else | |
545 | return FALSE; | |
546 | } | |
547 | return TRUE; | |
548 | } | |
549 | ||
550 | sub sml_start_typctxt (eqs) { | |
551 | type_face(true); | |
552 | sml_typctxt = sml_scope; | |
553 | sml_typctxt_expected_eqs = eqs; | |
554 | return; | |
555 | } | |
556 | sub sml_start_typbind () { | |
557 | sml_start_typctxt (1); | |
558 | sml_datbind = FALSE; | |
559 | sml_exbind = FALSE; | |
560 | sml_conbind = FALSE; | |
561 | } | |
562 | sub sml_start_eqtyp () { | |
563 | sml_start_typctxt (0); | |
564 | sml_datbind = FALSE; | |
565 | sml_exbind = FALSE; | |
566 | sml_conbind = FALSE; | |
567 | } | |
568 | sub sml_start_wheretyp () { | |
569 | sml_start_typctxt (1); | |
570 | sml_datbind = FALSE; | |
571 | sml_exbind = FALSE; | |
572 | sml_conbind = FALSE; | |
573 | } | |
574 | sub sml_start_sharingtyp () { | |
575 | sml_start_typctxt (-1); | |
576 | sml_datbind = FALSE; | |
577 | sml_exbind = FALSE; | |
578 | sml_conbind = FALSE; | |
579 | } | |
580 | sub sml_start_datbind () { | |
581 | sml_start_typctxt (1); | |
582 | sml_datbind = SML_DATBIND_UNKNOWN; | |
583 | sml_exbind = FALSE; | |
584 | sml_conbind = FALSE; | |
585 | } | |
586 | sub sml_start_exbind () { | |
587 | sml_start_typctxt (1); | |
588 | sml_datbind = FALSE; | |
589 | sml_exbind = TRUE; | |
590 | sml_conbind = TRUE; | |
591 | } | |
592 | sub sml_finish_typctxt () { | |
593 | if (sml_typctxt == sml_scope) { | |
594 | sml_typctxt = -1; | |
595 | sml_typctxt_expected_eqs = -1; | |
596 | if (sml_datbind) {sml_datbind = FALSE; sml_conbind = FALSE;} | |
597 | if (sml_exbind) {sml_exbind = FALSE; sml_conbind = FALSE;} | |
598 | type_face (false); | |
599 | } | |
600 | return; | |
601 | } | |
602 | ||
603 | ||
604 | state sml_fancy /* extends sml_verbose */ | |
605 | { | |
606 | /* | |
607 | * Keywords | |
608 | */ | |
609 | /(:|,|_|->)/ { | |
610 | language_print ($0); | |
611 | } | |
612 | /[\({[]/ { | |
613 | sml_enter_scope ($0,sml_scopes[0][1]); | |
614 | language_print ($0); | |
615 | } | |
616 | /[]}\)]/ { | |
617 | sml_finish_typctxt (); | |
618 | language_print ($0); | |
619 | sml_leave_scope (); | |
620 | } | |
621 | /(\.\.\.|;|=>)/ { | |
622 | sml_finish_typctxt (); | |
623 | sml_andbind[0] = SML_AND_NUL; | |
624 | language_print ($0); | |
625 | } | |
626 | /\|/ { | |
627 | if (sml_datbind == SML_DATBIND_DECL) { | |
628 | type_face (false); | |
629 | language_print ($0); | |
630 | sml_conbind = TRUE; | |
631 | type_face (true); | |
632 | } else { | |
633 | language_print ($0); | |
634 | } | |
635 | } | |
636 | /=/ { | |
637 | if (sml_typctxt != -1) { | |
638 | type_face (false); | |
639 | language_print ($0); | |
640 | type_face (true); | |
641 | if (sml_typctxt_expected_eqs == 0) { | |
642 | sml_finish_typctxt (); | |
643 | } else { | |
644 | sml_typctxt_expected_eqs--; | |
645 | if (sml_datbind == SML_DATBIND_UNKNOWN) { | |
646 | sml_conbind = TRUE; | |
647 | } | |
648 | if (sml_exbind) { | |
649 | sml_conbind = TRUE; | |
650 | } | |
651 | } | |
652 | } else { | |
653 | language_print ($0); | |
654 | } | |
655 | } | |
656 | sml_sel_re { | |
657 | language_print ($0); | |
658 | } | |
659 | /\b(abstype)\b/ { | |
660 | sml_finish_typctxt (); | |
661 | sml_enter_scope ($0,SML_CORE_LEVEL); | |
662 | sml_keyword ($0, SML_CORE_LEVEL); | |
663 | sml_andbind[0] = SML_AND_DATBIND; | |
664 | sml_endmatch[0] = SML_CORE_LEVEL; | |
665 | sml_start_datbind (); | |
666 | } | |
667 | /\b(and)\b/ { | |
668 | sml_finish_typctxt (); | |
669 | if (sml_andbind[0] == SML_AND_VALBIND) { | |
670 | sml_keyword ($0, SML_CORE_LEVEL); | |
671 | } else if (sml_andbind[0] == SML_AND_TYPBIND) { | |
672 | sml_keyword ($0, SML_CORE_LEVEL); | |
673 | sml_start_typbind (); | |
674 | } else if (sml_andbind[0] == SML_AND_DATBIND) { | |
675 | sml_keyword ($0, SML_CORE_LEVEL); | |
676 | sml_start_datbind (); | |
677 | } else if (sml_andbind[0] == SML_AND_EXBIND) { | |
678 | sml_keyword ($0, SML_CORE_LEVEL); | |
679 | sml_start_exbind (); | |
680 | } else if (sml_andbind[0] == SML_AND_STRBIND) { | |
681 | sml_keyword ($0, SML_MODULES_LEVEL); | |
682 | } else if (sml_andbind[0] == SML_AND_SIGBIND) { | |
683 | sml_keyword ($0, SML_MODULES_LEVEL); | |
684 | } else if (sml_andbind[0] == SML_AND_FUNBIND) { | |
685 | sml_keyword ($0, SML_MODULES_LEVEL); | |
686 | } else if (sml_andbind[0] == SML_AND_WHERETYPE) { | |
687 | sml_keyword ($0, SML_MODULES_LEVEL); | |
688 | sml_last_keyword = "where"; | |
689 | } | |
690 | ||
691 | } | |
692 | /\b(andalso)\b/ { | |
693 | sml_keyword ($0, SML_CORE_LEVEL); | |
694 | } | |
695 | /\b(as)\b/ { | |
696 | sml_keyword ($0, SML_CORE_LEVEL); | |
697 | } | |
698 | /\b(case)\b/ { | |
699 | sml_keyword ($0, SML_CORE_LEVEL); | |
700 | } | |
701 | /\b(datatype)\b/ { | |
702 | if (sml_datbind == SML_DATBIND_UNKNOWN) { | |
703 | sml_datbind = SML_DATBIND_REPL; | |
704 | sml_conbind = FALSE; | |
705 | sml_keyword ($0, SML_CORE_LEVEL); | |
706 | } else { | |
707 | sml_finish_typctxt (); | |
708 | sml_keyword ($0, SML_CORE_LEVEL); | |
709 | sml_andbind[0] = SML_AND_DATBIND; | |
710 | sml_start_datbind (); | |
711 | } | |
712 | } | |
713 | /\b(do)\b/ { | |
714 | sml_keyword ($0, SML_CORE_LEVEL); | |
715 | } | |
716 | /\b(else)\b/ { | |
717 | sml_keyword ($0, SML_CORE_LEVEL); | |
718 | } | |
719 | /\b(end)\b/ { | |
720 | sml_finish_typctxt (); | |
721 | sml_keyword ($0, sml_endmatch[0]); | |
722 | sml_leave_scope (); | |
723 | } | |
724 | /\b(eqtype)\b/ { | |
725 | sml_finish_typctxt (); | |
726 | sml_keyword ($0, SML_CORE_LEVEL); | |
727 | sml_start_eqtyp (); | |
728 | } | |
729 | /\b(exception)\b/ { | |
730 | sml_finish_typctxt (); | |
731 | sml_keyword ($0, SML_CORE_LEVEL); | |
732 | sml_andbind[0] = SML_AND_EXBIND; | |
733 | sml_start_exbind (); | |
734 | } | |
735 | /\b(fn)\b/ { | |
736 | sml_keyword ($0, SML_CORE_LEVEL); | |
737 | } | |
738 | sml_fun_with_tyvar_re { | |
739 | sml_finish_typctxt (); | |
740 | sml_keyword ($1, SML_CORE_LEVEL); | |
741 | language_print ($2); | |
742 | type_face(true); | |
743 | language_print ($3); | |
744 | type_face(false); | |
745 | sml_andbind[0] = SML_AND_VALBIND; | |
746 | } | |
747 | sml_fun_with_tyvarseq_re { | |
748 | sml_finish_typctxt (); | |
749 | sml_keyword ($1, SML_CORE_LEVEL); | |
750 | language_print ($2); | |
751 | language_print ($3); | |
752 | language_print ($4); | |
753 | type_face(true); | |
754 | language_print ($5); | |
755 | type_face(false); | |
756 | call (sml_tyvarseq); | |
757 | sml_andbind[0] = SML_AND_VALBIND; | |
758 | } | |
759 | /\b(fun)\b/ { | |
760 | sml_finish_typctxt (); | |
761 | sml_keyword ($0, SML_CORE_LEVEL); | |
762 | sml_andbind[0] = SML_AND_VALBIND; | |
763 | } | |
764 | /\b(functor)\b/ { | |
765 | sml_finish_typctxt (); | |
766 | sml_keyword ($0, SML_MODULES_LEVEL); | |
767 | sml_andbind[0] = SML_AND_FUNBIND; | |
768 | } | |
769 | /\b(handle)\b/ { | |
770 | sml_keyword ($0, SML_CORE_LEVEL); | |
771 | } | |
772 | /\b(if)\b/ { | |
773 | sml_keyword ($0, SML_CORE_LEVEL); | |
774 | } | |
775 | /\b(in)\b/ { | |
776 | sml_finish_typctxt (); | |
777 | sml_andbind[0] = SML_AND_NUL; | |
778 | sml_keyword ($0, sml_endmatch[0]); | |
779 | } | |
780 | /\b(include)\b/ { | |
781 | sml_finish_typctxt (); | |
782 | sml_keyword ($0, SML_MODULES_LEVEL); | |
783 | } | |
784 | sml_infix_re { | |
785 | sml_finish_typctxt (); | |
786 | sml_keyword ($1, SML_CORE_LEVEL); | |
787 | language_print ($3); | |
788 | language_print ($4); | |
789 | } | |
790 | /\b(let)\b/ { | |
791 | sml_finish_typctxt (); | |
792 | if (sml_let_level()) { | |
793 | sml_enter_scope ($0,SML_MODULES_LEVEL); | |
794 | sml_keyword ($0, SML_MODULES_LEVEL); | |
795 | sml_endmatch[0] = SML_MODULES_LEVEL; | |
796 | } else { | |
797 | sml_enter_scope ($0,SML_CORE_LEVEL); | |
798 | sml_keyword ($0, SML_CORE_LEVEL); | |
799 | sml_endmatch[0] = SML_CORE_LEVEL; | |
800 | } | |
801 | } | |
802 | /\b(local)\b/ { | |
803 | sml_finish_typctxt (); | |
804 | if (sml_local_level ()) { | |
805 | sml_enter_scope ($0, SML_MODULES_LEVEL); | |
806 | sml_keyword ($0, SML_MODULES_LEVEL); | |
807 | sml_endmatch[0] = SML_MODULES_LEVEL; | |
808 | } else { | |
809 | sml_enter_scope ($0, SML_CORE_LEVEL); | |
810 | sml_keyword ($0, SML_CORE_LEVEL); | |
811 | sml_endmatch[0] = SML_CORE_LEVEL; | |
812 | } | |
813 | } | |
814 | /\b(nonfix)\b/ { | |
815 | sml_finish_typctxt (); | |
816 | sml_keyword ($0, SML_CORE_LEVEL); | |
817 | } | |
818 | /\b(of)\b/ { | |
819 | sml_keyword ($0, SML_CORE_LEVEL); | |
820 | } | |
821 | /\b(op)\b/ { | |
822 | sml_keyword ($0, SML_CORE_LEVEL); | |
823 | } | |
824 | /\b(open)\b/ { | |
825 | sml_finish_typctxt (); | |
826 | sml_keyword ($0, SML_MODULES_LEVEL); | |
827 | } | |
828 | /\b(orelse)\b/ { | |
829 | sml_keyword ($0, SML_CORE_LEVEL); | |
830 | } | |
831 | /\b(raise)\b/ { | |
832 | sml_keyword ($0, SML_CORE_LEVEL); | |
833 | } | |
834 | /\b(rec)\b/ { | |
835 | sml_keyword ($0, SML_CORE_LEVEL); | |
836 | } | |
837 | /\b(sharing)\b/ { | |
838 | sml_finish_typctxt (); | |
839 | sml_keyword ($0, SML_MODULES_LEVEL); | |
840 | } | |
841 | /\b(sig)\b/ { | |
842 | sml_enter_scope ($0, SML_CORE_LEVEL); | |
843 | sml_keyword ($0, SML_MODULES_LEVEL); | |
844 | sml_endmatch[0] = SML_MODULES_LEVEL; | |
845 | } | |
846 | /\b(signature)\b/ { | |
847 | sml_finish_typctxt (); | |
848 | sml_keyword ($0, SML_MODULES_LEVEL); | |
849 | sml_andbind[0] = SML_AND_SIGBIND; | |
850 | } | |
851 | /\b(struct)\b/ { | |
852 | sml_enter_scope ($0, SML_CORE_LEVEL); | |
853 | sml_keyword ($0, SML_MODULES_LEVEL); | |
854 | sml_endmatch[0] = SML_MODULES_LEVEL; | |
855 | } | |
856 | /\b(structure)\b/ { | |
857 | sml_finish_typctxt (); | |
858 | sml_keyword ($0, SML_MODULES_LEVEL); | |
859 | sml_andbind[0] = SML_AND_STRBIND; | |
860 | } | |
861 | /\b(then)\b/ { | |
862 | sml_keyword ($0, SML_CORE_LEVEL); | |
863 | } | |
864 | /\b(type)\b/ { | |
865 | if (strcmp(sml_last_keyword,"where") == 0) { | |
866 | sml_keyword ($0, SML_MODULES_LEVEL); | |
867 | sml_last_keyword = "where type"; | |
868 | sml_andbind[0] = SML_AND_WHERETYPE; | |
869 | sml_start_wheretyp (); | |
870 | } else if (strcmp(sml_last_keyword,"sharing") == 0) { | |
871 | sml_keyword ($0, SML_MODULES_LEVEL); | |
872 | sml_last_keyword = "sharing type"; | |
873 | sml_andbind[0] = SML_AND_NUL; | |
874 | sml_start_sharingtyp (); | |
875 | } else { | |
876 | sml_finish_typctxt (); | |
877 | sml_keyword ($0, SML_CORE_LEVEL); | |
878 | sml_andbind[0] = SML_AND_TYPBIND; | |
879 | sml_start_typbind (); | |
880 | } | |
881 | } | |
882 | sml_val_with_tyvar_re { | |
883 | sml_finish_typctxt (); | |
884 | sml_keyword ($1, SML_CORE_LEVEL); | |
885 | language_print ($2); | |
886 | type_face(true); | |
887 | language_print ($3); | |
888 | type_face(false); | |
889 | sml_andbind[0] = SML_AND_VALBIND; | |
890 | } | |
891 | sml_val_with_tyvarseq_re { | |
892 | sml_finish_typctxt (); | |
893 | sml_keyword ($1, SML_CORE_LEVEL); | |
894 | language_print ($2); | |
895 | language_print ($3); | |
896 | language_print ($4); | |
897 | type_face(true); | |
898 | language_print ($5); | |
899 | type_face(false); | |
900 | call (sml_tyvarseq); | |
901 | sml_andbind[0] = SML_AND_VALBIND; | |
902 | } | |
903 | /\b(val)\b/ { | |
904 | sml_finish_typctxt (); | |
905 | sml_keyword ($0, SML_CORE_LEVEL); | |
906 | sml_andbind[0] = SML_AND_VALBIND; | |
907 | } | |
908 | /\b(where)\b/ { | |
909 | sml_keyword ($0, SML_MODULES_LEVEL); | |
910 | } | |
911 | /\b(while)\b/ { | |
912 | sml_keyword ($0, SML_CORE_LEVEL); | |
913 | } | |
914 | /\b(with)\b/ { | |
915 | sml_finish_typctxt (); | |
916 | sml_keyword ($0, SML_CORE_LEVEL); | |
917 | } | |
918 | /\b(withtype)\b/ { | |
919 | sml_finish_typctxt (); | |
920 | sml_keyword ($0, SML_CORE_LEVEL); | |
921 | sml_andbind[0] = SML_AND_TYPBIND; | |
922 | sml_start_typbind (); | |
923 | } | |
924 | sml_longid_re { | |
925 | if (sml_conbind) { | |
926 | sml_conbind = FALSE; | |
927 | variable_name_face (true); | |
928 | language_print ($0); | |
929 | variable_name_face (false); | |
930 | } else { | |
931 | language_print ($0); | |
932 | } | |
933 | } | |
934 | sml_id_re { | |
935 | if (sml_conbind) { | |
936 | if (sml_datbind == SML_DATBIND_UNKNOWN) | |
937 | sml_datbind = SML_DATBIND_DECL; | |
938 | sml_conbind = FALSE; | |
939 | variable_name_face (true); | |
940 | language_print ($0); | |
941 | variable_name_face (false); | |
942 | } else { | |
943 | language_print ($0); | |
944 | } | |
945 | } | |
946 | ||
947 | /* extends sml_verbose */ | |
948 | sml_infix_re { | |
949 | keyword_face (true); | |
950 | language_print ($1); | |
951 | keyword_face (false); | |
952 | language_print ($3); | |
953 | language_print ($4); | |
954 | } | |
955 | sml_sel_re { | |
956 | language_print ($0); | |
957 | } | |
958 | ||
959 | /* | |
960 | * Special constants (nums) | |
961 | */ | |
962 | sml_scon_num_re { | |
963 | reference_face (true); | |
964 | language_print ($0); | |
965 | reference_face (false); | |
966 | } | |
967 | ||
968 | /* extend sml_simple */ | |
969 | BEGIN { | |
970 | header (); | |
971 | } | |
972 | END { | |
973 | sml_finish_typctxt (); | |
974 | trailer (); | |
975 | } | |
976 | ||
977 | /* | |
978 | * Keywords | |
979 | */ | |
980 | sml_keywords_re { | |
981 | keyword_face (true); | |
982 | language_print ($0); | |
983 | keyword_face (false); | |
984 | } | |
985 | ||
986 | /* | |
987 | * Special constants (strings) | |
988 | */ | |
989 | /\"/ { | |
990 | string_face (true); | |
991 | language_print ($0); | |
992 | call (sml_string); | |
993 | string_face (false); | |
994 | } | |
995 | ||
996 | /* | |
997 | * Special constants (chars) | |
998 | */ | |
999 | /(#)(\")/ { | |
1000 | language_print ($1); | |
1001 | string_face (true); | |
1002 | language_print ($2); | |
1003 | call (sml_string); | |
1004 | string_face (false); | |
1005 | } | |
1006 | ||
1007 | /* | |
1008 | * Comments | |
1009 | */ | |
1010 | /\(\*/ { | |
1011 | comment_face (true); | |
1012 | language_print ($0); | |
1013 | call (sml_comment); | |
1014 | comment_face (false); | |
1015 | } | |
1016 | ||
1017 | LANGUAGE_SPECIALS { | |
1018 | language_print ($0); | |
1019 | } | |
1020 | } | |
1021 | ||
1022 | \f | |
1023 | /* | |
1024 | Local variables: | |
1025 | mode: c | |
1026 | End: | |
1027 | */ | |
1028 | ||
1029 | /** | |
1030 | * Name: sml_gaudy | |
1031 | * Description: Standard ML programming language. | |
1032 | * Author: Matthew Fluet <mfluet@acm.org> | |
1033 | */ | |
1034 | ||
1035 | /* | |
1036 | builtin_face --- | |
1037 | comment_face --- comments | |
1038 | function_name_face --- modules keywords | |
1039 | highlight_face --- | |
1040 | keyword_face --- core keywords | |
1041 | reference_face --- special constants (nums) | |
1042 | string_face --- strings | |
1043 | type_face --- type bindings, type annotations | |
1044 | variable_name_face --- constructor bindings | |
1045 | */ | |
1046 | ||
1047 | /* | |
1048 | require_state (sml_fancy); | |
1049 | */ | |
1050 | ||
1051 | state sml_gaudy /* extends sml_fancy */ | |
1052 | { | |
1053 | /* | |
1054 | * Keywords | |
1055 | */ | |
1056 | /,/ { | |
1057 | sml_finish_typctxt (); | |
1058 | language_print ($0); | |
1059 | } | |
1060 | /:/ { | |
1061 | if (sml_andbind[0] == SML_AND_STRBIND || | |
1062 | sml_andbind[0] == SML_AND_FUNBIND) { | |
1063 | language_print ($0); | |
1064 | } else { | |
1065 | language_print ($0); | |
1066 | if (sml_typctxt == -1) | |
1067 | sml_start_typctxt (0); | |
1068 | } | |
1069 | } | |
1070 | ||
1071 | /* extends sml_fancy */ | |
1072 | /* | |
1073 | * Keywords | |
1074 | */ | |
1075 | /(:|,|_|->)/ { | |
1076 | language_print ($0); | |
1077 | } | |
1078 | /[\({[]/ { | |
1079 | sml_enter_scope ($0,sml_scopes[0][1]); | |
1080 | language_print ($0); | |
1081 | } | |
1082 | /[]}\)]/ { | |
1083 | sml_finish_typctxt (); | |
1084 | language_print ($0); | |
1085 | sml_leave_scope (); | |
1086 | } | |
1087 | /(\.\.\.|;|=>)/ { | |
1088 | sml_finish_typctxt (); | |
1089 | sml_andbind[0] = SML_AND_NUL; | |
1090 | language_print ($0); | |
1091 | } | |
1092 | /\|/ { | |
1093 | if (sml_datbind == SML_DATBIND_DECL) { | |
1094 | type_face (false); | |
1095 | language_print ($0); | |
1096 | sml_conbind = TRUE; | |
1097 | type_face (true); | |
1098 | } else { | |
1099 | language_print ($0); | |
1100 | } | |
1101 | } | |
1102 | /=/ { | |
1103 | if (sml_typctxt != -1) { | |
1104 | type_face (false); | |
1105 | language_print ($0); | |
1106 | type_face (true); | |
1107 | if (sml_typctxt_expected_eqs == 0) { | |
1108 | sml_finish_typctxt (); | |
1109 | } else { | |
1110 | sml_typctxt_expected_eqs--; | |
1111 | if (sml_datbind == SML_DATBIND_UNKNOWN) { | |
1112 | sml_conbind = TRUE; | |
1113 | } | |
1114 | if (sml_exbind) { | |
1115 | sml_conbind = TRUE; | |
1116 | } | |
1117 | } | |
1118 | } else { | |
1119 | language_print ($0); | |
1120 | } | |
1121 | } | |
1122 | sml_sel_re { | |
1123 | language_print ($0); | |
1124 | } | |
1125 | /\b(abstype)\b/ { | |
1126 | sml_finish_typctxt (); | |
1127 | sml_enter_scope ($0,SML_CORE_LEVEL); | |
1128 | sml_keyword ($0, SML_CORE_LEVEL); | |
1129 | sml_andbind[0] = SML_AND_DATBIND; | |
1130 | sml_endmatch[0] = SML_CORE_LEVEL; | |
1131 | sml_start_datbind (); | |
1132 | } | |
1133 | /\b(and)\b/ { | |
1134 | sml_finish_typctxt (); | |
1135 | if (sml_andbind[0] == SML_AND_VALBIND) { | |
1136 | sml_keyword ($0, SML_CORE_LEVEL); | |
1137 | } else if (sml_andbind[0] == SML_AND_TYPBIND) { | |
1138 | sml_keyword ($0, SML_CORE_LEVEL); | |
1139 | sml_start_typbind (); | |
1140 | } else if (sml_andbind[0] == SML_AND_DATBIND) { | |
1141 | sml_keyword ($0, SML_CORE_LEVEL); | |
1142 | sml_start_datbind (); | |
1143 | } else if (sml_andbind[0] == SML_AND_EXBIND) { | |
1144 | sml_keyword ($0, SML_CORE_LEVEL); | |
1145 | sml_start_exbind (); | |
1146 | } else if (sml_andbind[0] == SML_AND_STRBIND) { | |
1147 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1148 | } else if (sml_andbind[0] == SML_AND_SIGBIND) { | |
1149 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1150 | } else if (sml_andbind[0] == SML_AND_FUNBIND) { | |
1151 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1152 | } else if (sml_andbind[0] == SML_AND_WHERETYPE) { | |
1153 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1154 | sml_last_keyword = "where"; | |
1155 | } | |
1156 | ||
1157 | } | |
1158 | /\b(andalso)\b/ { | |
1159 | sml_keyword ($0, SML_CORE_LEVEL); | |
1160 | } | |
1161 | /\b(as)\b/ { | |
1162 | sml_keyword ($0, SML_CORE_LEVEL); | |
1163 | } | |
1164 | /\b(case)\b/ { | |
1165 | sml_keyword ($0, SML_CORE_LEVEL); | |
1166 | } | |
1167 | /\b(datatype)\b/ { | |
1168 | if (sml_datbind == SML_DATBIND_UNKNOWN) { | |
1169 | sml_datbind = SML_DATBIND_REPL; | |
1170 | sml_conbind = FALSE; | |
1171 | sml_keyword ($0, SML_CORE_LEVEL); | |
1172 | } else { | |
1173 | sml_finish_typctxt (); | |
1174 | sml_keyword ($0, SML_CORE_LEVEL); | |
1175 | sml_andbind[0] = SML_AND_DATBIND; | |
1176 | sml_start_datbind (); | |
1177 | } | |
1178 | } | |
1179 | /\b(do)\b/ { | |
1180 | sml_keyword ($0, SML_CORE_LEVEL); | |
1181 | } | |
1182 | /\b(else)\b/ { | |
1183 | sml_keyword ($0, SML_CORE_LEVEL); | |
1184 | } | |
1185 | /\b(end)\b/ { | |
1186 | sml_finish_typctxt (); | |
1187 | sml_keyword ($0, sml_endmatch[0]); | |
1188 | sml_leave_scope (); | |
1189 | } | |
1190 | /\b(eqtype)\b/ { | |
1191 | sml_finish_typctxt (); | |
1192 | sml_keyword ($0, SML_CORE_LEVEL); | |
1193 | sml_start_eqtyp (); | |
1194 | } | |
1195 | /\b(exception)\b/ { | |
1196 | sml_finish_typctxt (); | |
1197 | sml_keyword ($0, SML_CORE_LEVEL); | |
1198 | sml_andbind[0] = SML_AND_EXBIND; | |
1199 | sml_start_exbind (); | |
1200 | } | |
1201 | /\b(fn)\b/ { | |
1202 | sml_keyword ($0, SML_CORE_LEVEL); | |
1203 | } | |
1204 | sml_fun_with_tyvar_re { | |
1205 | sml_finish_typctxt (); | |
1206 | sml_keyword ($1, SML_CORE_LEVEL); | |
1207 | language_print ($2); | |
1208 | type_face(true); | |
1209 | language_print ($3); | |
1210 | type_face(false); | |
1211 | sml_andbind[0] = SML_AND_VALBIND; | |
1212 | } | |
1213 | sml_fun_with_tyvarseq_re { | |
1214 | sml_finish_typctxt (); | |
1215 | sml_keyword ($1, SML_CORE_LEVEL); | |
1216 | language_print ($2); | |
1217 | language_print ($3); | |
1218 | language_print ($4); | |
1219 | type_face(true); | |
1220 | language_print ($5); | |
1221 | type_face(false); | |
1222 | call (sml_tyvarseq); | |
1223 | sml_andbind[0] = SML_AND_VALBIND; | |
1224 | } | |
1225 | /\b(fun)\b/ { | |
1226 | sml_finish_typctxt (); | |
1227 | sml_keyword ($0, SML_CORE_LEVEL); | |
1228 | sml_andbind[0] = SML_AND_VALBIND; | |
1229 | } | |
1230 | /\b(functor)\b/ { | |
1231 | sml_finish_typctxt (); | |
1232 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1233 | sml_andbind[0] = SML_AND_FUNBIND; | |
1234 | } | |
1235 | /\b(handle)\b/ { | |
1236 | sml_keyword ($0, SML_CORE_LEVEL); | |
1237 | } | |
1238 | /\b(if)\b/ { | |
1239 | sml_keyword ($0, SML_CORE_LEVEL); | |
1240 | } | |
1241 | /\b(in)\b/ { | |
1242 | sml_finish_typctxt (); | |
1243 | sml_andbind[0] = SML_AND_NUL; | |
1244 | sml_keyword ($0, sml_endmatch[0]); | |
1245 | } | |
1246 | /\b(include)\b/ { | |
1247 | sml_finish_typctxt (); | |
1248 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1249 | } | |
1250 | sml_infix_re { | |
1251 | sml_finish_typctxt (); | |
1252 | sml_keyword ($1, SML_CORE_LEVEL); | |
1253 | language_print ($3); | |
1254 | language_print ($4); | |
1255 | } | |
1256 | /\b(let)\b/ { | |
1257 | sml_finish_typctxt (); | |
1258 | if (sml_let_level()) { | |
1259 | sml_enter_scope ($0,SML_MODULES_LEVEL); | |
1260 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1261 | sml_endmatch[0] = SML_MODULES_LEVEL; | |
1262 | } else { | |
1263 | sml_enter_scope ($0,SML_CORE_LEVEL); | |
1264 | sml_keyword ($0, SML_CORE_LEVEL); | |
1265 | sml_endmatch[0] = SML_CORE_LEVEL; | |
1266 | } | |
1267 | } | |
1268 | /\b(local)\b/ { | |
1269 | sml_finish_typctxt (); | |
1270 | if (sml_local_level ()) { | |
1271 | sml_enter_scope ($0, SML_MODULES_LEVEL); | |
1272 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1273 | sml_endmatch[0] = SML_MODULES_LEVEL; | |
1274 | } else { | |
1275 | sml_enter_scope ($0, SML_CORE_LEVEL); | |
1276 | sml_keyword ($0, SML_CORE_LEVEL); | |
1277 | sml_endmatch[0] = SML_CORE_LEVEL; | |
1278 | } | |
1279 | } | |
1280 | /\b(nonfix)\b/ { | |
1281 | sml_finish_typctxt (); | |
1282 | sml_keyword ($0, SML_CORE_LEVEL); | |
1283 | } | |
1284 | /\b(of)\b/ { | |
1285 | sml_keyword ($0, SML_CORE_LEVEL); | |
1286 | } | |
1287 | /\b(op)\b/ { | |
1288 | sml_keyword ($0, SML_CORE_LEVEL); | |
1289 | } | |
1290 | /\b(open)\b/ { | |
1291 | sml_finish_typctxt (); | |
1292 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1293 | } | |
1294 | /\b(orelse)\b/ { | |
1295 | sml_keyword ($0, SML_CORE_LEVEL); | |
1296 | } | |
1297 | /\b(raise)\b/ { | |
1298 | sml_keyword ($0, SML_CORE_LEVEL); | |
1299 | } | |
1300 | /\b(rec)\b/ { | |
1301 | sml_keyword ($0, SML_CORE_LEVEL); | |
1302 | } | |
1303 | /\b(sharing)\b/ { | |
1304 | sml_finish_typctxt (); | |
1305 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1306 | } | |
1307 | /\b(sig)\b/ { | |
1308 | sml_enter_scope ($0, SML_CORE_LEVEL); | |
1309 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1310 | sml_endmatch[0] = SML_MODULES_LEVEL; | |
1311 | } | |
1312 | /\b(signature)\b/ { | |
1313 | sml_finish_typctxt (); | |
1314 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1315 | sml_andbind[0] = SML_AND_SIGBIND; | |
1316 | } | |
1317 | /\b(struct)\b/ { | |
1318 | sml_enter_scope ($0, SML_CORE_LEVEL); | |
1319 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1320 | sml_endmatch[0] = SML_MODULES_LEVEL; | |
1321 | } | |
1322 | /\b(structure)\b/ { | |
1323 | sml_finish_typctxt (); | |
1324 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1325 | sml_andbind[0] = SML_AND_STRBIND; | |
1326 | } | |
1327 | /\b(then)\b/ { | |
1328 | sml_keyword ($0, SML_CORE_LEVEL); | |
1329 | } | |
1330 | /\b(type)\b/ { | |
1331 | if (strcmp(sml_last_keyword,"where") == 0) { | |
1332 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1333 | sml_last_keyword = "where type"; | |
1334 | sml_andbind[0] = SML_AND_WHERETYPE; | |
1335 | sml_start_wheretyp (); | |
1336 | } else if (strcmp(sml_last_keyword,"sharing") == 0) { | |
1337 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1338 | sml_last_keyword = "sharing type"; | |
1339 | sml_andbind[0] = SML_AND_NUL; | |
1340 | sml_start_sharingtyp (); | |
1341 | } else { | |
1342 | sml_finish_typctxt (); | |
1343 | sml_keyword ($0, SML_CORE_LEVEL); | |
1344 | sml_andbind[0] = SML_AND_TYPBIND; | |
1345 | sml_start_typbind (); | |
1346 | } | |
1347 | } | |
1348 | sml_val_with_tyvar_re { | |
1349 | sml_finish_typctxt (); | |
1350 | sml_keyword ($1, SML_CORE_LEVEL); | |
1351 | language_print ($2); | |
1352 | type_face(true); | |
1353 | language_print ($3); | |
1354 | type_face(false); | |
1355 | sml_andbind[0] = SML_AND_VALBIND; | |
1356 | } | |
1357 | sml_val_with_tyvarseq_re { | |
1358 | sml_finish_typctxt (); | |
1359 | sml_keyword ($1, SML_CORE_LEVEL); | |
1360 | language_print ($2); | |
1361 | language_print ($3); | |
1362 | language_print ($4); | |
1363 | type_face(true); | |
1364 | language_print ($5); | |
1365 | type_face(false); | |
1366 | call (sml_tyvarseq); | |
1367 | sml_andbind[0] = SML_AND_VALBIND; | |
1368 | } | |
1369 | /\b(val)\b/ { | |
1370 | sml_finish_typctxt (); | |
1371 | sml_keyword ($0, SML_CORE_LEVEL); | |
1372 | sml_andbind[0] = SML_AND_VALBIND; | |
1373 | } | |
1374 | /\b(where)\b/ { | |
1375 | sml_keyword ($0, SML_MODULES_LEVEL); | |
1376 | } | |
1377 | /\b(while)\b/ { | |
1378 | sml_keyword ($0, SML_CORE_LEVEL); | |
1379 | } | |
1380 | /\b(with)\b/ { | |
1381 | sml_finish_typctxt (); | |
1382 | sml_keyword ($0, SML_CORE_LEVEL); | |
1383 | } | |
1384 | /\b(withtype)\b/ { | |
1385 | sml_finish_typctxt (); | |
1386 | sml_keyword ($0, SML_CORE_LEVEL); | |
1387 | sml_andbind[0] = SML_AND_TYPBIND; | |
1388 | sml_start_typbind (); | |
1389 | } | |
1390 | sml_longid_re { | |
1391 | if (sml_conbind) { | |
1392 | sml_conbind = FALSE; | |
1393 | variable_name_face (true); | |
1394 | language_print ($0); | |
1395 | variable_name_face (false); | |
1396 | } else { | |
1397 | language_print ($0); | |
1398 | } | |
1399 | } | |
1400 | sml_id_re { | |
1401 | if (sml_conbind) { | |
1402 | if (sml_datbind == SML_DATBIND_UNKNOWN) | |
1403 | sml_datbind = SML_DATBIND_DECL; | |
1404 | sml_conbind = FALSE; | |
1405 | variable_name_face (true); | |
1406 | language_print ($0); | |
1407 | variable_name_face (false); | |
1408 | } else { | |
1409 | language_print ($0); | |
1410 | } | |
1411 | } | |
1412 | ||
1413 | /* extends sml_verbose */ | |
1414 | sml_infix_re { | |
1415 | keyword_face (true); | |
1416 | language_print ($1); | |
1417 | keyword_face (false); | |
1418 | language_print ($3); | |
1419 | language_print ($4); | |
1420 | } | |
1421 | sml_sel_re { | |
1422 | language_print ($0); | |
1423 | } | |
1424 | ||
1425 | /* | |
1426 | * Special constants (nums) | |
1427 | */ | |
1428 | sml_scon_num_re { | |
1429 | reference_face (true); | |
1430 | language_print ($0); | |
1431 | reference_face (false); | |
1432 | } | |
1433 | ||
1434 | /* extend sml_simple */ | |
1435 | BEGIN { | |
1436 | header (); | |
1437 | } | |
1438 | END { | |
1439 | sml_finish_typctxt (); | |
1440 | trailer (); | |
1441 | } | |
1442 | ||
1443 | /* | |
1444 | * Keywords | |
1445 | */ | |
1446 | sml_keywords_re { | |
1447 | keyword_face (true); | |
1448 | language_print ($0); | |
1449 | keyword_face (false); | |
1450 | } | |
1451 | ||
1452 | /* | |
1453 | * Special constants (strings) | |
1454 | */ | |
1455 | /\"/ { | |
1456 | string_face (true); | |
1457 | language_print ($0); | |
1458 | call (sml_string); | |
1459 | string_face (false); | |
1460 | } | |
1461 | ||
1462 | /* | |
1463 | * Special constants (chars) | |
1464 | */ | |
1465 | /(#)(\")/ { | |
1466 | language_print ($1); | |
1467 | string_face (true); | |
1468 | language_print ($2); | |
1469 | call (sml_string); | |
1470 | string_face (false); | |
1471 | } | |
1472 | ||
1473 | /* | |
1474 | * Comments | |
1475 | */ | |
1476 | /\(\*/ { | |
1477 | comment_face (true); | |
1478 | language_print ($0); | |
1479 | call (sml_comment); | |
1480 | comment_face (false); | |
1481 | } | |
1482 | ||
1483 | LANGUAGE_SPECIALS { | |
1484 | language_print ($0); | |
1485 | } | |
1486 | } | |
1487 | ||
1488 | \f | |
1489 | /* | |
1490 | Local variables: | |
1491 | mode: c | |
1492 | End: | |
1493 | */ |