#include "lexer.h" #include #include #include int main(void) { char text[] = "abc 123 0xFF 0b101 3.14 'a' '\\n' \"hello\" \"world\\\"\\n\" if else /* /* while */ */ " "while break (){}[].,:; += -= *= /= %= == != <= >= + - * / % % = ! < >"; printf("text = \"%s\"\n", text); Lexer lexer; lexer_create(&lexer, text, strlen(text)); printf("tokens = [\n"); Token token = lexer_next(&lexer); while (token.type != TokenTypeEof) { char* stringified = token_to_string(&token, text); printf(" %s\n", stringified); free(stringified); token = lexer_next(&lexer); } printf("]\n"); }