scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 298745960166f4881f8203e9353b36a9f5603ef1
parent 84df6c68740f97dcd4ecac1b364987b6aa256fba
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 29 Aug 2012 20:00:16 +0200

Making exp return NULL if doesn't match a expression

This is really usefull because this means we can call expr() for example in
the for statement without be worried about if the expression will be empty
or not (it is also usefull in the case of return, where you can call it
without be worried).

Diffstat:
Mexpr.c | 3++-
Mflow.c | 6+++---
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/expr.c b/expr.c @@ -29,7 +29,8 @@ primary(void) expect(')'); break; default: - error("unexpected element"); + np = NULL; + break; } return np; } diff --git a/flow.c b/flow.c @@ -85,11 +85,11 @@ _for(void) expect(FOR); expect('('); - exp1 = (yytoken != ';') ? expr() : NULL; + exp1 = expr(); expect(';'); - exp2 = (yytoken != ';') ? expr() : NULL; + exp2 = expr(); expect(';'); - exp3 = (yytoken != ')') ? expr() : NULL; + exp3 = expr(); expect(')'); push(OFOR);