summaryrefslogtreecommitdiffstatshomepage
path: root/py/parsehelper.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-12-05 19:35:18 +0000
committerDamien George <damien.p.george@gmail.com>2014-12-05 19:35:18 +0000
commita4c52c5a3d19b5527023fedfaae96cb717d03802 (patch)
tree2974180c7270bd13df2e5f080cf951a22c559baa /py/parsehelper.c
parent41c07d5b8063d752d2b3e41056bdee3615b54635 (diff)
downloadmicropython-a4c52c5a3d19b5527023fedfaae96cb717d03802.tar.gz
micropython-a4c52c5a3d19b5527023fedfaae96cb717d03802.zip
py: Optimise lexer by exposing lexer type.
mp_lexer_t type is exposed, mp_token_t type is removed, and simple lexer functions (like checking current token kind) are now inlined. This saves 784 bytes ROM on 32-bit unix, 348 bytes on stmhal, and 460 bytes on bare-arm. It also saves a tiny bit of RAM since mp_lexer_t is a bit smaller. Also will run a bit more efficiently.
Diffstat (limited to 'py/parsehelper.c')
-rw-r--r--py/parsehelper.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/py/parsehelper.c b/py/parsehelper.c
index a6c54e8fc7..f304710673 100644
--- a/py/parsehelper.c
+++ b/py/parsehelper.c
@@ -43,7 +43,7 @@
#define STR_INVALID_SYNTAX "invalid syntax"
void mp_parse_show_exception(mp_lexer_t *lex, mp_parse_error_kind_t parse_error_kind) {
- printf(" File \"%s\", line " UINT_FMT ", column " UINT_FMT "\n", qstr_str(mp_lexer_source_name(lex)), mp_lexer_cur(lex)->src_line, mp_lexer_cur(lex)->src_column);
+ printf(" File \"%s\", line " UINT_FMT ", column " UINT_FMT "\n", qstr_str(lex->source_name), lex->tok_line, lex->tok_column);
switch (parse_error_kind) {
case MP_PARSE_ERROR_MEMORY:
printf("MemoryError: %s\n", STR_MEMORY);
@@ -88,7 +88,7 @@ mp_obj_t mp_parse_make_exception(mp_lexer_t *lex, mp_parse_error_kind_t parse_er
// add traceback to give info about file name and location
// we don't have a 'block' name, so just pass the NULL qstr to indicate this
- mp_obj_exception_add_traceback(exc, mp_lexer_source_name(lex), mp_lexer_cur(lex)->src_line, MP_QSTR_NULL);
+ mp_obj_exception_add_traceback(exc, lex->source_name, lex->tok_line, MP_QSTR_NULL);
return exc;
}