shithub: scc

Download patch

ref: c076bf291eff4fa3fa0702cb971a493fc1dc1680
parent: 2630b2abf0a6fb9c78352f7bea6d19f4bcfaa57c
author: Roberto E. Vargas Caballero <[email protected]>
date: Sun Jun 10 08:14:12 EDT 2012

Improved lexical analysis

This patch removes all the complex switch in function next, which is now a
clearer one.

--- a/decl.c
+++ b/decl.c
@@ -19,7 +19,7 @@
 
 	if (!sym)
 		sym = install(yytext, yyhash);
-	if (sym->level == nested_level)
+	else if (sym->level == nested_level)
 		error("redeclaration of '%s'", yytext);
 	return sym;
 }
--- a/lex.c
+++ b/lex.c
@@ -76,10 +76,10 @@
 	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 @@
 {
 	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)) {