Turn T_EOF into a properly registered token.
authorChristoph Mallon <christoph.mallon@gmx.de>
Wed, 20 Jun 2012 14:58:05 +0000 (16:58 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Wed, 20 Jun 2012 19:52:08 +0000 (21:52 +0200)
token.c
token_t.h
tokens.inc

diff --git a/token.c b/token.c
index f80d432..9db11b1 100644 (file)
--- a/token.c
+++ b/token.c
@@ -86,11 +86,6 @@ void exit_tokens(void)
 
 void print_token_kind(FILE *f, token_kind_t token_kind)
 {
-       if(token_kind == T_EOF) {
-               fputs("end of file", f);
-               return;
-       }
-
        if (token_kind >= lengthof(token_symbols)) {
                fputs("invalid token", f);
                return;
index 7843dc8..3e14d3d 100644 (file)
--- a/token_t.h
+++ b/token_t.h
@@ -28,7 +28,6 @@
 
 typedef enum token_kind_tag_t {
        T_NULL  =  0,
-       T_EOF   = '\x04', // EOT
 #define T(mode,x,str,val) T_##x val,
 #define TS(x,str,val) T_##x val,
 #include "tokens.inc"
index 74dc86c..36ab9c7 100644 (file)
@@ -9,6 +9,7 @@
 #undef PUNCTUATOR
 #undef ALTERNATE
 
+TS(EOF,                "end of input",)
 TS(IDENTIFIER,         "identifier",)
 TS(NUMBER,             "number constant",)
 TS(CHARACTER_CONSTANT, "character constant",)