parser base working
This commit is contained in:
5
lexer.c
5
lexer.c
@@ -158,6 +158,7 @@ size_t read_from_tok(Token *tok, const char *input, size_t cursor) {
|
||||
}
|
||||
buf[i] = '\0';
|
||||
token_push(tok, TOKEN_STRING, buf, BHV_STRING, cursor - start);
|
||||
//refactor into separate function to use in parsing functions and definitions
|
||||
} else {
|
||||
buf[0] = input[cursor];
|
||||
buf[1] = '\0';
|
||||
@@ -196,9 +197,9 @@ Token tokenize_all(const char *input) {
|
||||
|
||||
|
||||
int main() {
|
||||
char *expr = "1 + 2 * 3";
|
||||
char *input = "1 + 2 * 3 print";
|
||||
|
||||
Token tokens = tokenize_all(expr);
|
||||
Token tokens = tokenize_all(input);
|
||||
|
||||
for (size_t i = 0; i < tokens.size; i++) {
|
||||
printf("[%s] \"%s\"\n", token_type_to_string(tokens.type[i]), tokens.text[i]);
|
||||
|
||||
Reference in New Issue
Block a user