py: Protect mp_parse and mp_compile with nlr push/pop block.
To enable parsing constants more efficiently, mp_parse should be allowed
to raise an exception, and mp_compile can already raise a MemoryError.
So these functions need to be protected by an nlr push/pop block.
This patch adds that feature in all places. This allows to simplify how
mp_parse and mp_compile are called: they now raise an exception if they
have an error and so explicit checking is not needed anymore.
diff --git a/py/parse.h b/py/parse.h
index 4e7f2b9..ee0025a 100644
--- a/py/parse.h
+++ b/py/parse.h
@@ -90,14 +90,8 @@
MP_PARSE_EVAL_INPUT,
} mp_parse_input_kind_t;
-typedef enum {
- MP_PARSE_ERROR_MEMORY,
- MP_PARSE_ERROR_UNEXPECTED_INDENT,
- MP_PARSE_ERROR_UNMATCHED_UNINDENT,
- MP_PARSE_ERROR_INVALID_SYNTAX,
-} mp_parse_error_kind_t;
-
-// returns MP_PARSE_NODE_NULL on error, and then parse_error_kind_out is valid
-mp_parse_node_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind, mp_parse_error_kind_t *parse_error_kind_out);
+// the parser will raise an exception if an error occurred
+// the parser will free the lexer before it returns
+mp_parse_node_t mp_parse(struct _mp_lexer_t *lex, mp_parse_input_kind_t input_kind);
#endif // __MICROPY_INCLUDED_PY_PARSE_H__