aboutsummaryrefslogtreecommitdiff
path: root/compiler/lex.c
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/lex.c')
-rw-r--r--compiler/lex.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/compiler/lex.c b/compiler/lex.c
index e9cb65b..8255e11 100644
--- a/compiler/lex.c
+++ b/compiler/lex.c
@@ -34,13 +34,20 @@ unsigned char lex_name_length(char* input) {
return n;
}
-token_list* lex(char* input) {
+token_list* lex(token_list* list, char* input) {
if (input[0] == 0) {
return NULL;
}
- token_list* list = my_calloc(1, sizeof(token_list));
- token_list* first_list = list;
+ token_list* first_list;
+ if (list) {
+ first_list = list;
+ while (list->rest) list = list->rest;
+ list->rest = my_calloc(1, sizeof(token_list));
+ list = list->rest;
+ } else {
+ first_list = list = my_calloc(1, sizeof(token_list));
+ }
while (*input) {
list->elem.var = NULL;