Esempio n. 1
0
 public function setupRules()
 {
     parent::setupRules();
     $this->rules->remove('symbol.type', 0);
     // symbol.type[0] stands for universal type matching in arguments
     $this->rules->rule('keyword')->setMatcher(new WordMatcher(['auto', 'align(?:as|of)', 'and(?:_eq)?', 'asm', 'auto', 'bit(and|or)', 'break', 'case', 'catch', 'class', 'compl', 'concept', 'const(?:_cast|expr)?', 'continue', 'decltype', 'default', 'delete', 'do', 'double', 'dynamic_cast', 'else', 'enum', 'explicit', 'export', 'extern', 'for', 'friend', 'goto', 'if', 'inline', 'mutable', 'namespace', 'new', 'noexcept', 'not(?:_eq|ptr)', 'operator', 'or(?:_eq)?', 'private', 'protected', 'public', 'register', 'reinterpret_cast', 'requires', 'return', 'sizeof', 'static(?:_assert|_cast)?', 'struct', 'switch', 'template', 'thread_local', 'throw', 'try', 'typedef', 'typeid', 'typename', 'union', 'using', 'virtual', 'volatile', 'while', 'xor(?:_eq)?'], ['escape' => false]));
     $this->rules->add('symbol.type', new Rule(new WordMatcher(['bool', 'wchar'])));
     $this->rules->add('constant.special', new Rule(new WordMatcher(['false', 'null', 'true'])));
     $this->rules->add('symbol.class', new Rule(new RegexMatcher('/(\\w+)(?:\\s+|\\s*[*&]\\s*)\\w+\\s*[={}();,]/')));
     $this->rules->add('symbol.class.template', new Rule(new RegexMatcher('/(\\w+)\\s*<.*?>/')));
     $this->rules->add('symbol.namespace', new Rule(new RegexMatcher('/((?::)?(\\w+::)+)(\\w+)/', [1 => Token::NAME, 2 => 'symbol.class'])));
 }
Esempio n. 2
0
 public function setupRules()
 {
     parent::setupRules();
     $this->rules->rule('preprocessor')->setMatcher(new RegexMatcher('/^\\s*(#)/m'));
     $this->rules->rule('call.preprocessor')->setMatcher(new RegexMatcher('/^\\s*#(\\w+)/m'));
     $this->rules->remove('operator');
     // & and *
     $this->rules->remove('symbol.type', 0);
     // symbol.type[0] stands for universal type matching in arguments
     $this->rules->rule('keyword')->setMatcher(new WordMatcher(['abstract', 'as', 'base', 'break', 'case', 'catch', 'char', 'checked', 'class', 'const', 'continue', 'default', 'delegate', 'do', 'else', 'enum', 'event', 'explicit', 'extern', 'finally', 'fixed', 'for', 'foreach', 'goto', 'if', 'implicit', 'in', 'interface', 'internal', 'is', 'lock', 'namespace', 'new', 'object', 'operator', 'out', 'override', 'partial', 'params', 'private', 'protected', 'public', 'readonly', 'ref', 'return', 'sealed', 'short', 'sizeof', 'stackalloc', 'static', 'string', 'struct', 'switch', 'throw', 'try', 'typeof', 'unchecked', 'unsafe', 'using', 'virtual', 'volatile', 'var', 'while', 'yield', '__makeref', '__reftype', '__refvalue', '__arglist', 'get', 'set']));
     $this->rules->addMany(['symbol.class' => new Rule(new RegexMatcher('/(\\w+)(?:\\s+)\\w+\\s*[={}();,]/')), 'symbol.class.template' => new Rule(new RegexMatcher('/(\\w+)\\s*<.*?>/')), 'variable.special' => new Rule(new RegexMatcher('/\\b(this)\\b/')), 'constant.special' => new Rule(new WordMatcher(['true', 'false', 'null'])), 'operator' => new Rule(new RegexMatcher('/([!+-\\/*&|^<>=]{1,2}=?)/')), 'operator.scope' => new Rule(new RegexMatcher('/\\w(\\??\\.)\\w/')), 'symbol.annotation' => new Rule(new RegexMatcher('/\\[([\\w\\.]+)\\s*(?P<arguments>\\((?>[^()]+|(?&arguments))*\\))\\s*\\]/si', [1 => Token::NAME, 'arguments' => '$.arguments']))]);
 }