commit c076bf291eff4fa3fa0702cb971a493fc1dc1680
parent 2630b2abf0a6fb9c78352f7bea6d19f4bcfaa57c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sun, 10 Jun 2012 12:14:12 +0200
Improved lexical analysis
This patch removes all the complex switch in function next, which is now a
clearer one.
Diffstat:
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/decl.c b/decl.c
@@ -19,7 +19,7 @@ static struct symbol *newiden(char *s, unsigned char key)
if (!sym)
sym = install(yytext, yyhash);
- if (sym->level == nested_level)
+ else if (sym->level == nested_level)
error("redeclaration of '%s'", yytext);
return sym;
}
diff --git a/lex.c b/lex.c
@@ -76,10 +76,10 @@ static unsigned char skip(void)
if (c == EOF) {
if (parser_out_home)
error("Find EOF while parsing");
- return 1;
+ return 0;
}
ungetc(c, yyin);
- return 0;
+ return 1;
}
static unsigned char
@@ -132,9 +132,9 @@ unsigned char next(void)
{
register unsigned char c;
- if (!skip())
+ if (!skip()) {
c = EOFTOK;
- if (isalpha(c = getc(yyin)) || c == '_') {
+ } else if (isalpha(c = getc(yyin)) || c == '_') {
ungetc(c, yyin);
c = iden();
} else if (isdigit(c)) {