[pypy-svn] pypy default: Fix continuation lines handling. The tests all pass.

vincentlegoll commits-noreply at bitbucket.org
Tue Mar 1 05:03:41 CET 2011


Author: Vincent Legoll <vincent.legoll at gmail.com>
Branch: 
Changeset: r42360:2564812a55ee
Date: 2011-03-01 01:16 +0100
http://bitbucket.org/pypy/pypy/changeset/2564812a55ee/

Log:	Fix continuation lines handling. The tests all pass.

diff --git a/pypy/interpreter/pyparser/future.py b/pypy/interpreter/pyparser/future.py
--- a/pypy/interpreter/pyparser/future.py
+++ b/pypy/interpreter/pyparser/future.py
@@ -85,7 +85,7 @@
         c = self.getc()
         if c in ("'", '"', "r", "u") and not self.docstring_consumed:
             self.consume_docstring()
-        elif c in whitespace_or_newline:
+        elif c == '\\' or c in whitespace_or_newline:
             self.consume_empty_line()
         elif c == '#':
             self.consume_comment()
@@ -149,6 +149,12 @@
                     # Syntax error
                     return
 
+    def consume_continuation(self):
+        c = self.getc()
+        if c in '\n\r':
+            self.pos += 1
+            self.atbol()
+
     def consume_empty_line(self):
         """
         Called when the remainder of the line can only contain whitespace
@@ -162,6 +168,10 @@
             self.pos += 1
             self.consume_whitespace()
             self.start()
+        elif self.getc() in '\\':
+            self.pos += 1
+            self.consume_continuation()
+            self.start()
         elif self.getc() in '\r\n':
             c = self.getc()
             self.pos += 1


More information about the Pypy-commit mailing list