py: Move constant folding from compiler to parser.
It makes much more sense to do constant folding in the parser while the
parse tree is being built. This eliminates the need to create parse
nodes that will just be folded away. The code is slightly simpler and a
bit smaller as well.
Constant folding now has a configuration option,
MICROPY_COMP_CONST_FOLDING, which is enabled by default.
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 4b986ee..500af5e 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -215,6 +215,11 @@
/*****************************************************************************/
/* Compiler configuration */
+// Whether to enable constant folding; eg 1+2 rewritten as 3
+#ifndef MICROPY_COMP_CONST_FOLDING
+#define MICROPY_COMP_CONST_FOLDING (1)
+#endif
+
// Whether to enable lookup of constants in modules; eg module.CONST
#ifndef MICROPY_COMP_MODULE_CONST
#define MICROPY_COMP_MODULE_CONST (0)