[pypy-svn] r51654 - pypy/dist/pypy/rlib/parsing

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Feb 19 23:09:17 CET 2008


Author: cfbolz
Date: Tue Feb 19 23:09:15 2008
New Revision: 51654

Modified:
   pypy/dist/pypy/rlib/parsing/lexer.py
Log:
fix two typos and add an assert that would have caught the typos


Modified: pypy/dist/pypy/rlib/parsing/lexer.py
==============================================================================
--- pypy/dist/pypy/rlib/parsing/lexer.py	(original)
+++ pypy/dist/pypy/rlib/parsing/lexer.py	Tue Feb 19 23:09:15 2008
@@ -131,14 +131,14 @@
                     raise deterministic.LexerError(self.text, self.state,
                                                    source_pos)
                 source = self.text[start:stop]
-                result = self.make_token(start, self.last_matched_index, source)
+                result = self.make_token(start, self.last_matched_state, source)
                 self.adjust_position(source)
                 if self.ignore_token(self.last_matched_state):
                     continue
                 return result
             if self.last_matched_index == i - 1:
                 source = self.text[start: ]
-                result = self.make_token(start, self.last_matched_index, source)
+                result = self.make_token(start, self.last_matched_state, source)
                 self.adjust_position(source)
                 if self.ignore_token(self.last_matched_state):
                     if self.eof:
@@ -192,6 +192,7 @@
         return self.automaton.names[state] in self.ignore
 
     def make_token(self, index, state, text, eof=False):
+        assert (eof and state == -1) or 0 <= state < len(self.automaton.names)
         source_pos = SourcePos(index, self.lineno, self.columnno)
         if eof:
             return Token("EOF", "EOF", source_pos)



More information about the Pypy-commit mailing list