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 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 | */ | |
78 | state 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 | ||
95 | state 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 | */ | |
110 | state 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 | /* | |
131 | Local variables: | |
132 | mode: c | |
133 | End: | |
134 | */ |