From ada40b42249bd6834de13da8ba132c8a3385cff0 Mon Sep 17 00:00:00 2001 From: moculus Date: Tue, 24 Jul 2007 21:22:35 +0000 Subject: [PATCH] fix bug affecting almost empty files --HG-- branch : pmacs2 --- lex3.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lex3.py b/lex3.py index 6056fac..ed3a32c 100755 --- a/lex3.py +++ b/lex3.py @@ -253,12 +253,13 @@ class RegionRule(Rule): # ok, so now loop over all the tokens in the current grammar, until # the stop-token (if any) is found, and return each result as we get # it. + tok = None for tok in self._lex(lexer, toresume, tokname, stopre, grammar): yield tok # ok, so now either we found the stop-token, and have a new parent # for future tokens (if any), or we are done. - if tok.name == tokname: + if tok is not None and tok.name == tokname: toresume = [tok] matchd.update(tok.matchd) else: