Free cookie consent management tool by TermsFeed Policy Generator

source: branches/crossvalidation-2434/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Highlighting/Resources/CSharp-Mode.xshd @ 12779

Last change on this file since 12779 was 11700, checked in by jkarder, 10 years ago

#2077: created branch and added first version

File size: 8.2 KB
Line 
1<?xml version="1.0"?>
2<SyntaxDefinition name="C#" extensions=".cs" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
3  <!-- The named colors 'Comment' and 'String' are used in SharpDevelop to detect if a line is inside a multiline string/comment -->
4  <Color name="Comment" foreground="Green" exampleText="// comment" />
5  <Color name="String" foreground="Blue" exampleText="string text = &quot;Hello, World!&quot;"/>
6  <Color name="Char" foreground="Magenta" exampleText="char linefeed = '\n';"/>
7  <Color name="Preprocessor" foreground="Green" exampleText="#region Title" />
8  <Color name="Punctuation" exampleText="a(b.c);" />
9  <Color name="ValueTypeKeywords" fontWeight="bold" foreground="Red" exampleText="bool b = true;" />
10  <Color name="ReferenceTypeKeywords" foreground="Red" exampleText="object o;" />
11  <Color name="MethodCall" foreground="MidnightBlue" fontWeight="bold" exampleText="o.ToString();"/>
12  <Color name="NumberLiteral" foreground="DarkBlue" exampleText="3.1415f"/>
13  <Color name="ThisOrBaseReference" fontWeight="bold" exampleText="this.Do(); base.Do();"/>
14  <Color name="NullOrValueKeywords" fontWeight="bold" exampleText="if (value == null)"/>
15  <Color name="Keywords" fontWeight="bold" foreground="Blue" exampleText="if (a) {} else {}"/>
16  <Color name="GotoKeywords" foreground="Navy" exampleText="continue; return null;"/>
17  <Color name="ContextKeywords" foreground="Navy" exampleText="var a = from x in y select z;"/>
18  <Color name="ExceptionKeywords" fontWeight="bold" foreground="Teal" exampleText="try {} catch {} finally {}"/>
19  <Color name="CheckedKeyword" fontWeight="bold" foreground="DarkGray" exampleText="checked {}"/>
20  <Color name="UnsafeKeywords" foreground="Olive" exampleText="unsafe { fixed (..) {} }"/>
21  <Color name="OperatorKeywords" fontWeight="bold" foreground="Pink" exampleText="public static implicit operator..."/>
22  <Color name="ParameterModifiers" fontWeight="bold" foreground="DeepPink" exampleText="(ref int a, params int[] b)"/>
23  <Color name="Modifiers" foreground="Brown" exampleText="static readonly int a;"/>
24  <Color name="Visibility" fontWeight="bold" foreground="Blue" exampleText="public override void ToString();"/>
25  <Color name="NamespaceKeywords" fontWeight="bold" foreground="Green" exampleText="namespace A.B { using System; }"/>
26  <Color name="GetSetAddRemove" foreground="SaddleBrown" exampleText="int Prop { get; set; }"/>
27  <Color name="TrueFalse" fontWeight="bold" foreground="DarkCyan" exampleText="b = false; a = true;" />
28  <Color name="TypeKeywords" fontWeight="bold" foreground="DarkCyan" exampleText="if (x is int) { a = x as int; type = typeof(int); size = sizeof(int); c = new object(); }"/>
29 
30  <Property name="DocCommentMarker" value="///" />
31 
32  <RuleSet name="CommentMarkerSet">
33    <Keywords fontWeight="bold" foreground="Red">
34      <Word>TODO</Word>
35      <Word>FIXME</Word>
36    </Keywords>
37    <Keywords fontWeight="bold" foreground="#E0E000">
38      <Word>HACK</Word>
39      <Word>UNDONE</Word>
40    </Keywords>
41  </RuleSet>
42 
43  <!-- This is the main ruleset. -->
44  <RuleSet>
45    <Span color="Preprocessor">
46      <Begin>\#</Begin>
47      <RuleSet name="PreprocessorSet">
48        <Span> <!-- preprocessor directives that allows comments -->
49          <Begin fontWeight="bold">
50            (define|undef|if|elif|else|endif|line)\b
51          </Begin>
52          <RuleSet>
53            <Span color="Comment" ruleSet="CommentMarkerSet">
54              <Begin>//</Begin>
55            </Span>
56          </RuleSet>
57        </Span>
58        <Span> <!-- preprocessor directives that don't allow comments -->
59          <Begin fontWeight="bold">
60            (region|endregion|error|warning|pragma)\b
61          </Begin>
62        </Span>
63      </RuleSet>
64    </Span>
65   
66    <Span color="Comment">
67      <Begin color="XmlDoc/DocComment">///(?!/)</Begin>
68      <RuleSet>
69        <Import ruleSet="XmlDoc/DocCommentSet"/>
70        <Import ruleSet="CommentMarkerSet"/>
71      </RuleSet>
72    </Span>
73   
74    <Span color="Comment" ruleSet="CommentMarkerSet">
75      <Begin>//</Begin>
76    </Span>
77   
78    <Span color="Comment" ruleSet="CommentMarkerSet" multiline="true">
79      <Begin>/\*</Begin>
80      <End>\*/</End>
81    </Span>
82   
83    <Span color="String">
84      <Begin>"</Begin>
85      <End>"</End>
86      <RuleSet>
87        <!-- span for escape sequences -->
88        <Span begin="\\" end="."/>
89      </RuleSet>
90    </Span>
91   
92    <Span color="Char">
93      <Begin>'</Begin>
94      <End>'</End>
95      <RuleSet>
96        <!-- span for escape sequences -->
97        <Span begin="\\" end="."/>
98      </RuleSet>
99    </Span>
100   
101    <Span color="String" multiline="true">
102      <Begin>@"</Begin>
103      <End>"</End>
104      <RuleSet>
105        <!-- span for escape sequences -->
106        <Span begin='""' end=""/>
107      </RuleSet>
108    </Span>
109   
110    <!-- don't highlight "@int" as keyword -->
111    <Rule>
112      @[\w\d_]+
113    </Rule>
114   
115    <Keywords color="ThisOrBaseReference">
116      <Word>this</Word>
117      <Word>base</Word>
118    </Keywords>
119   
120    <Keywords color="TypeKeywords">
121      <Word>as</Word>
122      <Word>is</Word>
123      <Word>new</Word>
124      <Word>sizeof</Word>
125      <Word>typeof</Word>
126      <Word>stackalloc</Word>
127    </Keywords>
128   
129    <Keywords color="TrueFalse">
130      <Word>true</Word>
131      <Word>false</Word>
132    </Keywords>
133   
134    <Keywords color="Keywords">
135      <Word>else</Word>
136      <Word>if</Word>
137      <Word>switch</Word>
138      <Word>case</Word>
139      <Word>default</Word>
140      <Word>do</Word>
141      <Word>for</Word>
142      <Word>foreach</Word>
143      <Word>in</Word>
144      <Word>while</Word>
145      <Word>lock</Word>
146    </Keywords>
147   
148    <Keywords color="GotoKeywords">
149      <Word>break</Word>
150      <Word>continue</Word>
151      <Word>goto</Word>
152      <Word>return</Word>
153    </Keywords>
154   
155    <Keywords color="ContextKeywords">
156      <Word>yield</Word>
157      <Word>partial</Word>
158      <Word>global</Word>
159      <Word>where</Word>
160      <Word>select</Word>
161      <Word>group</Word>
162      <Word>by</Word>
163      <Word>into</Word>
164      <Word>from</Word>
165      <Word>ascending</Word>
166      <Word>descending</Word>
167      <Word>orderby</Word>
168      <Word>let</Word>
169      <Word>join</Word>
170      <Word>on</Word>
171      <Word>equals</Word>
172      <Word>var</Word>
173      <Word>dynamic</Word>
174      <Word>await</Word>
175    </Keywords>
176   
177    <Keywords color="ExceptionKeywords">
178      <Word>try</Word>
179      <Word>throw</Word>
180      <Word>catch</Word>
181      <Word>finally</Word>
182    </Keywords>
183   
184    <Keywords color="CheckedKeyword">
185      <Word>checked</Word>
186      <Word>unchecked</Word>
187    </Keywords>
188   
189    <Keywords color="UnsafeKeywords">
190      <Word>fixed</Word>
191      <Word>unsafe</Word>
192    </Keywords>
193   
194    <Keywords color="ValueTypeKeywords">
195      <Word>bool</Word>
196      <Word>byte</Word>
197      <Word>char</Word>
198      <Word>decimal</Word>
199      <Word>double</Word>
200      <Word>enum</Word>
201      <Word>float</Word>
202      <Word>int</Word>
203      <Word>long</Word>
204      <Word>sbyte</Word>
205      <Word>short</Word>
206      <Word>struct</Word>
207      <Word>uint</Word>
208      <Word>ushort</Word>
209      <Word>ulong</Word>
210    </Keywords>
211   
212    <Keywords color="ReferenceTypeKeywords">
213      <Word>class</Word>
214      <Word>interface</Word>
215      <Word>delegate</Word>
216      <Word>object</Word>
217      <Word>string</Word>
218      <Word>void</Word>
219    </Keywords>
220   
221    <Keywords color="OperatorKeywords">
222      <Word>explicit</Word>
223      <Word>implicit</Word>
224      <Word>operator</Word>
225    </Keywords>
226   
227    <Keywords color="ParameterModifiers">
228      <Word>params</Word>
229      <Word>ref</Word>
230      <Word>out</Word>
231    </Keywords>
232   
233    <Keywords color="Modifiers">
234      <Word>abstract</Word>
235      <Word>const</Word>
236      <Word>event</Word>
237      <Word>extern</Word>
238      <Word>override</Word>
239      <Word>readonly</Word>
240      <Word>sealed</Word>
241      <Word>static</Word>
242      <Word>virtual</Word>
243      <Word>volatile</Word>
244      <Word>async</Word>
245    </Keywords>
246   
247    <Keywords color="Visibility">
248      <Word>public</Word>
249      <Word>protected</Word>
250      <Word>private</Word>
251      <Word>internal</Word>
252    </Keywords>
253   
254    <Keywords color="NamespaceKeywords">
255      <Word>namespace</Word>
256      <Word>using</Word>
257    </Keywords>
258   
259    <Keywords color="GetSetAddRemove">
260      <Word>get</Word>
261      <Word>set</Word>
262      <Word>add</Word>
263      <Word>remove</Word>
264    </Keywords>
265   
266    <Keywords color="NullOrValueKeywords">
267      <Word>null</Word>
268      <Word>value</Word>
269    </Keywords>
270   
271    <!-- Mark previous rule-->
272    <Rule color="MethodCall">
273    \b
274    [\d\w_]+  # an identifier
275    (?=\s*\() # followed by (
276    </Rule>
277   
278    <!-- Digits -->
279    <Rule color="NumberLiteral">
280      \b0[xX][0-9a-fA-F]+  # hex number
281    |
282      ( \b\d+(\.[0-9]+)?   #number with optional floating point
283      | \.[0-9]+           #or just starting with floating point
284      )
285      ([eE][+-]?[0-9]+)? # optional exponent
286    </Rule>
287   
288    <Rule color="Punctuation">
289      [?,.;()\[\]{}+\-/%*&lt;&gt;^+~!|&amp;]+
290    </Rule>
291  </RuleSet>
292</SyntaxDefinition>
Note: See TracBrowser for help on using the repository browser.