commit b6d551944bd495bb30ba7345f5ab77ccca14c295
parent 6f28085c2d0113db59693fdf30fe1d1e855635f9
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Mon, 31 Mar 2014 19:37:40 +0200
Add plus() in lex.c
We have minus, so it is logical to have plus().
Diffstat:
M | lex.c | | | 20 | +++++++++++++++++++- |
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/lex.c b/lex.c
@@ -182,6 +182,7 @@ minus(void)
register int c = getc(yyin);
yybuf[1] = c;
+ yybuf[2] = '\0';
switch (c) {
case '-': return DEC;
case '>': return INDIR;
@@ -194,6 +195,23 @@ minus(void)
}
static uint8_t
+plus(void)
+{
+ register int c = getc(yyin);
+
+ yybuf[1] = c;
+ yybuf[2] = '\0';
+ switch (c) {
+ case '+': return INC;
+ case '=': return ADD_EQ;
+ default:
+ yybuf[1] = '\0';
+ ungetc(c, yyin);
+ return '+';
+ }
+}
+
+static uint8_t
relational(uint8_t op, uint8_t equal, uint8_t shift, uint8_t assig)
{
register int c = getc(yyin);
@@ -220,7 +238,6 @@ operator(void)
switch (c) {
case '<': return relational('<', LE, SHL, SHL_EQ);
case '>': return relational('>', GE, SHR, SHR_EQ);
- case '+': return follow('+', INC, follow('=', ADD_EQ, '+'));
case '=': return follow('=', EQ, '=');
case '^': return follow('=', XOR_EQ, '^');
case '*': return follow('=', MUL_EQ, '*');
@@ -229,6 +246,7 @@ operator(void)
case '&': return follow('=', AND_EQ, AND);
case '|': return follow('=', OR_EQ, OR);
case '-': return minus();
+ case '+': return plus();
default: return c;
}
}