diff options
author | Benjamin Peterson <benjamin@python.org> | 2011-02-26 22:11:02 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2011-02-26 22:11:02 (GMT) |
commit | 8059e1e2140d08683429a6731ecf4b1d2385cce3 (patch) | |
tree | ea2fede850afc6951800381fb4174b73e4a91b4f /Lib/lib2to3/pgen2/driver.py | |
parent | aeb187a22b2210fcf240a318d1745d0153c5e574 (diff) | |
download | cpython-8059e1e2140d08683429a6731ecf4b1d2385cce3.zip cpython-8059e1e2140d08683429a6731ecf4b1d2385cce3.tar.gz cpython-8059e1e2140d08683429a6731ecf4b1d2385cce3.tar.bz2 |
Merged revisions 88535,88661 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r88535 | brett.cannon | 2011-02-23 13:46:46 -0600 (Wed, 23 Feb 2011) | 1 line
Add lib2to3.__main__ for easy testing from the console.
........
r88661 | benjamin.peterson | 2011-02-26 16:06:24 -0600 (Sat, 26 Feb 2011) | 6 lines
fix refactoring on formfeed characters #11250
This is because text.splitlines() is not the same as
list(StringIO.StringIO(text)).
........
Diffstat (limited to 'Lib/lib2to3/pgen2/driver.py')
-rw-r--r-- | Lib/lib2to3/pgen2/driver.py | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/Lib/lib2to3/pgen2/driver.py b/Lib/lib2to3/pgen2/driver.py index 6b3825e..16adec0 100644 --- a/Lib/lib2to3/pgen2/driver.py +++ b/Lib/lib2to3/pgen2/driver.py @@ -19,6 +19,7 @@ __all__ = ["Driver", "load_grammar"] import codecs import os import logging +import StringIO import sys # Pgen imports @@ -101,18 +102,10 @@ class Driver(object): def parse_string(self, text, debug=False): """Parse a string and return the syntax tree.""" - tokens = tokenize.generate_tokens(generate_lines(text).next) + tokens = tokenize.generate_tokens(StringIO.StringIO(text).readline) return self.parse_tokens(tokens, debug) -def generate_lines(text): - """Generator that behaves like readline without using StringIO.""" - for line in text.splitlines(True): - yield line - while True: - yield "" - - def load_grammar(gt="Grammar.txt", gp=None, save=True, force=False, logger=None): """Load the grammar (maybe from a pickle).""" |