aboutsummaryrefslogtreecommitdiff
path: root/py/parse.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2020-09-30 23:34:42 +1000
committerDamien George <damien@micropython.org>2020-10-01 15:26:43 +1000
commit843dcd4f8515c62b32b4b25dc3b01fba107622e2 (patch)
treeea114c703e6a1a4361bfb103e4afa68c8b14aaca /py/parse.c
parentd4b61b00172ccc231307e3ef33f66f28cb6b051f (diff)
py/parse: Expose rule-name printing as MICROPY_DEBUG_PARSE_RULE_NAME.
So it can be enabled without modifying the source. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/parse.c')
-rw-r--r--py/parse.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/py/parse.c b/py/parse.c
index 38cd215a9..da2f5e796 100644
--- a/py/parse.c
+++ b/py/parse.c
@@ -55,9 +55,6 @@
#define RULE_ARG_RULE (0x2000)
#define RULE_ARG_OPT_RULE (0x3000)
-// (un)comment to use rule names; for debugging
-// #define USE_RULE_NAME (1)
-
// *FORMAT-OFF*
enum {
@@ -192,7 +189,7 @@ static const size_t FIRST_RULE_WITH_OFFSET_ABOVE_255 =
#undef DEF_RULE_NC
0;
-#if USE_RULE_NAME
+#if MICROPY_DEBUG_PARSE_RULE_NAME
// Define an array of rule names corresponding to each rule
STATIC const char *const rule_name_table[] = {
#define DEF_RULE(rule, comp, kind, ...) #rule,
@@ -410,7 +407,7 @@ void mp_parse_node_print(const mp_print_t *print, mp_parse_node_t pn, size_t ind
#endif
} else {
size_t n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
- #if USE_RULE_NAME
+ #if MICROPY_DEBUG_PARSE_RULE_NAME
mp_printf(print, "%s(%u) (n=%u)\n", rule_name_table[MP_PARSE_NODE_STRUCT_KIND(pns)], (uint)MP_PARSE_NODE_STRUCT_KIND(pns), (uint)n);
#else
mp_printf(print, "rule(%u) (n=%u)\n", (uint)MP_PARSE_NODE_STRUCT_KIND(pns), (uint)n);