diff options
author | Damien George <damien.p.george@gmail.com> | 2014-02-15 16:10:44 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-02-15 16:10:44 +0000 |
commit | c5966128c7c8a768f6726f299d85d5daef6bed48 (patch) | |
tree | fea6913ae43d722078a837d8c7fd9a1e459f3891 /py/lexer.c | |
parent | a71c83a1d1aeca1d81d7c673929f8e836dec131e (diff) |
Implement proper exception type hierarchy.
Each built-in exception is now a type, with base type BaseException.
C exceptions are created by passing a pointer to the exception type to
make an instance of. When raising an exception from the VM, an
instance is created automatically if an exception type is raised (as
opposed to an exception instance).
Exception matching (RT_BINARY_OP_EXCEPTION_MATCH) is now proper.
Handling of parse error changed to match new exceptions.
mp_const_type renamed to mp_type_type for consistency.
Diffstat (limited to 'py/lexer.c')
-rw-r--r-- | py/lexer.c | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/py/lexer.c b/py/lexer.c index c3c992aee..be0b1883c 100644 --- a/py/lexer.c +++ b/py/lexer.c @@ -51,6 +51,7 @@ bool str_strn_equal(const char *str, const char *strn, int len) { return i == len && *str == 0; } +#ifdef MICROPY_DEBUG_PRINTERS void mp_token_show(const mp_token_t *tok) { printf("(%d:%d) kind:%d str:%p len:%d", tok->src_line, tok->src_column, tok->kind, tok->str, tok->len); if (tok->str != NULL && tok->len > 0) { @@ -69,6 +70,7 @@ void mp_token_show(const mp_token_t *tok) { } printf("\n"); } +#endif #define CUR_CHAR(lex) ((lex)->chr0) @@ -711,35 +713,3 @@ const mp_token_t *mp_lexer_cur(const mp_lexer_t *lex) { bool mp_lexer_is_kind(mp_lexer_t *lex, mp_token_kind_t kind) { return lex->tok_cur.kind == kind; } - -/* -bool mp_lexer_is_str(mp_lexer_t *lex, const char *str) { - return mp_token_is_str(&lex->tok_cur, str); -} - -bool mp_lexer_opt_kind(mp_lexer_t *lex, mp_token_kind_t kind) { - if (mp_lexer_is_kind(lex, kind)) { - mp_lexer_to_next(lex); - return true; - } - return false; -} - -bool mp_lexer_opt_str(mp_lexer_t *lex, const char *str) { - if (mp_lexer_is_str(lex, str)) { - mp_lexer_to_next(lex); - return true; - } - return false; -} -*/ - -bool mp_lexer_show_error_pythonic_prefix(mp_lexer_t *lex) { - printf(" File \"%s\", line %d column %d\n", qstr_str(lex->source_name), lex->tok_cur.src_line, lex->tok_cur.src_column); - return false; -} - -bool mp_lexer_show_error_pythonic(mp_lexer_t *lex, const char *msg) { - printf(" File \"%s\", line %d column %d\n%s\n", qstr_str(lex->source_name), lex->tok_cur.src_line, lex->tok_cur.src_column, msg); - return false; -} |