Misc bugs

parse2.py: restore accidently-removed while1stmt rule
scanner27.py: grammar typo
check_ast: add while1else to list of looping constructs
pysource.py: CALL_FUNCTION_VAR_KW_ARGS with positional args rule is different?
This commit is contained in:
rocky
2017-04-10 07:57:56 -04:00
parent 9e34654b38
commit 41343c27b7
4 changed files with 7 additions and 4 deletions

View File

@@ -41,6 +41,7 @@ class Python2Parser(PythonParser):
def p_stmt2(self, args): def p_stmt2(self, args):
""" """
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK COME_FROM while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK COME_FROM
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK else_suite COME_FROM while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK else_suite COME_FROM

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2015, 2016 by Rocky Bernstein # Copyright (c) 2015-2017 by Rocky Bernstein
""" """
Python 2.7 bytecode ingester. Python 2.7 bytecode ingester.
@@ -48,7 +48,7 @@ class Scanner27(Scanner2):
self.opc.DELETE_SLICE_2, self.opc.DELETE_SLICE_3, self.opc.DELETE_SLICE_2, self.opc.DELETE_SLICE_3,
]) ])
# opcodes with expect a variable number pushed values whose # opcodes which expect a variable number pushed values and whose
# count is in the opcode. For parsing we generally change the # count is in the opcode. For parsing we generally change the
# opcode name to include that number. # opcode name to include that number.
varargs_ops = set([ varargs_ops = set([

View File

@@ -10,7 +10,7 @@ before reduction and don't reduce when there is a problem.
def checker(ast, in_loop, errors): def checker(ast, in_loop, errors):
in_loop = in_loop or ast.type in ('while1stmt', 'whileTruestmt', in_loop = in_loop or ast.type in ('while1stmt', 'whileTruestmt',
'whilestmt', 'whileelsestmt', 'whilestmt', 'whileelsestmt', 'while1elsestmt',
'for_block') 'for_block')
if ast.type in ('augassign1', 'augassign2') and ast[0][0] == 'and': if ast.type in ('augassign1', 'augassign2') and ast[0][0] == 'and':
text = str(ast) text = str(ast)

View File

@@ -1786,7 +1786,9 @@ class SourceWalker(GenericASTTraversal, object):
str += '*%c, **%c)' str += '*%c, **%c)'
# Python 3.5 only puts optional args (the VAR part) # Python 3.5 only puts optional args (the VAR part)
# lowest down the stack # lowest down the stack
if self.version == 3.5: na = (v & 0xff) # positional parameters
if self.version == 3.5 and na == 0:
print("XXX", k)
if p2[2]: p2 = (2, -2, ', ') if p2[2]: p2 = (2, -2, ', ')
entry = (str, 0, p2, 1, -2) entry = (str, 0, p2, 1, -2)
else: else: