import
[web.mtrack] / inc / hyperlight / csharp.php
1 <?php
2
3 class CsharpLanguage extends HyperLanguage {
4     public function __construct() {
5         $this->setInfo(array(
6             parent::NAME => 'C#',
7             parent::VERSION => '0.3',
8             parent::AUTHOR => array(
9                 parent::NAME => 'Konrad Rudolph',
10                 parent::WEBSITE => 'madrat.net',
11                 parent::EMAIL => 'konrad_rudolph@madrat.net'
12             )
13         ));
14
15         $this->setExtensions(array('cs'));
16
17         $this->setCaseInsensitive(false);
18
19         $this->addStates(array(
20             'init' => array(
21                 'string',
22                 'char',
23                 'number',
24                 'comment' => array('', 'doc'),
25                 'keyword' => array('', 'type', 'literal', 'operator', 'preprocessor'),
26                 'identifier',
27                 'operator',
28                 'whitespace',
29             ),
30             'comment doc' => 'doc',
31         ));
32
33         $this->addRules(array(
34             'whitespace' => Rule::ALL_WHITESPACE,
35             'operator' => '/[-+*\/%&|^!~=<>?{}()\[\].,:;]|&&|\|\||<<|>>|[-=!<>+*\/%&|^]=|<<=|>>=|->/',
36             'string' => Rule::C_DOUBLEQUOTESTRING,
37             'char' => Rule::C_SINGLEQUOTESTRING,
38             'number' => Rule::C_NUMBER,
39             'comment' => array(
40                 '#//(?:[^/].*?)?\n|/\*.*?\*/#s',
41                 'doc' => new Rule('#///#', '/$/m')
42             ),
43             'doc' => '/<(?:".*?"|\'.*?\'|[^>])*>/',
44             'keyword' => array(
45                 array(
46                     'abstract', 'break', 'case', 'catch', 'checked', 'class',
47                     'const', 'continue', 'default', 'delegate', 'do', 'else',
48                     'enum', 'event', 'explicit', 'extern', 'finally', 'fixed',
49                     'for', 'foreach', 'goto', 'if', 'implicit', 'in', 'interface',
50                     'internal', 'lock', 'namespace', 'operator', 'out', 'override',
51                     'params', 'private', 'protected', 'public', 'readonly', 'ref',
52                     'return', 'sealed', 'static', 'struct', 'switch', 'throw',
53                     'try', 'unchecked', 'unsafe', 'using', 'var', 'virtual',
54                     'volatile', 'while'
55                 ),
56                 'type' => array(
57                     'bool', 'byte', 'char', 'decimal', 'double', 'float', 'int',
58                     'long', 'object', 'sbyte', 'short', 'string', 'uint', 'ulong',
59                     'ushort', 'void'
60                 ),
61                 'literal' => array(
62                     'base', 'false', 'null', 'this', 'true',
63                 ),
64                 'operator' => array(
65                     'as', 'is', 'new', 'sizeof', 'stackallock', 'typeof',
66                 ),
67                 'preprocessor' => '/#(?:if|else|elif|endif|define|undef|warning|error|line|region|endregion)/'
68             ),
69             'identifier' => '/@?[a-z_][a-z0-9_]*/i',
70         ));
71
72         $this->addMappings(array(
73             'whitespace' => '',
74             'operator' => '',
75         ));
76     }
77 }
78
79 ?>