scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 96a486d98ec1ed5fceae00c6f4f0fb3ff29c8519
parent e179d9ca799142833e93edc318495322a1d62058
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu,  4 Jul 2013 15:51:53 +0200

Returns the next character in ahead

ahead was testing that next character is the desired character, but
in some situations we will need test against various characaters, so
it isn't a good idea. We must return the character and check out of
the function.

Diffstat:
flow.c | 2+-
lex.c | 6+++---
tokens.h | 2+-
3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/flow.c b/flow.c @@ -264,7 +264,7 @@ stmt(void) case GOTO: return _goto(); case CASE: return _case(); case DEFAULT: return _default(); - case IDEN: if (ahead(':')) return label(); + case IDEN: if (ahead() == ':') return label(); } np = expr(); expect(';'); diff --git a/lex.c b/lex.c @@ -180,14 +180,14 @@ next(void) } } -bool -ahead(register char tok) +unsigned char +ahead(void) { register char c; skip(); ungetc(c = getc(yyin), yyin); - return c == tok; + return c; } char diff --git a/tokens.h b/tokens.h @@ -46,5 +46,5 @@ extern void next(void); extern char accept(unsigned char tok); extern void expect(unsigned char tok); extern void init_keywords(void); -extern bool ahead(char c); +extern unsigned char ahead(void); #endif