Import Debian changes 20180207-1
[hcoop/debian/mlton.git] / ide / enscript / sml_simple.st
CommitLineData
7f918cf1
CE
1/**
2 * Name: sml_simple
3 * Description: Standard ML programming language.
4 * Author: Matthew Fluet <mfluet@acm.org>
5 */
6
7/*
8builtin_face ---
9comment_face --- comments
10function_name_face ---
11highlight_face ---
12keyword_face --- keywords
13reference_face ---
14string_face --- strings
15type_face ---
16variable_name_face ---
17*/
18
19sml_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
32state sml_simple extends HighlightEntry
33{
34 /*
35 * Keywords
36 */
37 sml_keywords_re {
38 keyword_face (true);
39 language_print ($0);
40 keyword_face (false);
41 }
42
43 /*
44 * Special constants (strings)
45 */
46 /\"/ {
47 string_face (true);
48 language_print ($0);
49 call (sml_string);
50 string_face (false);
51 }
52
53 /*
54 * Special constants (chars)
55 */
56 /(#)(\")/ {
57 language_print ($1);
58 string_face (true);
59 language_print ($2);
60 call (sml_string);
61 string_face (false);
62 }
63
64 /*
65 * Comments
66 */
67 /\(\*/ {
68 comment_face (true);
69 language_print ($0);
70 call (sml_comment);
71 comment_face (false);
72 }
73}
74
75/*
76 * Strings
77 */
78state sml_string extends Highlight
79{
80 /\\\\(\s|\n)/ {
81 language_print ($0);
82 call (sml_string_gap);
83 }
84
85 /\\\\./ {
86 language_print ($0);
87 }
88
89 /\"/ {
90 language_print ($0);
91 return;
92 }
93}
94
95state sml_string_gap extends Highlight
96{
97 /(\s|\n)/ {
98 language_print ($0);
99 }
100
101 /\\\\/ {
102 language_print ($0);
103 return;
104 }
105}
106
107/*
108 * Nested comments
109 */
110state sml_comment extends Highlight
111{
112 BEGIN {
113 sml_comment_depth = 1;
114 }
115
116 /\(\*/ {
117 sml_comment_depth += 1;
118 language_print ($0);
119 }
120
121 /\*\)/ {
122 sml_comment_depth -= 1;
123 language_print ($0);
124 if (sml_comment_depth == 0)
125 return;
126 }
127}
128
129\f
130/*
131Local variables:
132mode: c
133End:
134*/