From cbd2f7482c8bf457cc17da763859dbba6e03e2a2 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 19 Jan 2014 11:48:48 +0000 Subject: py: Add module/function/class name to exceptions. Exceptions know source file, line and block name. Also tidy up some debug printing functions and provide a global flag to enable/disable them. --- py/parse.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'py/parse.c') diff --git a/py/parse.c b/py/parse.c index fc74a5fa5..93d75424a 100644 --- a/py/parse.c +++ b/py/parse.c @@ -135,7 +135,8 @@ mp_parse_node_struct_t *parse_node_new_struct(int src_line, int rule_id, int num return pn; } -void mp_parse_node_show(mp_parse_node_t pn, int indent) { +#if MICROPY_DEBUG_PRINTERS +void mp_parse_node_print(mp_parse_node_t pn, int indent) { if (MP_PARSE_NODE_IS_STRUCT(pn)) { printf("[% 4d] ", (int)((mp_parse_node_struct_t*)pn)->source_line); } else { @@ -167,16 +168,17 @@ void mp_parse_node_show(mp_parse_node_t pn, int indent) { printf("rule(%u) (n=%d)\n", (uint)MP_PARSE_NODE_STRUCT_KIND(pns2), n); #endif for (int i = 0; i < n; i++) { - mp_parse_node_show(pns2->nodes[i], indent + 2); + mp_parse_node_print(pns2->nodes[i], indent + 2); } } } +#endif // MICROPY_DEBUG_PRINTERS /* static void result_stack_show(parser_t *parser) { printf("result stack, most recent first\n"); for (int i = parser->result_stack_top - 1; i >= 0; i--) { - mp_parse_node_show(parser->result_stack[i], 0); + mp_parse_node_print(parser->result_stack[i], 0); } } */ -- cgit v1.2.3