diff options
Diffstat (limited to 'stm')
-rw-r--r-- | stm/Makefile | 1 | ||||
-rw-r--r-- | stm/lexerfatfs.h | 2 | ||||
-rw-r--r-- | stm/lexerstr.c | 28 | ||||
-rw-r--r-- | stm/lexerstr.h | 8 | ||||
-rw-r--r-- | stm/main.c | 7 |
5 files changed, 3 insertions, 43 deletions
diff --git a/stm/Makefile b/stm/Makefile index 478441e04b..725eb4c30a 100644 --- a/stm/Makefile +++ b/stm/Makefile @@ -30,7 +30,6 @@ SRC_C = \ string0.c \ malloc0.c \ systick.c \ - lexerstr.c \ lexerfatfs.c \ led.c \ lcd.c \ diff --git a/stm/lexerfatfs.h b/stm/lexerfatfs.h index 2b41ed136b..f1fe5ad485 100644 --- a/stm/lexerfatfs.h +++ b/stm/lexerfatfs.h @@ -1,4 +1,4 @@ -typedef struct _py_lexer_file_buf_t { +typedef struct _mp_lexer_file_buf_t { FIL fp; char buf[20]; uint16_t len; diff --git a/stm/lexerstr.c b/stm/lexerstr.c deleted file mode 100644 index cc6be1d1ed..0000000000 --- a/stm/lexerstr.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <stdint.h> -#include <stdio.h> - -#include "misc.h" -#include "lexer.h" -#include "lexerstr.h" - -unichar str_buf_next_char(mp_lexer_str_buf_t *sb) { - if (sb->src_cur < sb->src_end) { - return *sb->src_cur++; - } else { - return MP_LEXER_CHAR_EOF; - } -} - -void str_buf_free(mp_lexer_str_buf_t *sb) { - if (sb->free) { - m_del(char, (char*)sb->src_beg, 0 /* don't know allocated size of src */); - } -} - -mp_lexer_t *mp_lexer_new_from_str_len(const char *src_name, const char *str, uint len, bool free_str, mp_lexer_str_buf_t *sb) { - sb->free = free_str; - sb->src_beg = str; - sb->src_cur = str; - sb->src_end = str + len; - return mp_lexer_new(src_name, sb, (mp_lexer_stream_next_char_t)str_buf_next_char, (mp_lexer_stream_close_t)str_buf_free); -} diff --git a/stm/lexerstr.h b/stm/lexerstr.h deleted file mode 100644 index 961a70ada4..0000000000 --- a/stm/lexerstr.h +++ /dev/null @@ -1,8 +0,0 @@ -typedef struct _py_lexer_str_buf_t { - bool free; // free src_beg when done - const char *src_beg; // beginning of source - const char *src_cur; // current location in source - const char *src_end; // end (exclusive) of source -} mp_lexer_str_buf_t; - -mp_lexer_t *mp_lexer_new_from_str_len(const char *src_name, const char *str, uint len, bool free_str, mp_lexer_str_buf_t *sb); diff --git a/stm/main.c b/stm/main.c index a2f3bc7f03..0ad638cde1 100644 --- a/stm/main.c +++ b/stm/main.c @@ -19,7 +19,6 @@ #include "nlr.h" #include "misc.h" #include "lexer.h" -#include "lexerstr.h" #include "lexerfatfs.h" #include "parse.h" #include "obj.h" @@ -432,8 +431,7 @@ void do_repl(void) { } } - mp_lexer_str_buf_t sb; - mp_lexer_t *lex = mp_lexer_new_from_str_len("<stdin>", vstr_str(&line), vstr_len(&line), false, &sb); + mp_lexer_t *lex = mp_lexer_new_from_str_len("<stdin>", vstr_str(&line), vstr_len(&line), 0); mp_parse_node_t pn = mp_parse(lex, MP_PARSE_SINGLE_INPUT); mp_lexer_free(lex); @@ -1059,8 +1057,7 @@ soft_reset: " pass\n" "f()\n"; - mp_lexer_str_buf_t mp_lexer_str_buf; - mp_lexer_t *lex = mp_lexer_new_from_str_len("<stdin>", pysrc, strlen(pysrc), false, &mp_lexer_str_buf); + mp_lexer_t *lex = mp_lexer_new_from_str_len("<stdin>", pysrc, strlen(pysrc), 0); // nalloc=1740;6340;6836 -> 140;4600;496 bytes for lexer, parser, compiler printf("lex; al=%u\n", m_get_total_bytes_allocated()); |