/* * This is not part of your eventual program, but it allows you to test the * functioning of our token.c and your additions to symbol.c. */ #include #include "token.h" #include "symbol.h" int main() { struct token t; int n; token_init(stdin); for (n = 0; t = get_next_token(), t.type != EOF; n++) { switch (t.type) { case TOKEN_ICONST: printf("token #%d is the int const %d\n", n, t.ivalue); break; case TOKEN_STRCONST: printf("token #%d is the string \"%s\"\n", n, t.strvalue); break; case TOKEN_IDENT: printf("token #%d is the symbol %s\n", n, symbol_getname(t.symvalue)); break; default: printf("token #%d is the character '%c'\n", n, t.type); } } return 0; }