diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-19 11:48:48 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-19 11:48:48 +0000 |
commit | cbd2f7482c8bf457cc17da763859dbba6e03e2a2 (patch) | |
tree | 8d6badc4197fe0d5763d381dd97586176db9fbae /py/parse.c | |
parent | e02b2d43912d13d216936786e4b7a33918877418 (diff) | |
download | micropython-cbd2f7482c8bf457cc17da763859dbba6e03e2a2.tar.gz micropython-cbd2f7482c8bf457cc17da763859dbba6e03e2a2.zip |
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.
Diffstat (limited to 'py/parse.c')
-rw-r--r-- | py/parse.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/py/parse.c b/py/parse.c index fc74a5fa50..93d75424ac 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); } } */ |