|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Highlighter |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright (C) 2016, Some right reserved. |
|
6
|
|
|
* |
|
7
|
|
|
* @author Kacper "Kadet" Donat <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* Contact with author: |
|
10
|
|
|
* Xmpp: [email protected] |
|
11
|
|
|
* E-mail: [email protected] |
|
12
|
|
|
* |
|
13
|
|
|
* From Kadet with love. |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace Kadet\Highlighter\Language; |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
use Kadet\Highlighter\Matcher\RegexMatcher; |
|
20
|
|
|
use Kadet\Highlighter\Matcher\WordMatcher; |
|
21
|
|
|
use Kadet\Highlighter\Parser\Token\Token; |
|
22
|
|
|
|
|
23
|
|
|
class Java extends CSharp // evil |
|
24
|
|
|
{ |
|
25
|
|
|
public function setupRules() |
|
26
|
|
|
{ |
|
27
|
|
|
parent::setupRules(); |
|
28
|
|
|
|
|
29
|
|
|
$this->rules->rule('keyword')->setMatcher(new WordMatcher([ |
|
30
|
|
|
'abstract', 'continue', 'for', 'new', 'switch', 'assert', 'default', 'goto', 'package', 'synchronized', |
|
31
|
|
|
'do', 'if', 'private', 'this', 'break', 'double', 'implements', 'protected', 'throw', 'else', 'import', |
|
32
|
|
|
'public', 'throws', 'case', 'enum', 'instanceof', 'return', 'transient', 'catch', 'extends', 'try', 'final', |
|
33
|
|
|
'interface', 'static', 'class', 'finally', 'strictfp', 'volatile', 'const', 'native', 'super', 'while' |
|
34
|
|
|
])); |
|
35
|
|
|
|
|
36
|
|
|
$this->rules->rule('annotation')->setMatcher(new RegexMatcher('/(@[\w\.]+)\s*(?:(?P<arguments>\((?>[^()]+|(?&arguments))*\))?)/si', [ |
|
37
|
|
|
1 => Token::NAME |
|
38
|
|
|
])); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getIdentifier() |
|
42
|
|
|
{ |
|
43
|
|
|
return 'java'; |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|