wacc/main.c
2023-02-18 00:07:24 +01:00

32 lines
864 B
C

#include "lexer.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char text[]
= "abc 123 123.. 0xFF 0b101 .5 1. 3.14 'a' '\\n' \"hello\" "
"\"world\\\"\\n\" if else /* /* while */ */ "
"while for in // in \n break let match false true not and or fn "
"return mut "
"defer (){}[],: :: ::< ; & _ . .. ..= ..< += -= *= /= %= == != <= >= "
"+ - * / % "
"% = ! < >";
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");
}