ref: 96a486d98ec1ed5fceae00c6f4f0fb3ff29c8519
parent: e179d9ca799142833e93edc318495322a1d62058
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Jul 4 11:51:53 EDT 2013
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.
--- a/flow.c
+++ b/flow.c
@@ -264,7 +264,7 @@
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(';');
--- a/lex.c
+++ b/lex.c
@@ -180,14 +180,14 @@
}
}
-bool
-ahead(register char tok)
+unsigned char
+ahead(void)
{
register char c;
skip();
ungetc(c = getc(yyin), yyin);
- return c == tok;
+ return c;
}
char
--- a/tokens.h
+++ b/tokens.h
@@ -46,5 +46,5 @@
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
--
⑨