ref: 69e7535d59c4e567c5279bea077e2ee7e24cb59a
parent: eb99e511ae17e585239954aa02821a05be94eb08
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Jun 4 17:25:41 EDT 2012
Added basic token for integers This patch adds the tokenizer for integer numbers, without testing sizes, formats or other aspects. This version is only s stub.
--- a/lex.c
+++ b/lex.c
@@ -95,6 +95,22 @@
}
}
+static char number(void)
+{
+ register char *bp;
+ register char ch;
+
+ for (bp = yytext; bp < yytext + TOKSIZ_MAX; *bp++ = ch) {
+ if (!isdigit(ch = getc(yyin)))
+ break;
+ }
+ if (bp == yytext + TOKSIZ_MAX)
+ error("identifier too long %s", yytext);
+ ungetc(ch, yyin);
+ *bp = '\0';
+ return CONSTANT;
+}
+
static unsigned char iden(void)
{
register struct keyword *kwp;
@@ -140,7 +156,8 @@
ungetc(ch, yyin);
ch = iden();
} else if (isdigit(ch)) {
- ;
+ ungetc(ch, yyin);
+ ch = number();
} else {
switch (ch) {
case '&': case '|':