summaryrefslogtreecommitdiff
path: root/pygments/lexers/special.py
diff options
context:
space:
mode:
authorgbrandl <devnull@localhost>2006-10-30 08:58:16 +0100
committergbrandl <devnull@localhost>2006-10-30 08:58:16 +0100
commit774af50b54d2ada20167b8b11a63d077b41ca5a9 (patch)
tree63876f260526e4aa78c5bebb758efbdef55e9ca9 /pygments/lexers/special.py
parentc42b7e1df1a4bcd5107b2a118b74d8dd476b0223 (diff)
downloadpygments-774af50b54d2ada20167b8b11a63d077b41ca5a9.tar.gz
[svn] Add a new unit test, reduce size of some examples, fix a few errors.
Diffstat (limited to 'pygments/lexers/special.py')
-rw-r--r--pygments/lexers/special.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/pygments/lexers/special.py b/pygments/lexers/special.py
index 621145a2..dcf9899c 100644
--- a/pygments/lexers/special.py
+++ b/pygments/lexers/special.py
@@ -13,7 +13,7 @@ import re
import cStringIO
from pygments.lexer import Lexer, RegexLexer
-from pygments.token import Token, \
+from pygments.token import Token, Error, \
Text, Comment, Operator, Keyword, Name, String, Number
@@ -66,14 +66,19 @@ class RawTokenLexer(Lexer):
def get_tokens_unprocessed(self, text):
length = 0
for match in line_re.finditer(text):
- ttypestr, val = match.group().split('\t', 1)
- ttype = _ttype_cache.get(ttypestr)
- if not ttype:
- ttype = Token
- ttypes = ttypestr.split('.')[1:]
- for ttype_ in ttypes:
- ttype = getattr(ttype, ttype_)
- _ttype_cache[ttypestr] = ttype
- val = val[1:-2].decode('string-escape')
+ try:
+ ttypestr, val = match.group().split('\t', 1)
+ except ValueError:
+ val = match.group()
+ ttype = Error
+ else:
+ ttype = _ttype_cache.get(ttypestr)
+ if not ttype:
+ ttype = Token
+ ttypes = ttypestr.split('.')[1:]
+ for ttype_ in ttypes:
+ ttype = getattr(ttype, ttype_)
+ _ttype_cache[ttypestr] = ttype
+ val = val[1:-2].decode('string-escape')
yield length, ttype, val
length += len(val)