More grammar isolation. narrow custom rules...

Specifically: _mklambda with load_closure is Python2 only
Add classdefdeco2 rule only when we have seen a LOAD_BUILD_CLASS
This commit is contained in:
rocky
2017-11-17 00:51:03 -05:00
parent 934df7b5c4
commit 58ee49159e
5 changed files with 18 additions and 12 deletions

View File

@@ -98,8 +98,7 @@ class Python36Parser(Python35Parser):
""" % (fstring_expr_or_str_n, fstring_expr_or_str_n, "fstring_expr_or_str " * v)
self.add_unique_doc_rules(rules_str, customize)
def custom_classfunc_rule(self, opname, token, customize):
def custom_classfunc_rule(self, opname, token, customize, seen_LOAD_BUILD_CLASS):
if opname.startswith('CALL_FUNCTION_KW'):
values = 'expr ' * token.attr
rule = 'call_function ::= expr kwargs_only_36 {token.kind}'.format(**locals())
@@ -107,7 +106,8 @@ class Python36Parser(Python35Parser):
rule = 'kwargs_only_36 ::= {values} LOAD_CONST'.format(**locals())
self.add_unique_rule(rule, token.kind, token.attr, customize)
else:
super(Python36Parser, self).custom_classfunc_rule(opname, token, customize)
super(Python36Parser, self).custom_classfunc_rule(opname, token,
customize, seen_LOAD_BUILD_CLASS)
class Python36ParserSingle(Python36Parser, PythonParserSingle):