diff options
author | Damien George <damien.p.george@gmail.com> | 2014-05-06 21:44:11 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-05-06 21:44:11 +0100 |
commit | 93afa230a42592023ba39951a48109d098f03bbe (patch) | |
tree | 41d58fb61fefed26ef2598ee2c52617144ac4ab7 /py | |
parent | c53b408f28942bfc5b64fee86ac89a339dc06e3f (diff) | |
download | micropython-93afa230a42592023ba39951a48109d098f03bbe.tar.gz micropython-93afa230a42592023ba39951a48109d098f03bbe.zip |
py, parser: Add commented-out code to discard doc strings.
Doesn't help with RAM reduction because doc strings are interned as soon
as they are encountered, which is too soon to do any optimisations on
them.
Diffstat (limited to 'py')
-rw-r--r-- | py/parse.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/py/parse.c b/py/parse.c index f512eea3b2..0ec336cd1a 100644 --- a/py/parse.c +++ b/py/parse.c @@ -511,6 +511,20 @@ mp_parse_node_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind, mp_p } } +#if 0 && !MICROPY_ENABLE_DOC_STRING + // this code discards lonely statement, such as doc strings + // problem is that doc strings have already been interned, so this doesn't really help reduce RAM usage + if (input_kind != MP_PARSE_SINGLE_INPUT && rule->rule_id == RULE_expr_stmt && peek_result(parser, 0) == MP_PARSE_NODE_NULL) { + mp_parse_node_t p = peek_result(parser, 1); + if (MP_PARSE_NODE_IS_LEAF(p) && !MP_PARSE_NODE_IS_ID(p)) { + pop_result(parser); + pop_result(parser); + push_result_rule(parser, rule_src_line, rules[RULE_pass_stmt], 0); + break; + } + } +#endif + // always emit these rules, even if they have only 1 argument if (rule->rule_id == RULE_expr_stmt || rule->rule_id == RULE_yield_stmt) { emit_rule = true; |