import
[web.mtrack] / inc / hyperlight / vb.php
1 <?php
2
3 class VbLanguage extends HyperLanguage {
4     public function __construct() {
5         $this->setInfo(array(
6             parent::NAME => 'VB',
7             parent::VERSION => '1.4',
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('vb'));
16
17         $this->setCaseInsensitive(true);
18
19         $this->addStates(array(
20             'init' => array(
21                 'string',
22                 'number',
23                 'comment' => array('', 'doc'),
24                 'keyword' => array('', 'type', 'literal', 'operator', 'preprocessor'),
25                 'date',
26                 'identifier',
27                 'operator',
28                 'whitespace',
29             ),
30             'string' => 'escaped',
31             'comment doc' => 'doc',
32         ));
33
34         $this->addRules(array(
35             'whitespace' => Rule::ALL_WHITESPACE,
36             'operator' => '/[-+*\/\\\\^&.=,()<>{}]/',
37             'string' => new Rule('/"/', '/"c?/i'),
38             'number' => '/(?: # Integer followed by optional fractional part.
39                 (?:&(?:H[0-9a-f]+|O[0-7]+)|\d+)
40                 (?:\.\d*)?
41                 (?:e[+-]\d+)?
42                 U?[SILDFR%@!#&]?
43             )
44             |
45             (?: # Just the fractional part.
46                 (?:\.\d+)
47                 (?:e[+-]\d+)?
48                 [FR!#]?
49             )
50             /ix',
51             'escaped' => '/""/',
52             'keyword' => array(
53                 array(
54                     'addhandler', 'addressof', 'alias', 'as', 'byref', 'byval',
55                     'call', 'case', 'catch', 'cbool', 'cbyte', 'cchar',
56                     'cdate', 'cdec', 'cdbl', 'cint', 'class', 'clng', 'cobj',
57                     'const', 'continue', 'csbyte', 'cshort', 'csng', 'cstr',
58                     'ctype', 'cuint', 'culng', 'cushort', 'declare', 'default',
59                     'delegate', 'dim', 'directcast', 'do', 'each', 'else',
60                     'elseif', 'end', 'endif', 'enum', 'erase', 'error',
61                     'event', 'exit', 'finally', 'for', 'friend', 'function',
62                     'get', 'gettype', 'getxmlnamespace', 'global', 'gosub',
63                     'goto', 'handles', 'if', 'implements', 'imports', 'in',
64                     'inherits', 'interface', 'let', 'lib', 'loop', 'module',
65                     'mustinherit', 'mustoverride', 'namespace', 'narrowing',
66                     'next', 'notinheritable', 'notoverridable', 'of', 'on',
67                     'operator', 'option', 'optional', 'overloads',
68                     'overridable', 'overrides', 'paramarray', 'partial',
69                     'private', 'property', 'protected', 'public', 'raiseevent',
70                     'readonly', 'redim', 'removehandler', 'resume', 'return',
71                     'select', 'set', 'shadows', 'shared', 'static', 'step',
72                     'stop', 'structure', 'sub', 'synclock', 'then', 'throw',
73                     'to', 'try', 'trycast', 'wend', 'using', 'when', 'while',
74                     'widening', 'with', 'withevents', 'writeonly'
75                 ),
76                 'type' => array(
77                     'boolean', 'byte', 'char', 'date', 'decimal', 'double',
78                     'long', 'integer', 'object', 'sbyte', 'short', 'single',
79                     'string', 'variant', 'uinteger', 'ulong', 'ushort'
80                 ),
81                 'literal' => array(
82                     'false', 'me', 'mybase', 'myclass', 'nothing', 'true'
83                 ),
84                 'operator' => array(
85                     'and', 'andalso', 'is', 'isnot', 'like', 'mod', 'new',
86                     'not', 'or', 'orelse', 'typeof', 'xor'
87                 ),
88                 'preprocessor' => '/#(?:const|else|elseif|end if|end region|if|region)/i'
89             ),
90             'comment' => array(
91                 "/(?:'{1,2}[^']|rem\s).*/i",
92                 'doc' => new Rule("/'''/", '/$/m')
93             ),
94             'date' => '/#.+?#/',
95             'identifier' => '/[a-z_][a-z_0-9]*|\[.+?\]/i',
96             'doc' => '/<(?:".*?"|\'.*?\'|[^>])*>/',
97         ));
98
99         $this->addMappings(array(
100             'whitespace' => '',
101             'operator' => '',
102             'date' => 'tag',
103         ));
104     }
105 }
106
107 ?>