summaryrefslogtreecommitdiffstatshomepage
path: root/unix/main.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-15 21:23:31 +0000
committerDamien George <damien.p.george@gmail.com>2014-01-15 21:23:31 +0000
commit9528cd66d7c94d7376884a53c2080b29e9bc3a0a (patch)
tree7c3ad5d4af03b7760f7c3be4ae1a1e9555113324 /unix/main.c
parent24224d7c72e1d6572ef0d24f08eb882dcac8dc50 (diff)
downloadmicropython-9528cd66d7c94d7376884a53c2080b29e9bc3a0a.tar.gz
micropython-9528cd66d7c94d7376884a53c2080b29e9bc3a0a.zip
Convert parse errors to exceptions.
Parser no longer prints an error, but instead returns an exception ID and message.
Diffstat (limited to 'unix/main.c')
-rw-r--r--unix/main.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/unix/main.c b/unix/main.c
index 15a4000ab5..d74247e59b 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -37,14 +37,20 @@ static void execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind
return;
}
- mp_parse_node_t pn = mp_parse(lex, input_kind);
- mp_lexer_free(lex);
+ qstr parse_exc_id;
+ const char *parse_exc_msg;
+ mp_parse_node_t pn = mp_parse(lex, input_kind, &parse_exc_id, &parse_exc_msg);
if (pn == MP_PARSE_NODE_NULL) {
// parse error
+ mp_lexer_show_error_pythonic_prefix(lex);
+ printf("%s: %s\n", qstr_str(parse_exc_id), parse_exc_msg);
+ mp_lexer_free(lex);
return;
}
+ mp_lexer_free(lex);
+
//printf("----------------\n");
//parse_node_show(pn, 0);
//printf("----------------\n");