Start to fold in 3.7 reduction-rule goodness into 3.6

This commit is contained in:
rocky
2020-01-08 19:50:05 -05:00
parent 7d24910b3c
commit 7b76d55e55
6 changed files with 23 additions and 2 deletions

Binary file not shown.

View File

@@ -1490,7 +1490,7 @@ class Python3Parser(PythonParser):
# print("XXX", first, last) # print("XXX", first, last)
# for t in range(first, last): print(tokens[t]) # for t in range(first, last): print(tokens[t])
# from trepan.api import debug; debug() # from trepan.api import debug; debug()
# return condition_jump.attr < condition_jump2.off2int() return condition_jump.attr < condition_jump2.off2int()
return False return False
elif lhs == "ifelsestmt" and rule[1][2] == "jump_forward_else": elif lhs == "ifelsestmt" and rule[1][2] == "jump_forward_else":
last = min(last, len(tokens)-1) last = min(last, len(tokens)-1)

View File

@@ -153,6 +153,16 @@ class Python36Parser(Python35Parser):
""" """
# Some of this is duplicated from parse37. Eventually we'll probably rebase from
# that and then we can remove this.
def p_37conditionals(self, args):
"""
expr ::= conditional37
conditional37 ::= expr expr jf_cfs expr COME_FROM
jf_cfs ::= JUMP_FORWARD _come_froms
ifelsestmt ::= testexpr c_stmts_opt jf_cfs else_suite opt_come_from_except
"""
def customize_grammar_rules(self, tokens, customize): def customize_grammar_rules(self, tokens, customize):
# self.remove_rules(""" # self.remove_rules("""
# """) # """)

View File

@@ -620,6 +620,8 @@ class Python37Parser(Python37BaseParser):
def p_37conditionals(self, args): def p_37conditionals(self, args):
""" """
expr ::= conditional37
conditional37 ::= expr expr jf_cfs expr COME_FROM
jf_cfs ::= JUMP_FORWARD _come_froms jf_cfs ::= JUMP_FORWARD _come_froms
ifelsestmt ::= testexpr c_stmts_opt jf_cfs else_suite opt_come_from_except ifelsestmt ::= testexpr c_stmts_opt jf_cfs else_suite opt_come_from_except

View File

@@ -60,6 +60,12 @@ def customize_for_version36(self, version):
'call_ex' : ( 'call_ex' : (
'%c(%p)', '%c(%p)',
(0, 'expr'), (1, 100)), (0, 'expr'), (1, 100)),
# This comes from 3.7. Eventually we will rebase from 3.7
# and then this can go away
"conditional37": ( "%p if %c else %c",
(1, 'expr', 27), 0, 3 ),
'store_annotation': ( 'store_annotation': (
'%[1]{pattr}: %c', '%[1]{pattr}: %c',
0 0

View File

@@ -120,6 +120,9 @@ def customize_for_version37(self, version):
(0, 19), (0, 19),
(6, 19), (6, 19),
), ),
'conditional37': ( '%p if %c else %c',
(1, 'expr', 27), 0, 3 ),
"except_return": ("%|except:\n%+%c%-", 3), "except_return": ("%|except:\n%+%c%-", 3),
"if_exp_37a": ( "if_exp_37a": (
"%p if %p else %p", "%p if %p else %p",