From eacbd7aeba3bdd634b56af544e40da87779f4a95 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 13 Apr 2016 15:21:47 +0100 Subject: py: Fix constant folding and inline-asm to work with new async grammar. --- py/parse.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'py/parse.c') diff --git a/py/parse.c b/py/parse.c index b57e82d45..ce2dcb62c 100644 --- a/py/parse.c +++ b/py/parse.c @@ -563,11 +563,10 @@ STATIC bool fold_constants(parser_t *parser, const rule_t *rule, size_t num_args // this node is of the form = mp_parse_node_t pn0 = peek_result(parser, 1); if (MP_PARSE_NODE_IS_ID(pn0) - && MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_power) + && MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_atom_expr_normal) && MP_PARSE_NODE_IS_ID(((mp_parse_node_struct_t*)pn1)->nodes[0]) && MP_PARSE_NODE_LEAF_ARG(((mp_parse_node_struct_t*)pn1)->nodes[0]) == MP_QSTR_const && MP_PARSE_NODE_IS_STRUCT_KIND(((mp_parse_node_struct_t*)pn1)->nodes[1], RULE_trailer_paren) - && MP_PARSE_NODE_IS_NULL(((mp_parse_node_struct_t*)pn1)->nodes[2]) ) { // code to assign dynamic constants: id = const(value) @@ -599,13 +598,11 @@ STATIC bool fold_constants(parser_t *parser, const rule_t *rule, size_t num_args #endif #if MICROPY_COMP_MODULE_CONST - } else if (rule->rule_id == RULE_power) { - mp_parse_node_t pn0 = peek_result(parser, 2); - mp_parse_node_t pn1 = peek_result(parser, 1); - mp_parse_node_t pn2 = peek_result(parser, 0); + } else if (rule->rule_id == RULE_atom_expr_normal) { + mp_parse_node_t pn0 = peek_result(parser, 1); + mp_parse_node_t pn1 = peek_result(parser, 0); if (!(MP_PARSE_NODE_IS_ID(pn0) - && MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_trailer_period) - && MP_PARSE_NODE_IS_NULL(pn2))) { + && MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_trailer_period))) { return false; } // id1.id2 -- cgit v1.2.3