frontend: compile: print lex token details as they are read

This commit is contained in:
2024-11-16 17:06:02 +00:00
parent 00cf226078
commit 6e5db6a3e2

View File

@@ -44,7 +44,24 @@ static int compile_file(const char *path)
break; break;
} }
printf("read token!\n"); printf("%s", ivy_lex_token_type_to_string(tok->t_type));
switch (tok->t_type) {
case IVY_TOK_IDENT:
case IVY_TOK_LABEL:
printf("(%s)", tok->t_str);
break;
case IVY_TOK_SYMBOL:
printf("(%s)", ivy_symbol_to_string(tok->t_symbol));
break;
case IVY_TOK_KEYWORD:
printf("(%s)", ivy_keyword_to_string(tok->t_keyword));
break;
default:
break;
}
printf("\n");
} }
int r = (lex.lex_status == IVY_OK || lex.lex_status == IVY_ERR_EOF) ? 0 int r = (lex.lex_status == IVY_OK || lex.lex_status == IVY_ERR_EOF) ? 0