diff options
author | Damien George <damien.p.george@gmail.com> | 2014-07-30 11:46:05 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-07-30 11:46:05 +0100 |
commit | 94fbe9711a1179b3c4d0eb2e9822787d90231719 (patch) | |
tree | 8a925d2f40d088c8f8d2d0919212e64cb4426a4b /py/lexer.h | |
parent | 07133415d26d740b866f4542222bb92c06c863d1 (diff) | |
download | micropython-94fbe9711a1179b3c4d0eb2e9822787d90231719.tar.gz micropython-94fbe9711a1179b3c4d0eb2e9822787d90231719.zip |
py: Change lexer stream API to return bytes not chars.
Lexer is now 8-bit clean inside strings.
Diffstat (limited to 'py/lexer.h')
-rw-r--r-- | py/lexer.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/py/lexer.h b/py/lexer.h index 3f5176be10..d70735f6d7 100644 --- a/py/lexer.h +++ b/py/lexer.h @@ -139,18 +139,18 @@ typedef struct _mp_token_t { mp_uint_t len; // (byte) length of string of token } mp_token_t; -// the next-char function must return the next character in the stream -// it must return MP_LEXER_CHAR_EOF if end of stream -// it can be called again after returning MP_LEXER_CHAR_EOF, and in that case must return MP_LEXER_CHAR_EOF -#define MP_LEXER_CHAR_EOF (-1) -typedef unichar (*mp_lexer_stream_next_char_t)(void*); +// the next-byte function must return the next byte in the stream +// it must return MP_LEXER_EOF if end of stream +// it can be called again after returning MP_LEXER_EOF, and in that case must return MP_LEXER_EOF +#define MP_LEXER_EOF (-1) +typedef mp_uint_t (*mp_lexer_stream_next_byte_t)(void*); typedef void (*mp_lexer_stream_close_t)(void*); typedef struct _mp_lexer_t mp_lexer_t; void mp_token_show(const mp_token_t *tok); -mp_lexer_t *mp_lexer_new(qstr src_name, void *stream_data, mp_lexer_stream_next_char_t stream_next_char, mp_lexer_stream_close_t stream_close); +mp_lexer_t *mp_lexer_new(qstr src_name, void *stream_data, mp_lexer_stream_next_byte_t stream_next_byte, mp_lexer_stream_close_t stream_close); mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, mp_uint_t len, mp_uint_t free_len); void mp_lexer_free(mp_lexer_t *lex); |