Warning, /frameworks/syntax-highlighting/autotests/input/highlight.d is written in an unsupported language. File is not indexed.

0001 /********
0002 * Highlight testing module.
0003 *
0004 * Do not attempt to run this!
0005 ***********/
0006 module highlighttest;
0007 import X = null;
0008 
0009 /++ Pragma directives. DDoc + DDoc embedded items. Special Tokens.
0010 +
0011 + ---
0012 + // comment
0013 + #line 12 "hightlighttest.d"   /* block comment */
0014 + #line __LINE__ __FILE__       /++ embedded block comment +/
0015 +
0016 + pragma /* */ (msg, "what?");
0017 + pragma(/++ +/ lib, "insane.a");
0018 + pragma(inline);
0019 + pragma(linkerDirective);
0020 + pragma(mangle);
0021 + pragma(startaddress);
0022 + pragma(D_Custom_Extension, "custom data");
0023 + pragma(foo 0);
0024 + ---
0025 +/
0026 
0027 /// version condition
0028 version = X;
0029 version = 1_2_3;
0030 version (X) ;
0031 version(linux) {}
0032 
0033 /// linkage
0034 extern
0035     (C) {}
0036 extern :
0037 ;
0038 extern (C++) {}
0039 extern (C++, foo.bar.baz) {}
0040 extern (D) {}
0041 extern (Windows) {}
0042 extern (Pascal) {}
0043 extern (System) {}
0044 extern (unknown) {}
0045 extern (C,) {}
0046 extern (C++, foo, bar) {}
0047 
0048 /// alias & typedef
0049 alias int.min minint;
0050 typedef int myint;
0051 
0052 int main(char[][] args) {
0053     /// statements
0054     if (1) {}
0055     else {}
0056     with (N) {x = B}
0057     
0058     /// attributes
0059     auto x = 1;
0060     static if (true) {}
0061     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?
0062     
0063     /// deprecated
0064     deprecated void fct ();
0065     
0066     /// types
0067     void a;
0068     ushort u;
0069     int[uint] AA;
0070     class C;
0071     enum N : int { A = 5, B }
0072     typeof(u) u2;
0073     
0074     /// expressions
0075     x = cast(int) 55;
0076     void* p = null;
0077     p = cast(void*) new int;
0078     x = 1 in AA;        // NOTE: a THIRD use of in. How to detect??
0079     assert (true);
0080         
0081     /// libsymbols
0082     string s = "";
0083     throw new Exception;
0084     TypeInfo ti = typeid(int);
0085     
0086     /// tests
0087     debug {}
0088     debug (2) {}
0089     debug (DSymb) {}
0090     unittest {}
0091     
0092     /// scope (as attribute and as statement)
0093     scope struct S;
0094     scope (exit) {}
0095     scope 
0096      (success) {}       // NOTE: rules cannot match across new-lines
0097     scope (failure) {}
0098     
0099     /// Properties
0100     x = int.min;
0101     s = (5-3).stringof;
0102     
0103     /// strings
0104     s = r"raw string";
0105     s = x"00FF";
0106     s = \n \a;
0107     s = \u1234;
0108     s = \U12345678;
0109     s = \& ;
0110     char c = 'a';
0111     s = "abc 012 \" \n \x12 \u1234 \U12345678";
0112     s = `BQString '"`;
0113     s = q{foo "bar" 123};
0114     s = q"FOO
0115 foo
0116 FOO";
0117     s = q"[foo [bar] q"[baz]"]";
0118     s = q"(foo (bar) q"(baz)")";
0119     s = q"<foo <bar> q"<baz>">";
0120     s = q"{foo {bar} q"{baz}"}";
0121     s = q"/foo/";
0122     s = q"!foo!";
0123     
0124     /// region markers
0125     //BEGIN x
0126     //END x
0127     
0128     /// DDoc
0129     /*******
0130     * DDoc
0131     *
0132     * Section:
0133     * New section.
0134     * $(I italic)
0135     *******/
0136     /+++++++
0137     + DDoc
0138     + /+
0139     + +/
0140     +++++++/
0141     
0142     // comments
0143     // FIXME NOTE
0144     /* comment */
0145     /+ comment /+ nested comment +/ +/
0146     
0147     /// brace folding
0148     {
0149     }
0150     
0151     /** normal text
0152     * ---
0153     * .x;
0154     * ..
0155     * ...
0156     * ....
0157     * .....
0158     * _._
0159     * _e1
0160     * ---
0161     */
0162     
0163     /// float and int literals
0164     int i;
0165     real r;
0166     ireal ir;
0167     r = .0;
0168     r = 0f;
0169     ir = 0e0i;
0170     ir = 0.fi;
0171     r = 0.0e0;
0172     r = 0xF.Fp0;
0173     r = 0x_._p0_;
0174     i = 5;
0175     i = -1;
0176     i = 0b10;
0177     i = 0070;
0178     i = 00;
0179     i = 0xF0;
0180     
0181     /// ranges
0182     int[] A;
0183     i = A[1];
0184     A = A[0..$];
0185     A = A[0..0];
0186     A = A[0..length];
0187     
0188     /// labels
0189     label:
0190     goto label;
0191     
0192     /// function, delegate
0193     creal function () fp = function creal() { return 0f+0fi; };
0194     void delegate (in int i, lazy int b) dg = delegate void (int, int) {}
0195     
0196     /// in, out, body
0197     // NOTE: highlighting in & out as statements here could be difficult
0198     float F ()
0199     in {}
0200     out (result) {}
0201     body {}
0202     
0203     /// try, catch, finally
0204     try {
0205         throw new Exception("oh no... ");
0206     } catch (Exception e) {
0207     } finally {
0208     }
0209     
0210     /// mixin
0211     mixin("return false;").stringof;
0212     
0213     /// templates
0214     macro; // what does this do?
0215     template Tp (T) {
0216         Tp t;
0217     }
0218     Tp!(int) y;
0219 }