summaryrefslogtreecommitdiffstatshomepage
path: root/py/lexer.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-28 14:07:11 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-28 14:07:11 +0000
commit16677ce311fd70162cc9f7cfe2ab97461df765fc (patch)
treeb6c76957d31774814f3a8203ab9035f910107f74 /py/lexer.c
parent0ecd5988a24aaa72415d83961327fc034cfe64a2 (diff)
downloadmicropython-16677ce311fd70162cc9f7cfe2ab97461df765fc.tar.gz
micropython-16677ce311fd70162cc9f7cfe2ab97461df765fc.zip
py: Be more precise about unicode type and disabled unicode behaviour.
Diffstat (limited to 'py/lexer.c')
-rw-r--r--py/lexer.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/py/lexer.c b/py/lexer.c
index 13c3a3e9b5..8a8875ed51 100644
--- a/py/lexer.c
+++ b/py/lexer.c
@@ -492,11 +492,19 @@ STATIC void mp_lexer_next_token_into(mp_lexer_t *lex, bool first_token) {
}
}
if (c != MP_LEXER_EOF) {
+ #if MICROPY_PY_BUILTINS_STR_UNICODE
if (c < 0x110000 && !is_bytes) {
vstr_add_char(&lex->vstr, c);
} else if (c < 0x100 && is_bytes) {
vstr_add_byte(&lex->vstr, c);
- } else {
+ }
+ #else
+ // without unicode everything is just added as an 8-bit byte
+ if (c < 0x100) {
+ vstr_add_byte(&lex->vstr, c);
+ }
+ #endif
+ else {
assert(!"TODO: Throw an error, invalid escape code probably");
}
}