shithub: scc

Download patch

ref: b4a75db28d8358ead5216591676f1c2e5867ebb4
parent: 0214edbad28232ca828f44aa43dd413fe18edaa9
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Apr 23 18:25:01 EDT 2014

Fix next()

+ and - are operators, and they must be operators since they
can be part of +=, -=, ++, -- tokens, so they are no a valid
part of a number.

--- a/lex.c
+++ b/lex.c
@@ -59,14 +59,9 @@
 static uint8_t
 number(void)
 {
-	register char ch, *bp = yybuf;
+	register char ch, *bp;
 	static char base;
 
-	if ((ch = getc(yyin)) == '+' || ch == '-')
-		*bp++ = ch;
-	else
-		ungetc(ch, yyin);
-
 	if ((ch = getc(yyin)) == '0') {
 		if (toupper(ch = getc(yyin)) == 'X') {
 			base = 16;
@@ -79,7 +74,7 @@
 		ungetc(ch, yyin);
 	}
 
-	for ( ; bp < &yybuf[IDENTSIZ]; *bp++ = ch) {
+	for (bp = yybuf ; bp < &yybuf[IDENTSIZ]; *bp++ = ch) {
 		ch = getc(yyin);
 		switch (base) {
 		case 8:
@@ -405,7 +400,7 @@
 	ungetc(c, yyin);
 	if (isalpha(c) || c == '_')
 		yyntoken = iden();
-	else if (isdigit(c) || c == '-' || c == '+')
+	else if (isdigit(c))
 		yyntoken = number();
 	else if (c == '"')
 		yyntoken = string();