diff options
author | Camil Staps | 2016-08-26 00:46:55 +0200 |
---|---|---|
committer | Camil Staps | 2016-08-26 00:46:55 +0200 |
commit | 00e2c70b01f28c9b00ec3d5096895a387676774d (patch) | |
tree | 8ee65ec944e5cdd79d517c723e6b506fa7ee43a1 /interpreter/lex.c | |
parent | Added tup example (diff) |
Linking C functions
Diffstat (limited to 'interpreter/lex.c')
-rw-r--r-- | interpreter/lex.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/interpreter/lex.c b/interpreter/lex.c index b238b5e..bd64349 100644 --- a/interpreter/lex.c +++ b/interpreter/lex.c @@ -49,7 +49,7 @@ token_list* lex(token_list* list, char* input) { } while (*input) { - unsigned proceed_to_next_token = 1; + unsigned create_new_token = 1; list->elem.var = NULL; @@ -62,6 +62,13 @@ token_list* lex(token_list* list, char* input) { case ']': list->elem.kind = TOKEN_CLOSE_SQ; break; case '=': list->elem.kind = TOKEN_EQUALS; break; case ',': list->elem.kind = TOKEN_COMMA; break; + case 'c': + if (input[1] == 'o' && input[2] == 'd' && input[3] == 'e' && + is_space_char(input[4])) { + list->elem.kind = TOKEN_CODE; + input += 4; + } + break; default: if (is_int_char(*input)) { @@ -81,7 +88,7 @@ token_list* lex(token_list* list, char* input) { strncpy(list->elem.var, input, len); input += len - 1; } else if (is_space_char(*input)) { - proceed_to_next_token = 0; + create_new_token = 0; } else { free_token_list(first_list); my_free(first_list); @@ -91,7 +98,7 @@ token_list* lex(token_list* list, char* input) { input++; - if (*input && proceed_to_next_token) { + if (*input && create_new_token) { list->rest = my_calloc(1, sizeof(token_list)); list = list->rest; } |