projects
/
cparser
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
support for pointer add/sub, no need for type_environment in ast2firm
[cparser]
/
token.c
diff --git
a/token.c
b/token.c
index
50e166a
..
4769365
100644
(file)
--- a/
token.c
+++ b/
token.c
@@
-30,6
+30,15
@@
void init_tokens(void)
#include "tokens.inc"
#undef TS
#include "tokens.inc"
#undef TS
+#undef T
+
+#define T(x,str,val) \
+ assert(TP_##x >= 0 && TP_##x < TP_LAST_TOKEN); \
+ symbol = symbol_table_insert(str); \
+ symbol->pp_ID = TP_##x;
+
+#include "tokens_preprocessor.inc"
+
#undef T
}
#undef T
}
@@
-39,14
+48,14
@@
void exit_tokens(void)
void print_token_type(FILE *f, token_type_t token_type)
{
void print_token_type(FILE *f, token_type_t token_type)
{
- if(token_type >= 0 && token_type < 256) {
- fprintf(f, "'%c'", token_type);
- return;
- }
if(token_type == T_EOF) {
fputs("end of file", f);
return;
}
if(token_type == T_EOF) {
fputs("end of file", f);
return;
}
+ if(token_type == T_ERROR) {
+ fputs("error", f);
+ return;
+ }
int token_symbols_len = T_LAST_TOKEN;
if(token_type < 0 || token_type >= token_symbols_len) {
int token_symbols_len = T_LAST_TOKEN;
if(token_type < 0 || token_type >= token_symbols_len) {
@@
-56,8
+65,12
@@
void print_token_type(FILE *f, token_type_t token_type)
const symbol_t *symbol = token_symbols[token_type];
if(symbol != NULL) {
const symbol_t *symbol = token_symbols[token_type];
if(symbol != NULL) {
- fp
uts(symbol->string, f
);
+ fp
rintf(f, "'%s'", symbol->string
);
} else {
} else {
+ if(token_type >= 0 && token_type < 256) {
+ fprintf(f, "'%c'", token_type);
+ return;
+ }
fputs("unknown token", f);
}
}
fputs("unknown token", f);
}
}
@@
-71,6
+84,9
@@
void print_token(FILE *f, const token_t *token)
case T_INTEGER:
fprintf(f, "integer number %d", token->v.intvalue);
break;
case T_INTEGER:
fprintf(f, "integer number %d", token->v.intvalue);
break;
+ case T_FLOATINGPOINT:
+ fprintf(f, "floatingpointer number %f", token->v.floatvalue);
+ break;
case T_STRING_LITERAL:
fprintf(f, "string '%s'", token->v.string);
break;
case T_STRING_LITERAL:
fprintf(f, "string '%s'", token->v.string);
break;