4 // - Add escaped string characters
5 // - Add 'TO DO', 'FIX ME', … tags
6 // - (Add doc comments?)
8 class CppLanguage extends HyperLanguage {
9 public function __construct() {
11 parent::NAME => 'C++',
12 parent::VERSION => '0.4',
13 parent::AUTHOR => array(
14 parent::NAME => 'Konrad Rudolph',
15 parent::WEBSITE => 'madrat.net',
16 parent::EMAIL => 'konrad_rudolph@madrat.net'
20 $this->setExtensions(array('c', 'cc', 'cpp', 'h', 'hpp', 'icl', 'ipp'));
22 $keyword = array('keyword' => array('', 'type', 'literal', 'operator'));
24 'string', 'char', 'number', 'comment',
25 'keyword' => array('', 'type', 'literal', 'operator'),
30 $this->addStates(array(
31 'init' => array_merge(array('include', 'preprocessor'), $common),
32 'include' => array('incpath'),
33 'preprocessor' => array_merge($common, array('pp_newline')),
36 $this->addRules(array(
37 'whitespace' => RULE::ALL_WHITESPACE,
38 'operator' => '/<:|:>|<%|%>|%:|%:%:|\+\+|--|&&|\|\||::|<<|>>|##|\.\.\.|\.\*|->|->*|[-+*\/%^&|!~<>.=,;:?()\[\]\{\}]|[-+*\/%^&|=!~<>]=|<<=|>>=/',
39 'include' => new Rule('/#\s*include/', '/\n/'),
40 'preprocessor' => new Rule('/#\s*\w+/', '/\n/'),
41 //'pp_newline' => '/[^\\\\](?<bs>\\\\*?)(?P=bs)\\\\\n/',
42 'pp_newline' => '/(?<!\\\\)(?:\\\\\\\\)*?\\\\\n/',
43 'incpath' => '/<[^>]*>|"[^"]*"/',
44 'string' => Rule::C_DOUBLEQUOTESTRING,
45 'char' => Rule::C_SINGLEQUOTESTRING,
46 'number' => Rule::C_NUMBER,
47 'comment' => Rule::C_COMMENT,
50 'asm', 'auto', 'break', 'case', 'catch',
51 'const_cast', 'continue', 'default', 'do', 'dynamic_cast',
52 'else', 'explicit', 'export', 'extern', 'for',
53 'friend', 'goto', 'if', 'mutable', 'namespace',
54 'operator', 'private', 'protected', 'public', 'register',
55 'reinterpret_cast', 'return', 'sizeof',
56 'static_cast', 'switch', 'template', 'throw',
57 'try', 'typedef', 'typename', 'using', 'virtual',
61 'bool', 'char', 'double', 'float', 'int', 'long', 'short',
62 'signed', 'unsigned', 'void', 'wchar_t', 'struct', 'union',
63 'class', 'static', 'inline', 'enum', 'const',
64 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t',
65 'int8_t', 'int16_t', 'int32_t', 'int64_t', 'FILE', 'DIR',
68 'false', 'this', 'true', 'NULL',
71 'and', 'and_eq', 'bitand', 'bitor', 'compl', 'delete',
72 'new', 'not', 'not_eq', 'or', 'or_eq', 'typeid', 'xor',
76 'identifier' => Rule::C_IDENTIFIER,
79 $this->addMappings(array(
81 'include' => 'preprocessor',