Merge branch 'master' into python-2.4

This commit is contained in:
rocky
2017-11-28 09:22:24 -05:00
7 changed files with 18 additions and 6 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,5 @@
# Python 3.6, uses rule:
# genexpr ::= load_closure load_genexpr LOAD_CONST
# MAKE_FUNCTION_8 expr GET_ITER CALL_FUNCTION_1
def __sub__(self, other): # SList()-other
return self.__class__(i for i in self if i not in other)

View File

@@ -49,16 +49,17 @@ class Python24Parser(Python25Parser):
# Python 2.6, 2.7 and 3.3+ use kv3 # Python 2.6, 2.7 and 3.3+ use kv3
# Python 2.3- use kv # Python 2.3- use kv
kvlist ::= kvlist kv2 kvlist ::= kvlist kv2
kv2 ::= DUP_TOP expr expr ROT_THREE STORE_SUBSCR kv2 ::= DUP_TOP expr expr ROT_THREE STORE_SUBSCR
''' '''
def add_custom_rules(self, tokens, customize): def add_custom_rules(self, tokens, customize):
self.remove_rules(""" self.remove_rules("""
kvlist ::= kvlist kv3 gen_comp_body ::= expr YIELD_VALUE POP_TOP
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM kvlist ::= kvlist kv3
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK COME_FROM while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM
while1stmt ::= SETUP_LOOP return_stmts COME_FROM while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK COME_FROM
whilestmt ::= SETUP_LOOP testexpr return_stmts POP_BLOCK COME_FROM while1stmt ::= SETUP_LOOP return_stmts COME_FROM
whilestmt ::= SETUP_LOOP testexpr return_stmts POP_BLOCK COME_FROM
""") """)
super(Python24Parser, self).add_custom_rules(tokens, customize) super(Python24Parser, self).add_custom_rules(tokens, customize)
if self.version == 2.4: if self.version == 2.4:

View File

@@ -887,6 +887,12 @@ class Python3Parser(PythonParser):
'LOAD_CONST ' * 2, 'LOAD_CONST ' * 2,
opname)) opname))
self.add_unique_rule(rule, opname, token.attr, customize) self.add_unique_rule(rule, opname, token.attr, customize)
if has_get_iter_call_function1:
rule_pat = ("genexpr ::= %sload_closure load_genexpr %%s%s expr "
"GET_ITER CALL_FUNCTION_1" % ('pos_arg '* args_pos, opname))
self.add_make_function_rule(rule_pat, opname, token.attr, customize)
rule_pat = ('mklambda ::= %s%sLOAD_LAMBDA %%s%s' % rule_pat = ('mklambda ::= %s%sLOAD_LAMBDA %%s%s' %
(('pos_arg '* args_pos), (('pos_arg '* args_pos),
('kwarg '* args_kw), ('kwarg '* args_kw),