コード例 #1
0
ファイル: Html.php プロジェクト: kadet1090/KeyLighter
 /**
  * Tokenization rules
  */
 public function setupRules()
 {
     parent::setupRules();
     $css = new Css();
     $js = new JavaScript();
     $this->rules->addMany(['language.' . $js->getIdentifier() => [new OpenRule(new RegexMatcher('/<script.*?>()/'), ['factory' => new TokenFactory(LanguageToken::class), 'inject' => $js, 'language' => $this, 'postProcess' => true]), new CloseRule(new RegexMatcher('/()<\\/script>/'), ['factory' => new TokenFactory(LanguageToken::class), 'language' => $js])], 'language.' . $css->getIdentifier() => [new OpenRule(new RegexMatcher('/<style.*?>()/'), ['factory' => new TokenFactory(LanguageToken::class), 'inject' => $css, 'language' => $this, 'postProcess' => true]), new CloseRule(new RegexMatcher('/()<\\/style>/'), ['factory' => new TokenFactory(LanguageToken::class), 'language' => $css])]]);
 }
コード例 #2
0
ファイル: Xaml.php プロジェクト: kadet1090/KeyLighter
 public function setupRules()
 {
     parent::setupRules();
     $attribute = $this->rules->rule('symbol.attribute');
     $tag = $this->rules->rule('symbol.tag');
     $this->rules->remove('symbol.attribute');
     $this->rules->remove('symbol.tag');
     $this->rules->add('variable', $attribute);
     $this->rules->add('symbol.class', $tag);
     $this->rules->add('variable.property', new Rule(new RegexMatcher('/[\\w-]+\\.([\\w-]+)/'), ['context' => ['*tag', '*expression', '!string']]));
     $this->rules->add('expression', new Rule(new RegexMatcher('/=["\']?(?P<expression>\\{(?>(?:(?&expression)|[^{}]*)*)\\})/'), ['context' => ['tag.open']]));
 }