summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/src/tokens.txt4
-rw-r--r--pygments/lexers/agile.py8
-rw-r--r--pygments/lexers/compiled.py19
3 files changed, 18 insertions, 13 deletions
diff --git a/docs/src/tokens.txt b/docs/src/tokens.txt
index 5451ec8c..9ef0df8d 100644
--- a/docs/src/tokens.txt
+++ b/docs/src/tokens.txt
@@ -117,6 +117,10 @@ Keyword Tokens
For keywords used for variable declaration (e.g. ``var`` in some programming
languages like JavaScript).
+`Keyword.Namespace`
+ For keywords used for namespace declarations (e.g. ``import`` in Python and
+ Java and ``package`` in Java).
+
`Keyword.Pseudo`
For keywords that aren't really keywords (e.g. ``None`` in old Python
versions).
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py
index 30779ebd..83bea6a8 100644
--- a/pygments/lexers/agile.py
+++ b/pygments/lexers/agile.py
@@ -60,8 +60,8 @@ class PythonLexer(RegexLexer):
include('keywords'),
(r'(def)(\s+)', bygroups(Keyword, Text), 'funcname'),
(r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
- (r'(from)(\s+)', bygroups(Keyword, Text), 'fromimport'),
- (r'(import)(\s+)', bygroups(Keyword, Text), 'import'),
+ (r'(from)(\s+)', bygroups(Keyword.Namespace, Text), 'fromimport'),
+ (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
include('builtins'),
include('backtick'),
('(?:[rR]|[uU][rR]|[rR][uU])"""', String, 'tdqs'),
@@ -126,13 +126,13 @@ class PythonLexer(RegexLexer):
('[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
],
'import': [
- (r'(\s+)(as)(\s+)', bygroups(Text, Keyword, Text)),
+ (r'(\s+)(as)(\s+)', bygroups(Text, Keyword.Namespace, Text)),
(r'[a-zA-Z_][a-zA-Z0-9_.]*', Name.Namespace),
(r'(\s*)(,)(\s*)', bygroups(Text, Operator, Text)),
(r'', Text, '#pop') # all else: go back
],
'fromimport': [
- (r'(\s+)(import)\b', bygroups(Text, Keyword), '#pop'),
+ (r'(\s+)(import)\b', bygroups(Text, Keyword.Namespace), '#pop'),
(r'[a-zA-Z_.][a-zA-Z0-9_.]*', Name.Namespace),
],
'stringescape': [
diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py
index 12e99930..8058317d 100644
--- a/pygments/lexers/compiled.py
+++ b/pygments/lexers/compiled.py
@@ -129,7 +129,7 @@ class CLexer(RegexLexer):
}
stdlib_types = ['size_t', 'ssize_t', 'off_t', 'wchar_t', 'ptrdiff_t',
- 'sig_atomic_t', 'fpos_t', 'clock_t', 'time_t', 'va_list',
+ 'sig_atomic_t', 'fpos_t', 'clock_t', 'time_t', 'va_list',
'jmp_buf', 'FILE', 'DIR', 'div_t', 'ldiv_t', 'mbstate_t',
'wctrans_t', 'wint_t', 'wctype_t']
c99_types = ['_Bool', '_Complex', 'int8_t', 'int16_t', 'int32_t', 'int64_t',
@@ -892,17 +892,18 @@ class JavaLexer(RegexLexer):
(r'//.*?\n', Comment),
(r'/\*.*?\*/', Comment),
(r'@[a-zA-Z_][a-zA-Z0-9_\.]*', Name.Decorator),
- (r'(abstract|assert|break|case|catch|'
- r'const|continue|default|do|else|enum|extends|final|'
- r'finally|for|if|goto|implements|instanceof|'
- r'native|new|package|private|protected|public|'
- r'return|static|strictfp|super|switch|synchronized|this|'
- r'throw|throws|transient|try|volatile|while)\b', Keyword),
+ (r'(assert|break|case|catch|continue|default|do|else|finally|for|'
+ r'if|goto|instanceof|new|return|switch|this|throw|try|while)\b',
+ Keyword),
+ (r'(abstract|const|enum|extends|final|implements|native|private|'
+ r'protected|public|static|strictfp|super|synchronized|throws|'
+ r'transient|volatile)\b', Keyword.Declaration),
(r'(boolean|byte|char|double|float|int|long|short|void)\b',
Keyword.Type),
+ (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
(r'(true|false|null)\b', Keyword.Constant),
- (r'(class|interface)(\s+)', bygroups(Keyword, Text), 'class'),
- (r'(import)(\s+)', bygroups(Keyword, Text), 'import'),
+ (r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text), 'class'),
+ (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
(r'"(\\\\|\\"|[^"])*"', String),
(r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char),
(r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)),