summaryrefslogtreecommitdiffstatshomepage
path: root/py/grammar.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-12-27 17:07:16 +0000
committerDamien George <damien.p.george@gmail.com>2014-12-27 17:33:30 +0000
commite37dcaafb43c1246ab55d79ebb8889a61f280533 (patch)
tree79b86304793ac4d2396c7bc8a24209459e3eaf1a /py/grammar.h
parent3b74c91684e6dfc785bf33ba03e520470f59059e (diff)
downloadmicropython-e37dcaafb43c1246ab55d79ebb8889a61f280533.tar.gz
micropython-e37dcaafb43c1246ab55d79ebb8889a61f280533.zip
py: Allow to properly disable builtin "set" object.
This patch makes MICROPY_PY_BUILTINS_SET compile-time option fully disable the builtin set object (when set to 0). This includes removing set constructor/comprehension from the grammar, the compiler and the emitters. Now, enabling set costs 8168 bytes on unix x64, and 3576 bytes on stmhal.
Diffstat (limited to 'py/grammar.h')
-rw-r--r--py/grammar.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/py/grammar.h b/py/grammar.h
index 15c4e98109..1df0e938ec 100644
--- a/py/grammar.h
+++ b/py/grammar.h
@@ -287,8 +287,12 @@ DEF_RULE(exprlist_2, nc, or(2), rule(star_expr), rule(expr))
DEF_RULE(testlist, c(generic_tuple), list_with_end, rule(test), tok(DEL_COMMA))
// TODO dictorsetmaker lets through more than is allowed
DEF_RULE(dictorsetmaker, nc, and(2), rule(dictorsetmaker_item), opt_rule(dictorsetmaker_tail))
+#if MICROPY_PY_BUILTINS_SET
DEF_RULE(dictorsetmaker_item, c(dictorsetmaker_item), and(2), rule(test), opt_rule(dictorsetmaker_colon))
DEF_RULE(dictorsetmaker_colon, nc, ident | and(2), tok(DEL_COLON), rule(test))
+#else
+DEF_RULE(dictorsetmaker_item, c(dictorsetmaker_item), and(3), rule(test), tok(DEL_COLON), rule(test))
+#endif
DEF_RULE(dictorsetmaker_tail, nc, or(2), rule(comp_for), rule(dictorsetmaker_list))
DEF_RULE(dictorsetmaker_list, nc, and(2), tok(DEL_COMMA), opt_rule(dictorsetmaker_list2))
DEF_RULE(dictorsetmaker_list2, nc, list_with_end, rule(dictorsetmaker_item), tok(DEL_COMMA))