1 /********
2 * Highlight testing module.
3 *
4 * Do not attempt to run this!
5 ***********/
6 module highlighttest;
7 import X = null;
8
9 /++ Pragma directives. DDoc + DDoc embedded items. Special Tokens.
10 +
11 + ---
12 + // comment
13 + #line 12 "hightlighttest.d" /* block comment */
14 + #line __LINE__ __FILE__ /++ embedded block comment +/
15 +
16 + pragma /* */ (msg, "what?");
17 + pragma(/++ +/ lib, "insane.a");
18 + pragma(inline);
19 + pragma(linkerDirective);
20 + pragma(mangle);
21 + pragma(startaddress);
22 + pragma(D_Custom_Extension, "custom data");
23 + pragma(foo 0);
24 + ---
25 +/
26
27 /// version condition
28 version = X;
29 version = 1_2_3;
30 version (X) ;
version(linux)31 version(linux) {}
32
33 /// linkage
34 extern
35 (C) {}
36 extern :
37 ;
38 extern (C++) {}
39 extern (C++, foo.bar.baz) {}
40 extern (D) {}
41 extern (Windows) {}
42 extern (Pascal) {}
43 extern (System) {}
44 extern (unknown) {}
45 extern (C,) {}
46 extern (C++, foo, bar) {}
47
48 /// alias & typedef
49 alias int.min minint;
50 typedef int myint;
51
main(char[][]args)52 int main(char[][] args) {
53 /// statements
54 if (1) {}
55 else {}
56 with (N) {x = B}
57
58 /// attributes
59 auto x = 1;
60 static if (true) {}
61 void (in X, out Y) {} // NOTE: using in like this is rare, more common to use as an expression and no way to tell apart?
62
63 /// deprecated
64 deprecated void fct ();
65
66 /// types
67 void a;
68 ushort u;
69 int[uint] AA;
70 class C;
71 enum N : int { A = 5, B }
72 typeof(u) u2;
73
74 /// expressions
75 x = cast(int) 55;
76 void* p = null;
77 p = cast(void*) new int;
78 x = 1 in AA; // NOTE: a THIRD use of in. How to detect??
79 assert (true);
80
81 /// libsymbols
82 string s = "";
83 throw new Exception;
84 TypeInfo ti = typeid(int);
85
86 /// tests
87 debug {}
88 debug (2) {}
89 debug (DSymb) {}
90 unittest {}
91
92 /// scope (as attribute and as statement)
93 scope struct S;
94 scope (exit) {}
95 scope
96 (success) {} // NOTE: rules cannot match across new-lines
97 scope (failure) {}
98
99 /// Properties
100 x = int.min;
101 s = (5-3).stringof;
102
103 /// strings
104 s = r"raw string";
105 s = x"00FF";
106 s = \n \a;
107 s = \u1234;
108 s = \U12345678;
109 s = \& ;
110 char c = 'a';
111 s = "abc 012 \" \n \x12 \u1234 \U12345678";
112 s = `BQString '"`;
113 s = q{foo "bar" 123};
114 s = q"FOO
115 foo
116 FOO";
117 s = q"[foo [bar] q"[baz]"]";
118 s = q"(foo (bar) q"(baz)")";
119 s = q"<foo <bar> q"<baz>">";
120 s = q"{foo {bar} q"{baz}"}";
121 s = q"/foo/";
122 s = q"!foo!";
123
124 /// region markers
125 //BEGIN x
126 //END x
127
128 /// DDoc
129 /*******
130 * DDoc
131 *
132 * Section:
133 * New section.
134 * $(I italic)
135 *******/
136 /+++++++
137 + DDoc
138 + /+
139 + +/
140 +++++++/
141
142 // comments
143 // FIXME NOTE
144 /* comment */
145 /+ comment /+ nested comment +/ +/
146
147 /// brace folding
148 {
149 }
150
151 /** normal text
152 * ---
153 * .x;
154 * ..
155 * ...
156 * ....
157 * .....
158 * _._
159 * _e1
160 * ---
161 */
162
163 /// float and int literals
164 int i;
165 real r;
166 ireal ir;
167 r = .0;
168 r = 0f;
169 ir = 0e0i;
170 ir = 0.fi;
171 r = 0.0e0;
172 r = 0xF.Fp0;
173 r = 0x_._p0_;
174 i = 5;
175 i = -1;
176 i = 0b10;
177 i = 0070;
178 i = 00;
179 i = 0xF0;
180
181 /// ranges
182 int[] A;
183 i = A[1];
184 A = A[0..$];
185 A = A[0..0];
186 A = A[0..length];
187
188 /// labels
189 label:
190 goto label;
191
192 /// function, delegate
193 creal function () fp = function creal() { return 0f+0fi; };
194 void delegate (in int i, lazy int b) dg = delegate void (int, int) {}
195
196 /// in, out, body
197 // NOTE: highlighting in & out as statements here could be difficult
198 float F ()
199 in {}
200 out (result) {}
201 body {}
202
203 /// try, catch, finally
204 try {
205 throw new Exception("oh no... ");
206 } catch (Exception e) {
207 } finally {
208 }
209
210 /// mixin
211 mixin("return false;").stringof;
212
213 /// templates
214 macro; // what does this do?
215 template Tp (T) {
216 Tp t;
217 }
218 Tp!(int) y;
219 }
220