aboutsummaryrefslogtreecommitdiff
path: root/py/parse.h
diff options
context:
space:
mode:
authorDamien George2015-02-07 18:33:58 +0000
committerDamien George2015-02-07 18:33:58 +0000
commit0bfc7638baa4c5a4a2351364ab770a188dcab302 (patch)
tree0127fcea13a875d37dd9cfa07dc6921bf387c578 /py/parse.h
parente1e359ff59d6bbf09441cc1f3965be63f1046182 (diff)
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.
Diffstat (limited to 'py/parse.h')
-rw-r--r--py/parse.h12
1 files changed, 3 insertions, 9 deletions
diff --git a/py/parse.h b/py/parse.h
index 4e7f2b9d1..ee0025a7b 100644
--- a/py/parse.h
+++ b/py/parse.h
@@ -90,14 +90,8 @@ typedef enum {
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__