Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Highlights most languages reasonably: Java, C#, JavaScript, AS3, C, C++, Lua
- class GenericLanguage extends HyperLanguage {
- public function __construct() {
- $this->setInfo(array(
- parent::NAME => 'Generic',
- parent::VERSION => '0.1',
- parent::AUTHOR => array(
- parent::NAME => 'Nathan Sweet', // based Konrad Rudolph's csharp.php!
- parent::WEBSITE => 'esotericsoftware.com',
- parent::EMAIL => 'misc@n4te.com'
- )
- ));
- $this->setExtensions(array('java'));
- $this->setCaseInsensitive(false);
- $this->addStates(array(
- 'init' => array(
- 'string',
- 'char',
- 'number',
- 'comment',
- 'keyword' => array('', 'preprocessor'),
- 'method',
- 'ctor',
- 'function',
- 'operator',
- 'type',
- 'identifier',
- 'whitespace',
- ),
- ));
- $this->addRules(array(
- 'whitespace' => Rule::ALL_WHITESPACE,
- 'operator' => '/[-+*\/%&|^!~=<>?{}()\[\].,:;]|&&|\|\||<<|>>|[-=!<>+*\/%&|^]=|<<=|>>=|->/',
- 'string' => Rule::C_DOUBLEQUOTESTRING,
- 'char' => Rule::C_SINGLEQUOTESTRING,
- 'number' => Rule::C_NUMBER,
- 'comment' => '#(//|--)(?:[^/].*?)?\n|/\*.*?\*/#s',
- 'keyword' => array(
- array(
- // C#
- 'abstract', 'break', 'case', 'catch', 'checked', 'class',
- 'const', 'continue', 'default', 'delegate', 'do', 'else',
- 'enum', 'explicit', 'extern', 'finally', 'fixed',
- 'for', 'foreach', 'goto', 'if', 'implicit', 'in', 'interface',
- 'internal', 'lock', 'namespace', 'operator', 'out', 'override',
- 'params', 'private', 'protected', 'public', 'readonly', 'ref',
- 'return', 'sealed', 'static', 'struct', 'switch', 'throw',
- 'try', 'unchecked', 'unsafe', 'using', 'var', 'virtual',
- 'volatile', 'while',
- 'bool', 'byte', 'char', 'decimal', 'double', 'float', 'int',
- 'long', 'object', 'sbyte', 'short', 'string', 'uint', 'ulong',
- 'ushort', 'void',
- 'base', 'false', 'null', 'this', 'true',
- 'as', 'is', 'new', 'sizeof', 'stackallock', 'typeof',
- // Java
- 'extends', 'throws', 'implements',
- 'final', 'native', 'synchronized',
- 'transient', 'assert',
- 'package', 'strictfp', 'super',
- 'import', 'boolean', 'instanceof',
- // JavaScript
- 'function',
- // Lua
- 'local', 'not', 'then', 'end', 'nil', 'pairs', 'ipairs',
- ),
- 'preprocessor' => '/#(?:if|else|elif|endif|define|undef|warning|error|line|region|endregion|include|import)[^\r\n]*/',
- ),
- 'method' => '/(?<=\.)\s*([a-zA-Z][^\s\.\(:]+)(?=\s*\()/',
- 'ctor' => '/(?<=new)\s+([a-zA-Z][^\s\(:]+)(?=\s*\()/',
- 'function' => '/([a-zA-Z][^\s\.\(:]+)(?=\s*\()/',
- 'type' => '/@?(sp)?[A-Z][a-z0-9_]*/',
- 'identifier' => '/@?[a-z_][a-z0-9_]*/i',
- ));
- $this->addMappings(array(
- 'whitespace' => '',
- ));
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement