1 | <?php |
---|
2 | /************************************************************************************* |
---|
3 | * csharp.php |
---|
4 | * ---------- |
---|
5 | * Author: Alan Juden (alan@judenware.org) |
---|
6 | * Revised by: Michael Mol (mikemol@gmail.com) |
---|
7 | * Copyright: (c) 2004 Alan Juden, Nigel McNie (http://qbnz.com/highlighter/) |
---|
8 | * Release Version: 1.0.9.0 |
---|
9 | * Date Started: 2004/06/04 |
---|
10 | * |
---|
11 | * C# language file for GeSHi. |
---|
12 | * |
---|
13 | * CHANGES |
---|
14 | * ------- |
---|
15 | * 2015/04/14 |
---|
16 | * - Added C# 5.0 and 6.0 missing keywords and #pragma directive |
---|
17 | * 2012/06/18 (1.0.8.11) |
---|
18 | * - Added missing keywords (Christian Stelzmann) |
---|
19 | * 2009/04/03 (1.0.8.6) |
---|
20 | * - Added missing keywords identified by Rosetta Code users. |
---|
21 | * 2008/05/25 (1.0.7.22) |
---|
22 | * - Added highlighting of using and namespace directives as non-OOP |
---|
23 | * 2005/01/05 (1.0.1) |
---|
24 | * - Used hardquote support for @"..." strings (Cliff Stanford) |
---|
25 | * 2004/11/27 (1.0.0) |
---|
26 | * - Initial release |
---|
27 | * |
---|
28 | * TODO (updated 2004/11/27) |
---|
29 | * ------------------------- |
---|
30 | * |
---|
31 | ************************************************************************************* |
---|
32 | * |
---|
33 | * This file is part of GeSHi. |
---|
34 | * |
---|
35 | * GeSHi is free software; you can redistribute it and/or modify |
---|
36 | * it under the terms of the GNU General Public License as published by |
---|
37 | * the Free Software Foundation; either version 2 of the License, or |
---|
38 | * (at your option) any later version. |
---|
39 | * |
---|
40 | * GeSHi is distributed in the hope that it will be useful, |
---|
41 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
42 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
43 | * GNU General Public License for more details. |
---|
44 | * |
---|
45 | * You should have received a copy of the GNU General Public License |
---|
46 | * along with GeSHi; if not, write to the Free Software |
---|
47 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
48 | * |
---|
49 | ************************************************************************************/ |
---|
50 | |
---|
51 | $language_data = array ( |
---|
52 | 'LANG_NAME' => 'C#', |
---|
53 | 'COMMENT_SINGLE' => array(1 => '//', 2 => '#'), |
---|
54 | 'COMMENT_MULTI' => array('/*' => '*/'), |
---|
55 | 'COMMENT_REGEXP' => array( |
---|
56 | //Using and Namespace directives (basic support) |
---|
57 | //Please note that the alias syntax for using is not supported |
---|
58 | 3 => '/(?:(?<=using[\\n\\s])|(?<=namespace[\\n\\s]))[\\n\\s]*([a-zA-Z0-9_]+\\.)*[a-zA-Z0-9_]+[\n\s]*(?=[;=])/i'), |
---|
59 | 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, |
---|
60 | 'QUOTEMARKS' => array("'", '"'), |
---|
61 | 'HARDQUOTE' => array('@"', '"'), |
---|
62 | 'HARDESCAPE' => array('"'), |
---|
63 | 'HARDCHAR' => '"', |
---|
64 | 'ESCAPE_CHAR' => '\\', |
---|
65 | 'KEYWORDS' => array( |
---|
66 | 1 => array( |
---|
67 | 'abstract', 'add', 'as', 'async', 'await', 'base', |
---|
68 | 'break', 'by', 'case', 'catch', 'const', 'continue', |
---|
69 | 'default', 'do', 'else', 'event', 'explicit', 'extern', 'false', |
---|
70 | 'finally', 'fixed', 'for', 'foreach', 'from', 'get', 'goto', 'group', 'if', |
---|
71 | 'implicit', 'in', 'into', 'internal', 'join', 'lock', 'namespace', 'null', |
---|
72 | 'operator', 'out', 'override', 'params', 'partial', 'private', |
---|
73 | 'protected', 'public', 'readonly', 'remove', 'ref', 'return', 'sealed', |
---|
74 | 'select', 'set', 'stackalloc', 'static', 'switch', 'this', 'throw', 'true', |
---|
75 | 'try', 'unsafe', 'using', 'var', 'value', 'virtual', 'volatile', 'where', |
---|
76 | 'while', 'yield' |
---|
77 | ), |
---|
78 | 2 => array( |
---|
79 | '#elif', '#endif', '#endregion', '#else', '#error', '#define', '#if', |
---|
80 | '#line', '#pragma', '#region', '#undef', '#warning' |
---|
81 | ), |
---|
82 | 3 => array( |
---|
83 | 'checked', 'is', 'new', 'nameof', 'sizeof', 'typeof', 'unchecked' |
---|
84 | ), |
---|
85 | 4 => array( |
---|
86 | 'bool', 'byte', 'char', 'class', 'decimal', 'delegate', 'double', |
---|
87 | 'dynamic', 'enum', 'float', 'int', 'interface', 'long', 'object', 'sbyte', |
---|
88 | 'short', 'string', 'struct', 'uint', 'ulong', 'ushort', 'void' |
---|
89 | ), |
---|
90 | 5 => array( |
---|
91 | 'Microsoft.Win32', |
---|
92 | 'System', |
---|
93 | 'System.CodeDOM', |
---|
94 | 'System.CodeDOM.Compiler', |
---|
95 | 'System.Collections', |
---|
96 | 'System.Collections.Bases', |
---|
97 | 'System.ComponentModel', |
---|
98 | 'System.ComponentModel.Design', |
---|
99 | 'System.ComponentModel.Design.CodeModel', |
---|
100 | 'System.Configuration', |
---|
101 | 'System.Configuration.Assemblies', |
---|
102 | 'System.Configuration.Core', |
---|
103 | 'System.Configuration.Install', |
---|
104 | 'System.Configuration.Interceptors', |
---|
105 | 'System.Configuration.Schema', |
---|
106 | 'System.Configuration.Web', |
---|
107 | 'System.Core', |
---|
108 | 'System.Data', |
---|
109 | 'System.Data.ADO', |
---|
110 | 'System.Data.Design', |
---|
111 | 'System.Data.Internal', |
---|
112 | 'System.Data.SQL', |
---|
113 | 'System.Data.SQLTypes', |
---|
114 | 'System.Data.XML', |
---|
115 | 'System.Data.XML.DOM', |
---|
116 | 'System.Data.XML.XPath', |
---|
117 | 'System.Data.XML.XSLT', |
---|
118 | 'System.Diagnostics', |
---|
119 | 'System.Diagnostics.SymbolStore', |
---|
120 | 'System.DirectoryServices', |
---|
121 | 'System.Drawing', |
---|
122 | 'System.Drawing.Design', |
---|
123 | 'System.Drawing.Drawing2D', |
---|
124 | 'System.Drawing.Imaging', |
---|
125 | 'System.Drawing.Printing', |
---|
126 | 'System.Drawing.Text', |
---|
127 | 'System.Globalization', |
---|
128 | 'System.IO', |
---|
129 | 'System.IO.IsolatedStorage', |
---|
130 | 'System.Messaging', |
---|
131 | 'System.Net', |
---|
132 | 'System.Net.Sockets', |
---|
133 | 'System.NewXml', |
---|
134 | 'System.NewXml.XPath', |
---|
135 | 'System.NewXml.Xsl', |
---|
136 | 'System.Reflection', |
---|
137 | 'System.Reflection.Emit', |
---|
138 | 'System.Resources', |
---|
139 | 'System.Runtime.InteropServices', |
---|
140 | 'System.Runtime.InteropServices.Expando', |
---|
141 | 'System.Runtime.Remoting', |
---|
142 | 'System.Runtime.Serialization', |
---|
143 | 'System.Runtime.Serialization.Formatters', |
---|
144 | 'System.Runtime.Serialization.Formatters.Binary', |
---|
145 | 'System.Security', |
---|
146 | 'System.Security.Cryptography', |
---|
147 | 'System.Security.Cryptography.X509Certificates', |
---|
148 | 'System.Security.Permissions', |
---|
149 | 'System.Security.Policy', |
---|
150 | 'System.Security.Principal', |
---|
151 | 'System.ServiceProcess', |
---|
152 | 'System.Text', |
---|
153 | 'System.Text.RegularExpressions', |
---|
154 | 'System.Threading', |
---|
155 | 'System.Timers', |
---|
156 | 'System.Web', |
---|
157 | 'System.Web.Caching', |
---|
158 | 'System.Web.Configuration', |
---|
159 | 'System.Web.Security', |
---|
160 | 'System.Web.Services', |
---|
161 | 'System.Web.Services.Description', |
---|
162 | 'System.Web.Services.Discovery', |
---|
163 | 'System.Web.Services.Protocols', |
---|
164 | 'System.Web.UI', |
---|
165 | 'System.Web.UI.Design', |
---|
166 | 'System.Web.UI.Design.WebControls', |
---|
167 | 'System.Web.UI.Design.WebControls.ListControls', |
---|
168 | 'System.Web.UI.HtmlControls', |
---|
169 | 'System.Web.UI.WebControls', |
---|
170 | 'System.WinForms', |
---|
171 | 'System.WinForms.ComponentModel', |
---|
172 | 'System.WinForms.Design', |
---|
173 | 'System.Xml', |
---|
174 | 'System.Xml.Serialization', |
---|
175 | 'System.Xml.Serialization.Code', |
---|
176 | 'System.Xml.Serialization.Schema' |
---|
177 | ), |
---|
178 | ), |
---|
179 | 'SYMBOLS' => array( |
---|
180 | '+', '-', '*', '?', '=', '/', '%', '&', '>', '<', '^', '!', ':', ';', |
---|
181 | '(', ')', '{', '}', '[', ']', '|', '.' |
---|
182 | ), |
---|
183 | 'CASE_SENSITIVE' => array( |
---|
184 | GESHI_COMMENTS => false, |
---|
185 | 1 => false, |
---|
186 | 2 => false, |
---|
187 | 3 => false, |
---|
188 | 4 => false, |
---|
189 | 5 => false, |
---|
190 | ), |
---|
191 | 'STYLES' => array( |
---|
192 | 'KEYWORDS' => array( |
---|
193 | 1 => 'color: #0600FF; font-weight: bold;', |
---|
194 | 2 => 'color: #FF8000; font-weight: bold;', |
---|
195 | 3 => 'color: #008000;', |
---|
196 | 4 => 'color: #6666cc; font-weight: bold;', |
---|
197 | 5 => 'color: #000000;' |
---|
198 | ), |
---|
199 | 'COMMENTS' => array( |
---|
200 | 1 => 'color: #008080; font-style: italic;', |
---|
201 | 2 => 'color: #008080;', |
---|
202 | 3 => 'color: #008080;', |
---|
203 | 'MULTI' => 'color: #008080; font-style: italic;' |
---|
204 | ), |
---|
205 | 'ESCAPE_CHAR' => array( |
---|
206 | 0 => 'color: #008080; font-weight: bold;', |
---|
207 | 'HARD' => 'color: #008080; font-weight: bold;' |
---|
208 | ), |
---|
209 | 'BRACKETS' => array( |
---|
210 | 0 => 'color: #008000;' |
---|
211 | ), |
---|
212 | 'STRINGS' => array( |
---|
213 | 0 => 'color: #666666;', |
---|
214 | 'HARD' => 'color: #666666;' |
---|
215 | ), |
---|
216 | 'NUMBERS' => array( |
---|
217 | 0 => 'color: #FF0000;' |
---|
218 | ), |
---|
219 | 'METHODS' => array( |
---|
220 | 1 => 'color: #0000FF;', |
---|
221 | 2 => 'color: #0000FF;' |
---|
222 | ), |
---|
223 | 'SYMBOLS' => array( |
---|
224 | 0 => 'color: #008000;' |
---|
225 | ), |
---|
226 | 'REGEXPS' => array( |
---|
227 | ), |
---|
228 | 'SCRIPT' => array( |
---|
229 | ) |
---|
230 | ), |
---|
231 | 'URLS' => array( |
---|
232 | 1 => '', |
---|
233 | 2 => '', |
---|
234 | 3 => 'http://www.google.com/search?q={FNAMEL}+msdn.microsoft.com', |
---|
235 | 4 => '', |
---|
236 | 5 => '' |
---|
237 | ), |
---|
238 | 'OOLANG' => true, |
---|
239 | 'OBJECT_SPLITTERS' => array( |
---|
240 | 1 => '.', |
---|
241 | 2 => '::' |
---|
242 | ), |
---|
243 | 'REGEXPS' => array( |
---|
244 | ), |
---|
245 | 'STRICT_MODE_APPLIES' => GESHI_NEVER, |
---|
246 | 'SCRIPT_DELIMITERS' => array( |
---|
247 | ), |
---|
248 | 'HIGHLIGHT_STRICT_BLOCK' => array( |
---|
249 | ), |
---|
250 | 'TAB_WIDTH' => 4, |
---|
251 | 'PARSER_CONTROL' => array( |
---|
252 | 'KEYWORDS' => array( |
---|
253 | 'DISALLOWED_BEFORE' => "(?<![a-zA-Z0-9\$_\|\#>|^])", |
---|
254 | 'DISALLOWED_AFTER' => "(?![a-zA-Z0-9_%\\-])" |
---|
255 | ) |
---|
256 | ) |
---|
257 | ); |
---|