ref: f3ccbaf2c6369cfb1e3b61dfd6d559ef9f2f7edd
parent: 03513bb49e57c85779f088666ae448f3932089ca
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Apr 3 18:41:07 EDT 2014
Add pre and post increment
--- a/expr.c
+++ b/expr.c
@@ -163,6 +163,25 @@
}
}
+static Node *
+unary(void)
+{
+ Node *np;
+ char op;
+
+ switch (yytoken) {
+ case INC: case DEC:
+ op = (yytoken == INC) ? OINC : ODEC;
+ /* TODO: check that the the base type is a complete type */
+ next();
+ np = unary();
+ return unarycode(op, np->type, np);
+ break;
+ default:
+ return postfix();
+ }
+}
+
Node *
expr(void)
{
@@ -169,7 +188,7 @@
Node *np;
do
- np = postfix();
+ np = unary();
while (yytoken == ',');
return np;
}