summaryrefslogtreecommitdiff
path: root/pygments/lexer.py
diff options
context:
space:
mode:
authorgbrandl <devnull@localhost>2007-03-20 13:39:28 +0100
committergbrandl <devnull@localhost>2007-03-20 13:39:28 +0100
commiteaa1b5924fc57e19e537f9107a515e792e168fc2 (patch)
tree2ec13207f7590e7cdc19a6b0ba7325468104e02d /pygments/lexer.py
parent5f5642e6f1ef4cccee57be2134e483383721b933 (diff)
downloadpygments-eaa1b5924fc57e19e537f9107a515e792e168fc2.tar.gz
[svn] A better error message if compiling a regex fails.
Diffstat (limited to 'pygments/lexer.py')
-rw-r--r--pygments/lexer.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/pygments/lexer.py b/pygments/lexer.py
index 0c28cf3e..bffec0f1 100644
--- a/pygments/lexer.py
+++ b/pygments/lexer.py
@@ -364,7 +364,11 @@ class RegexLexerMeta(LexerMeta):
assert type(tdef) is tuple, "wrong rule def %r" % tdef
- rex = re.compile(tdef[0], rflags).match
+ try:
+ rex = re.compile(tdef[0], rflags).match
+ except Exception, err:
+ raise ValueError("uncompilable regex %r in state %r of %r: %s" %
+ (tdef[0], state, cls, err))
assert type(tdef[1]) is _TokenType or callable(tdef[1]), \
'token type must be simple type or callable, not %r' % tdef[1]