Fragment fixes (and workarounds)

fragments.py: add more parent offsets. blacken buffer
parser3.py: additional grammar rules for fragment parser

Misc small typos and corrections
This commit is contained in:
rocky
2019-10-12 12:22:27 -04:00
parent 0cf32f1b70
commit 163e47fb49
4 changed files with 620 additions and 473 deletions

View File

@@ -68,6 +68,11 @@ class Python3Parser(PythonParser):
set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
JUMP_BACK RETURN_VALUE RETURN_LAST
# FIXME: This is used only in the fragment parser
# Fix the fragment parser so that it adds RETURN_LAST
set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
JUMP_BACK RETURN_VALUE
set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
COME_FROM JUMP_BACK RETURN_VALUE RETURN_LAST
@@ -341,6 +346,10 @@ class Python3Parser(PythonParser):
stmt ::= return_closure
return_closure ::= LOAD_CLOSURE RETURN_VALUE RETURN_LAST
# FIXME: This is used only in the fragment parser
# Fix the fragment parser so that it adds RETURN_LAST
return_closure ::= LOAD_CLOSURE RETURN_VALUE
stmt ::= whileTruestmt
ifelsestmt ::= testexpr c_stmts_opt JUMP_FORWARD else_suite _come_froms
"""

View File

@@ -418,7 +418,6 @@ TABLE_DIRECT = {
'except_suite_finalize': ( '%+%c%-%C', 1, (3, maxint, '') ),
'pass': ( '%|pass\n', ),
'STORE_FAST': ( '%{pattr}', ),
'kv': ( '%c: %c', 3, 1 ),
'kv2': ( '%c: %c', 1, 2 ),
'import': ( '%|import %c\n', 2),

File diff suppressed because it is too large Load Diff

View File

@@ -1443,7 +1443,7 @@ class SourceWalker(GenericASTTraversal, object):
list_if = None
assert n == "comp_iter"
# find innermost node
# find inner-most node
while n == "comp_iter":
n = n[0] # recurse one step
# FIXME: adjust for set comprehension