Add node and template code to cleanup "for" handling

This commit is contained in:
rocky
2015-12-26 10:42:57 -05:00
parent d6ac51d0a2
commit 3ac3ef24ac
2 changed files with 10 additions and 2 deletions

View File

@@ -57,6 +57,14 @@ ExtractInfo = namedtuple("ExtractInfo",
TABLE_DIRECT_FRAGMENT = { TABLE_DIRECT_FRAGMENT = {
'importstmt': ( '%|import %c%x\n', 2, (2, (0, 1)), ), 'importstmt': ( '%|import %c%x\n', 2, (2, (0, 1)), ),
'importfrom': ( '%|from %[2]{pattr}%x import %c\n', (2, (0, 1)), 3), 'importfrom': ( '%|from %[2]{pattr}%x import %c\n', (2, (0, 1)), 3),
# FIXME: fix bugs below and add
# 'forstmt': ( '%|for %c%x in %c:\n%+%c%-\n\n', 3, (3, (2,)), 1, 4 ),
# 'forelsestmt': (
# '%|for %c in %c%x:\n%+%c%-%|else:\n%+%c%-\n\n', 3, (3, (2,)), 1, 4, -2),
# 'forelselaststmt': (
# '%|for %c%x in %c:\n%+%c%-%|else:\n%+%c%-', 3, (3, (2,)), 1, 4, -2),
# 'forelselaststmtl': (
# '%|for %c%x in %c:\n%+%c%-%|else:\n%+%c%-\n\n', 3, (3, (2,)), 1, 4, -2),
} }
class Traverser(pysource.Walker, object): class Traverser(pysource.Walker, object):

View File

@@ -41,8 +41,8 @@ methods implement most of the below.
format string and arguments (a la printf()) for the formatting engine. format string and arguments (a la printf()) for the formatting engine.
Escapes in the format string are: Escapes in the format string are:
%c evaluate N[A] recursively* %c evaluate children N[A] recursively*
%C evaluate N[A[0]]..N[A[1]-1] recursively, separate by A[2]* %C evaluate children N[A[0]]..N[A[1]-1] recursively, separate by A[2]*
%P same as %C but sets operator precedence %P same as %C but sets operator precedence
%, print ',' if last %C only printed one item (for tuples--unused) %, print ',' if last %C only printed one item (for tuples--unused)
%| tab to current indentation level %| tab to current indentation level