summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2017-01-17 08:40:29 +0100
committerGeorg Brandl <georg@python.org>2017-01-17 08:40:29 +0100
commit764d102841016c38742704f5e1573f22336b3249 (patch)
treed6ad7edbc224c86e80931137619431486798e8c6
parent5c29a167c321f27d3c58b9c8d8b350cde0658698 (diff)
parentc6095b637547ae379c968aea33acbe69ed201e6f (diff)
downloadpygments-764d102841016c38742704f5e1573f22336b3249.tar.gz
Merged in takluyver/pygments-main/delay-pkg-resources (pull request #690)
Delay loading pkg_resources until it is needed.
-rw-r--r--pygments/lexers/_mapping.py2
-rw-r--r--pygments/lexers/asm.py6
-rw-r--r--pygments/lexers/dsls.py2
-rw-r--r--pygments/lexers/haskell.py5
-rw-r--r--pygments/lexers/javascript.py16
-rw-r--r--pygments/lexers/python.py1
-rw-r--r--pygments/lexers/verification.py4
-rw-r--r--tests/examplefiles/example.hs10
-rw-r--r--tests/test_basic_api.py8
-rw-r--r--tests/test_examplefiles.py2
-rw-r--r--tests/test_latex_formatter.py4
11 files changed, 36 insertions, 24 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index a6097b1c..12c3d5f4 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -378,7 +378,7 @@ LEXERS = {
'ScilabLexer': ('pygments.lexers.matlab', 'Scilab', ('scilab',), ('*.sci', '*.sce', '*.tst'), ('text/scilab',)),
'ScssLexer': ('pygments.lexers.css', 'SCSS', ('scss',), ('*.scss',), ('text/x-scss',)),
'ShenLexer': ('pygments.lexers.lisp', 'Shen', ('shen',), ('*.shen',), ('text/x-shen', 'application/x-shen')),
- 'SilverLexer': ('pygments.lexers.verification', 'Silver', ('silver',), ('*.sil',), ()),
+ 'SilverLexer': ('pygments.lexers.verification', 'Silver', ('silver',), ('*.sil', '*.vpr'), ()),
'SlimLexer': ('pygments.lexers.webmisc', 'Slim', ('slim',), ('*.slim',), ('text/x-slim',)),
'SmaliLexer': ('pygments.lexers.dalvik', 'Smali', ('smali',), ('*.smali',), ('text/smali',)),
'SmalltalkLexer': ('pygments.lexers.smalltalk', 'Smalltalk', ('smalltalk', 'squeak', 'st'), ('*.st',), ('text/x-smalltalk',)),
diff --git a/pygments/lexers/asm.py b/pygments/lexers/asm.py
index 2bb3eac9..4c58e54b 100644
--- a/pygments/lexers/asm.py
+++ b/pygments/lexers/asm.py
@@ -54,8 +54,6 @@ class GasLexer(RegexLexer):
(number, Number.Integer),
(r'[\r\n]+', Text, '#pop'),
- (r'#.*?$', Comment, '#pop'),
-
include('punctuation'),
include('whitespace')
],
@@ -78,14 +76,14 @@ class GasLexer(RegexLexer):
('$'+number, Number.Integer),
(r"$'(.|\\')'", String.Char),
(r'[\r\n]+', Text, '#pop'),
- (r'#.*?$', Comment, '#pop'),
+
include('punctuation'),
include('whitespace')
],
'whitespace': [
(r'\n', Text),
(r'\s+', Text),
- (r'#.*?\n', Comment)
+ (r'[;#].*?\n', Comment)
],
'punctuation': [
(r'[-*,.()\[\]!:]+', Punctuation)
diff --git a/pygments/lexers/dsls.py b/pygments/lexers/dsls.py
index 312d5f5e..4044b7c5 100644
--- a/pygments/lexers/dsls.py
+++ b/pygments/lexers/dsls.py
@@ -36,7 +36,7 @@ class ProtoBufLexer(RegexLexer):
tokens = {
'root': [
(r'[ \t]+', Text),
- (r'[,;{}\[\]()]', Punctuation),
+ (r'[,;{}\[\]()<>]', Punctuation),
(r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
(r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment.Multiline),
(words((
diff --git a/pygments/lexers/haskell.py b/pygments/lexers/haskell.py
index ffc3a3a2..b85a8d58 100644
--- a/pygments/lexers/haskell.py
+++ b/pygments/lexers/haskell.py
@@ -39,7 +39,7 @@ class HaskellLexer(RegexLexer):
flags = re.MULTILINE | re.UNICODE
reserved = ('case', 'class', 'data', 'default', 'deriving', 'do', 'else',
- 'if', 'in', 'infix[lr]?', 'instance',
+ 'family', 'if', 'in', 'infix[lr]?', 'instance',
'let', 'newtype', 'of', 'then', 'type', 'where', '_')
ascii = ('NUL', 'SOH', '[SE]TX', 'EOT', 'ENQ', 'ACK',
'BEL', 'BS', 'HT', 'LF', 'VT', 'FF', 'CR', 'S[OI]', 'DLE',
@@ -63,6 +63,9 @@ class HaskellLexer(RegexLexer):
(r'^[_' + uni.Ll + r'][\w\']*', Name.Function),
(r"'?[_" + uni.Ll + r"][\w']*", Name),
(r"('')?[" + uni.Lu + r"][\w\']*", Keyword.Type),
+ (r"(')[" + uni.Lu + r"][\w\']*", Keyword.Type),
+ (r"(')\[[^\]]*\]", Keyword.Type), # tuples and lists get special treatment in GHC
+ (r"(')\([^\)]*\)", Keyword.Type), # ..
# Operators
(r'\\(?![:!#$%&*+.\\/<=>?@^|~-]+)', Name.Function), # lambda operator
(r'(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word), # specials
diff --git a/pygments/lexers/javascript.py b/pygments/lexers/javascript.py
index a23ba184..4b47b15a 100644
--- a/pygments/lexers/javascript.py
+++ b/pygments/lexers/javascript.py
@@ -53,7 +53,7 @@ class JavascriptLexer(RegexLexer):
'slashstartsregex': [
include('commentsandwhitespace'),
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
- r'([gim]+\b|\B)', String.Regex, '#pop'),
+ r'([gimuy]+\b|\B)', String.Regex, '#pop'),
(r'(?=/)', Text, ('#pop', 'badregex')),
default('#pop')
],
@@ -64,9 +64,14 @@ class JavascriptLexer(RegexLexer):
(r'\A#! ?/.*?\n', Comment.Hashbang), # recognized by node.js
(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
include('commentsandwhitespace'),
+ (r'(\.\d+|[0-9]+\.[0-9]*)([eE][-+]?[0-9]+)?', Number.Float),
+ (r'0[bB][01]+', Number.Bin),
+ (r'0[oO][0-7]+', Number.Oct),
+ (r'0[xX][0-9a-fA-F]+', Number.Hex),
+ (r'[0-9]+', Number.Integer),
+ (r'\.\.\.|=>', Punctuation),
(r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
- r'(<<|>>>?|=>|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),
- (r'\.\.\.', Punctuation),
+ r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
(r'[})\].]', Punctuation),
(r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
@@ -84,11 +89,6 @@ class JavascriptLexer(RegexLexer):
r'Error|eval|isFinite|isNaN|isSafeInteger|parseFloat|parseInt|'
r'document|this|window)\b', Name.Builtin),
(JS_IDENT, Name.Other),
- (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
- (r'0b[01]+', Number.Bin),
- (r'0o[0-7]+', Number.Oct),
- (r'0x[0-9a-fA-F]+', Number.Hex),
- (r'[0-9]+', Number.Integer),
(r'"(\\\\|\\"|[^"])*"', String.Double),
(r"'(\\\\|\\'|[^'])*'", String.Single),
(r'`', String.Backtick, 'interp'),
diff --git a/pygments/lexers/python.py b/pygments/lexers/python.py
index 35635ed1..d41dd08d 100644
--- a/pygments/lexers/python.py
+++ b/pygments/lexers/python.py
@@ -362,6 +362,7 @@ class Python3Lexer(RegexLexer):
]
tokens['numbers'] = [
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
+ (r'\d+[eE][+-]?[0-9]+j?', Number.Float),
(r'0[oO][0-7]+', Number.Oct),
(r'0[bB][01]+', Number.Bin),
(r'0[xX][a-fA-F0-9]+', Number.Hex),
diff --git a/pygments/lexers/verification.py b/pygments/lexers/verification.py
index 3e77e04a..1ffee0ab 100644
--- a/pygments/lexers/verification.py
+++ b/pygments/lexers/verification.py
@@ -69,7 +69,7 @@ class SilverLexer(RegexLexer):
"""
name = 'Silver'
aliases = ['silver']
- filenames = ['*.sil']
+ filenames = ['*.sil', '*.vpr']
tokens = {
'root': [
@@ -89,7 +89,7 @@ class SilverLexer(RegexLexer):
'constraining', 'Seq', 'Set', 'Multiset', 'union', 'intersection',
'setminus', 'subset', 'unfolding', 'in', 'old', 'forall', 'exists',
'acc', 'wildcard', 'write', 'none', 'epsilon', 'perm', 'unique',
- 'apply', 'package', 'folding', 'label'),
+ 'apply', 'package', 'folding', 'label', 'forperm'),
suffix=r'\b'), Keyword),
(words(('Int', 'Perm', 'Bool', 'Ref'), suffix=r'\b'), Keyword.Type),
include('numbers'),
diff --git a/tests/examplefiles/example.hs b/tests/examplefiles/example.hs
index f5e2b555..764cab77 100644
--- a/tests/examplefiles/example.hs
+++ b/tests/examplefiles/example.hs
@@ -29,3 +29,13 @@ data ĈrazyThings =
-- some char literals:
charl = ['"', 'a', '\ESC', '\'', ' ']
+
+-- closed type families
+type family Fam (a :: Type) = r :: Type where
+ Fam Int = True
+ Fam a = False
+
+-- type literals
+type IntChar = '[Int, Char]
+type Falsy = 'False
+type Falsy = '(10, 20, 30)
diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py
index 022e6c55..03a452d7 100644
--- a/tests/test_basic_api.py
+++ b/tests/test_basic_api.py
@@ -161,8 +161,8 @@ def test_formatter_public_api():
try:
inst = formatter(opt1="val1")
- except (ImportError, FontNotFound):
- raise support.SkipTest
+ except (ImportError, FontNotFound) as e:
+ raise support.SkipTest(e)
try:
inst.get_style_defs()
@@ -209,9 +209,9 @@ def test_formatter_unicode_handling():
def verify(formatter):
try:
inst = formatter(encoding=None)
- except (ImportError, FontNotFound):
+ except (ImportError, FontNotFound) as e:
# some dependency or font not installed
- raise support.SkipTest
+ raise support.SkipTest(e)
if formatter.name != 'Raw tokens':
out = format(tokens, inst)
diff --git a/tests/test_examplefiles.py b/tests/test_examplefiles.py
index f43abf9b..28037a55 100644
--- a/tests/test_examplefiles.py
+++ b/tests/test_examplefiles.py
@@ -89,7 +89,7 @@ def test_example_files():
def check_lexer(lx, fn):
if os.name == 'java' and fn in BAD_FILES_FOR_JYTHON:
- raise support.SkipTest
+ raise support.SkipTest('%s is a known bad file on Jython' % fn)
absfn = os.path.join(TESTDIR, 'examplefiles', fn)
with open(absfn, 'rb') as fp:
text = fp.read()
diff --git a/tests/test_latex_formatter.py b/tests/test_latex_formatter.py
index 05a6c3ac..fbcb6cde 100644
--- a/tests/test_latex_formatter.py
+++ b/tests/test_latex_formatter.py
@@ -42,9 +42,9 @@ class LatexFormatterTest(unittest.TestCase):
ret = po.wait()
output = po.stdout.read()
po.stdout.close()
- except OSError:
+ except OSError as e:
# latex not available
- raise support.SkipTest
+ raise support.SkipTest(e)
else:
if ret:
print(output)