summaryrefslogtreecommitdiff
path: root/pygments/lexers/jvm.py
diff options
context:
space:
mode:
authorGaurav Jain <gaurav@gauravjain.org>2014-05-12 23:03:21 -0400
committerGaurav Jain <gaurav@gauravjain.org>2014-05-12 23:03:21 -0400
commit51d5e12de5378483a19209abd873f9932fd65458 (patch)
treed747510d2d1a7f6443711234379e8c02919d0933 /pygments/lexers/jvm.py
parent16b39eea26af87813151b03992f2ed4738057eaa (diff)
downloadpygments-51d5e12de5378483a19209abd873f9932fd65458.tar.gz
Add support for unicode letters in Java identifiers
Additionally, allow $ in middle of variable names
Diffstat (limited to 'pygments/lexers/jvm.py')
-rw-r--r--pygments/lexers/jvm.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py
index 06dcc81b..b2fda960 100644
--- a/pygments/lexers/jvm.py
+++ b/pygments/lexers/jvm.py
@@ -34,14 +34,14 @@ class JavaLexer(RegexLexer):
filenames = ['*.java']
mimetypes = ['text/x-java']
- flags = re.MULTILINE | re.DOTALL
+ flags = re.MULTILINE | re.DOTALL | re.UNICODE
tokens = {
'root': [
(r'[^\S\n]+', Text),
(r'//.*?\n', Comment.Single),
(r'/\*.*?\*/', Comment.Multiline),
- (r'@[a-zA-Z_][a-zA-Z0-9_\.]*', Name.Decorator),
+ (r'@[^\W\d][\w\.]*', Name.Decorator),
(r'(assert|break|case|catch|continue|default|do|else|finally|for|'
r'if|goto|instanceof|new|return|switch|this|throw|try|while)\b',
Keyword),
@@ -51,9 +51,9 @@ class JavaLexer(RegexLexer):
(r'(boolean|byte|char|double|float|int|long|short|void)\b',
Keyword.Type),
# method names
- (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]<>]*\s+)+?)' # return arguments
- r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
- r'(\s*)(\()', # signature start
+ (r'^(\s*(?:[^\W\d][\w\.\[\]<>]*\s+)+?)' # return arguments
+ r'([^\W\d]\w*)' # method name
+ r'(\s*)(\()', # signature start
bygroups(using(this), Name.Function, Text, Operator)),
(r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
(r'(true|false|null)\b', Keyword.Constant),
@@ -61,9 +61,9 @@ class JavaLexer(RegexLexer):
(r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
(r'"(\\\\|\\"|[^"])*"', String),
(r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
- (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)),
- (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
- (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
+ (r'(\.)([^\W\d]\w*)', bygroups(Operator, Name.Attribute)),
+ (r'[^\W\d]\w*:', Name.Label),
+ (r'([^\W\d]|\$)[\w\$]*', Name),
(r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
(r'0x[0-9a-fA-F]+', Number.Hex),
@@ -71,10 +71,10 @@ class JavaLexer(RegexLexer):
(r'\n', Text)
],
'class': [
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+ (r'[^\W\d]\w*', Name.Class, '#pop')
],
'import': [
- (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
+ (r'[\w.]+\*?', Name.Namespace, '#pop')
],
}