Convert parse errors to exceptions.

Parser no longer prints an error, but instead returns an exception ID
and message.
This commit is contained in:
Damien George
2014-01-15 21:23:31 +00:00
parent 24224d7c72
commit 9528cd66d7
9 changed files with 73 additions and 41 deletions

View File

@@ -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");