25 lines
556 B
C
25 lines
556 B
C
// test_lex.c -- Dump lexer tokens
|
|
//
|
|
// Build: make -C dvxbasic tests
|
|
|
|
#include "compiler/lexer.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
int main(void) {
|
|
const char *src = "PRINT \"Hello, World!\"\n";
|
|
BasLexerT lex;
|
|
basLexerInit(&lex, src, (int32_t)strlen(src));
|
|
|
|
for (int i = 0; i < 20; i++) {
|
|
printf("Token %d: type=%d (%s) text='%s'\n", i, lex.token.type, basTokenName(lex.token.type), lex.token.text);
|
|
|
|
if (lex.token.type == TOK_EOF) {
|
|
break;
|
|
}
|
|
|
|
basLexerNext(&lex);
|
|
}
|
|
|
|
return 0;
|
|
}
|