Tidy a little ...

parse32.py: Move common grammar rules from parse32.py to parse3.py
            parse32 should just have 3.2ish specific stuff.

parse3.py: favor addRule over add_unique_rule

pysource.py: make more clear what's up with comprehensions.
             more later.
This commit is contained in:
rocky
2017-12-04 09:36:39 -05:00
parent 3425851dc7
commit 53b195ede9
3 changed files with 25 additions and 21 deletions

View File

@@ -1082,9 +1082,10 @@ class SourceWalker(GenericASTTraversal, object):
assert n == 'list_iter'
# find innermost node
# Find the list comprehension body. It is the inner-most
# node.
while n == 'list_iter':
n = n[0] # recurse one step
n = n[0] # iterate one nesting deeper
if n == 'list_for': n = n[3]
elif n == 'list_if': n = n[2]
elif n == 'list_if_not': n= n[2]
@@ -1140,9 +1141,10 @@ class SourceWalker(GenericASTTraversal, object):
assert n == 'list_iter'
assert store == 'store'
# find innermost node
# Find the list comprehension body. It is the inner-most
# node.
while n == 'list_iter':
n = n[0] # recurse one step
n = n[0] # iterate one nesting deeper
if n == 'list_for': n = n[3]
elif n == 'list_if': n = n[2]
elif n == 'list_if_not': n= n[2]