3
3
MoinMoin - Java Source Parser
5
DEPRECATED compatibility wrapper calling the highlight parser.
7
This is to support (deprecated) existing syntax like:
12
It is equivalent to the new way to highlight code:
13
{{{#!highlight java ...
17
@copyright: 2008 MoinMoin:ThomasWaldmann
5
@copyright: 2002 Taesu Pyo <bigflood@hitel.net>
18
6
@license: GNU GPL, see COPYING for details.
21
from MoinMoin.parser.highlight import Parser as HighlightParser
22
from MoinMoin.parser.highlight import Dependencies
24
class Parser(HighlightParser):
25
parsername = 'java' # Lexer name pygments recognizes
26
extensions = [] # this is only a compatibility wrapper, we have declared
27
# support for this extension in the HighlightParser, so
28
# moin will call that directly
10
from MoinMoin.parser._ParserBase import ParserBase
12
Dependencies = ['user'] # the "Toggle line numbers link" depends on user's language
14
class Parser(ParserBase):
16
parsername = "ColorizedJava"
17
extensions = ['.java']
18
Dependencies = Dependencies
21
ParserBase.setupRules(self)
23
self.addRulePair("Comment", "/[*]", "[*]/")
24
self.addRule("Comment", "//.*$")
25
self.addRulePair("String", '"', r'$|[^\\](\\\\)*"')
26
self.addRule("Char", r"'\\.'|'[^\\]'")
27
self.addRule("Number", r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?")
28
self.addRule("ID", "[a-zA-Z_][0-9a-zA-Z_]*")
29
self.addRule("SPChar", r"[~!%^&*()+=|\[\]:;,.<>/?{}-]")
31
reserved_words = ['class', 'interface', 'enum', 'import', 'package',
32
'byte', 'int', 'long', 'float', 'double', 'char', 'short', 'void', 'boolean',
33
'static', 'final', 'const', 'private', 'public', 'protected',
34
'new', 'this', 'super', 'abstract', 'native', 'synchronized', 'transient', 'volatile', 'strictfp',
35
'extends', 'implements', 'if', 'else', 'while', 'for', 'do', 'switch', 'case', 'default', 'instanceof',
36
'try', 'catch', 'finally', 'throw', 'throws', 'return', 'continue', 'break']
38
self.addReserved(reserved_words)
40
constant_words = ['true', 'false', 'null']
42
self.addConstant(constant_words)