aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mako/lexer.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-03-01 20:52:43 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-03-01 20:52:43 +0000
commitda478af85111d92bba7003bb7d5772a2da267c7b (patch)
tree64c855e3e5e8875a8e4c57164f3a98eb9499852f /lib/mako/lexer.py
parentab9c4e6e563483b9be7fc0a28aec41a81e08fe5e (diff)
downloadexternal_python_mako-da478af85111d92bba7003bb7d5772a2da267c7b.tar.gz
external_python_mako-da478af85111d92bba7003bb7d5772a2da267c7b.tar.bz2
external_python_mako-da478af85111d92bba7003bb7d5772a2da267c7b.zip
- fixes to code parsing/whitespace adjusting where plain python
comments may contain quote characters [ticket:23]
Diffstat (limited to 'lib/mako/lexer.py')
-rw-r--r--lib/mako/lexer.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/mako/lexer.py b/lib/mako/lexer.py
index 9e0905f..179e15c 100644
--- a/lib/mako/lexer.py
+++ b/lib/mako/lexer.py
@@ -59,6 +59,9 @@ class Lexer(object):
def parse_until_text(self, *text):
startpos = self.match_position
while True:
+ match = self.match(r'#.*\n')
+ if match:
+ continue
match = self.match(r'(\"\"\"|\'\'\'|\"|\')')
if match:
m = self.match(r'.*?%s' % match.group(1), re.S)
@@ -69,7 +72,7 @@ class Lexer(object):
if match:
return (self.text[startpos:self.match_position-len(match.group(1))], match.group(1))
else:
- match = self.match(r".*?(?=\"|\'|%s)" % r'|'.join(text), re.S)
+ match = self.match(r".*?(?=\"|\'|#|%s)" % r'|'.join(text), re.S)
if not match:
raise exceptions.SyntaxException("Expected: %s" % ','.join(text), self.matched_lineno, self.matched_charpos, self.filename)