220 lines
7.1 KiB
Plaintext
220 lines
7.1 KiB
Plaintext
<beginfold id='1'>/********</beginfold id='1'>
|
|
* Highlight testing module.
|
|
*
|
|
* Do not attempt to run this!
|
|
<endfold id='1'>***********/</endfold id='1'>
|
|
module highlighttest;
|
|
import X = null;
|
|
|
|
<beginfold id='2'>/++</beginfold id='2'> Pragma directives. DDoc + DDoc embedded items. Special Tokens.
|
|
+
|
|
+ ---
|
|
+ // comment
|
|
+ #line 12 "hightlighttest.d" <beginfold id='3'>/*</beginfold id='3'> block comment <endfold id='3'>*/</endfold id='3'>
|
|
+ #line __LINE__ __FILE__ <beginfold id='2'>/++</beginfold id='2'> embedded block comment <endfold id='2'>+/</endfold id='2'>
|
|
+
|
|
+ pragma <beginfold id='3'>/*</beginfold id='3'> <endfold id='3'>*/</endfold id='3'> (msg, "what?");
|
|
+ pragma(<beginfold id='2'>/++</beginfold id='2'> <endfold id='2'>+/</endfold id='2'> lib, "insane.a");
|
|
+ pragma(inline);
|
|
+ pragma(linkerDirective);
|
|
+ pragma(mangle);
|
|
+ pragma(startaddress);
|
|
+ pragma(D_Custom_Extension, "custom data");
|
|
+ pragma(foo 0);
|
|
+ ---
|
|
<endfold id='2'>+/</endfold id='2'>
|
|
|
|
/// version condition
|
|
version = X;
|
|
version = 1_2_3;
|
|
version (X) ;
|
|
version(linux) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
|
|
/// linkage
|
|
extern
|
|
(C) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
extern :
|
|
;
|
|
extern (C++) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
extern (C++, foo.bar.baz) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
extern (D) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
extern (Windows) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
extern (Pascal) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
extern (System) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
extern (unknown) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
extern (C,) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
extern (C++, foo, bar) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
|
|
/// alias & typedef
|
|
alias int.min minint;
|
|
typedef int myint;
|
|
|
|
int main(char[][] args) <beginfold id='4'>{</beginfold id='4'>
|
|
/// statements
|
|
if (1) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
else <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
with (N) <beginfold id='4'>{</beginfold id='4'>x = B<endfold id='4'>}</endfold id='4'>
|
|
|
|
/// attributes
|
|
auto x = 1;
|
|
static if (true) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
void (in X, out Y) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'> // NOTE: using in like this is rare, more common to use as an expression and no way to tell apart?
|
|
|
|
/// deprecated
|
|
deprecated void fct ();
|
|
|
|
/// types
|
|
void a;
|
|
ushort u;
|
|
int[uint] AA;
|
|
class C;
|
|
enum N : int <beginfold id='4'>{</beginfold id='4'> A = 5, B <endfold id='4'>}</endfold id='4'>
|
|
typeof(u) u2;
|
|
|
|
/// expressions
|
|
x = cast(int) 55;
|
|
void* p = null;
|
|
p = cast(void*) new int;
|
|
x = 1 in AA; // NOTE: a THIRD use of in. How to detect??
|
|
assert (true);
|
|
|
|
/// libsymbols
|
|
string s = "";
|
|
throw new Exception;
|
|
TypeInfo ti = typeid(int);
|
|
|
|
/// tests
|
|
debug <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
debug (2) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
debug (DSymb) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
unittest <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
|
|
/// scope (as attribute and as statement)
|
|
scope struct S;
|
|
scope (exit) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
scope
|
|
(success) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'> // NOTE: rules cannot match across new-lines
|
|
scope (failure) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
|
|
/// Properties
|
|
x = int.min;
|
|
s = (5-3).stringof;
|
|
|
|
/// strings
|
|
s = r"raw string";
|
|
s = x"00FF";
|
|
s = \n \a;
|
|
s = \u1234;
|
|
s = \U12345678;
|
|
s = \& ;
|
|
char c = 'a';
|
|
s = "abc 012 \" \n \x12 \u1234 \U12345678";
|
|
s = `BQString '"`;
|
|
s = q{foo "bar" 123};
|
|
s = q"FOO
|
|
foo
|
|
FOO";
|
|
s = q"[foo [bar] q"[baz]"]";
|
|
s = q"(foo (bar) q"(baz)")";
|
|
s = q"<foo <bar> q"<baz>">";
|
|
s = q"{foo {bar} q"{baz}"}";
|
|
s = q"/foo/";
|
|
s = q"!foo!";
|
|
|
|
/// region markers
|
|
<beginfold id='5'>//BEGIN</beginfold id='5'> x
|
|
<endfold id='5'>//END</endfold id='5'> x
|
|
|
|
/// DDoc
|
|
<beginfold id='1'>/*******</beginfold id='1'>
|
|
* DDoc
|
|
*
|
|
* Section:
|
|
* New section.
|
|
* $(I italic)
|
|
<endfold id='1'>*******/</endfold id='1'>
|
|
<beginfold id='2'>/+++++++</beginfold id='2'>
|
|
+ DDoc
|
|
+ /+
|
|
+ +/
|
|
<endfold id='2'>+++++++/</endfold id='2'>
|
|
|
|
// comments
|
|
// FIXME NOTE
|
|
<beginfold id='3'>/*</beginfold id='3'> comment <endfold id='3'>*/</endfold id='3'>
|
|
<beginfold id='6'>/+</beginfold id='6'> comment <beginfold id='6'>/+</beginfold id='6'> nested comment <endfold id='6'>+/</endfold id='6'> <endfold id='6'>+/</endfold id='6'>
|
|
|
|
/// brace folding
|
|
<beginfold id='4'>{</beginfold id='4'>
|
|
<endfold id='4'>}</endfold id='4'>
|
|
|
|
<beginfold id='1'>/**</beginfold id='1'> normal text
|
|
* ---
|
|
* .x;
|
|
* ..
|
|
* ...
|
|
* ....
|
|
* .....
|
|
* _._
|
|
* _e1
|
|
* ---
|
|
<endfold id='1'>*/</endfold id='1'>
|
|
|
|
/// float and int literals
|
|
int i;
|
|
real r;
|
|
ireal ir;
|
|
r = .0;
|
|
r = 0f;
|
|
ir = 0e0i;
|
|
ir = 0.fi;
|
|
r = 0.0e0;
|
|
r = 0xF.Fp0;
|
|
r = 0x_._p0_;
|
|
i = 5;
|
|
i = -1;
|
|
i = 0b10;
|
|
i = 0070;
|
|
i = 00;
|
|
i = 0xF0;
|
|
|
|
/// ranges
|
|
int[] A;
|
|
i = A[1];
|
|
A = A[0..$];
|
|
A = A[0..0];
|
|
A = A[0..length];
|
|
|
|
/// labels
|
|
label:
|
|
goto label;
|
|
|
|
/// function, delegate
|
|
creal function () fp = function creal() <beginfold id='4'>{</beginfold id='4'> return 0f+0fi; <endfold id='4'>}</endfold id='4'>;
|
|
void delegate (in int i, lazy int b) dg = delegate void (int, int) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
|
|
/// in, out, body
|
|
// NOTE: highlighting in & out as statements here could be difficult
|
|
float F ()
|
|
in <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
out (result) <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
body <beginfold id='4'>{</beginfold id='4'><endfold id='4'>}</endfold id='4'>
|
|
|
|
/// try, catch, finally
|
|
try <beginfold id='4'>{</beginfold id='4'>
|
|
throw new Exception("oh no... ");
|
|
<endfold id='4'>}</endfold id='4'> catch (Exception e) <beginfold id='4'>{</beginfold id='4'>
|
|
<endfold id='4'>}</endfold id='4'> finally <beginfold id='4'>{</beginfold id='4'>
|
|
<endfold id='4'>}</endfold id='4'>
|
|
|
|
/// mixin
|
|
mixin("return false;").stringof;
|
|
|
|
/// templates
|
|
macro; // what does this do?
|
|
template Tp (T) <beginfold id='4'>{</beginfold id='4'>
|
|
Tp t;
|
|
<endfold id='4'>}</endfold id='4'>
|
|
Tp!(int) y;
|
|
<endfold id='4'>}</endfold id='4'>
|