123456789101112131415161718192021222324252627282930313233343536 |
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include "vm.h"
- #include "lexer.h"
-
- static const char* strs[] =
- {
- "whitespace",
- "identifier",
- "keyword",
- "operator",
- "separator",
- "integer",
- "string",
- "function_start",
- "function_end",
- "expression_start",
- "expression_end"
- };
-
- int main(int argc, char** argv)
- {
- lexer_tokens* tokens = lexer_analyze("int foo = \"hi there\"");
- size_t i;
- for (i = 0; i < tokens->length; ++i)
- {
- lexer_token pair = tokens->pairs[i];
- char* str = malloc(pair.len);
- memcpy(str, pair.str, pair.len);
- str[pair.len - 1] = '\0';
-
- printf("class: %s, str: %s\n", strs[pair.tokenClass], str);
- }
- }
|