scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit f3ccbaf2c6369cfb1e3b61dfd6d559ef9f2f7edd
parent 03513bb49e57c85779f088666ae448f3932089ca
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu,  3 Apr 2014 22:41:07 +0200

Add pre and post increment

Diffstat:
expr.c | 21++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/expr.c b/expr.c @@ -163,13 +163,32 @@ postfix(void) } } +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) { Node *np; do - np = postfix(); + np = unary(); while (yytoken == ','); return np; }