scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 4cf972513cefeba94d92337eed301e1f140582cf
parent 34a81d796b32081310c4232f2955cd31fc84bc00
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed,  3 Jul 2013 14:51:48 +0200

Move ahead call out of label

it is not clear calling to exp inside of label. It is more clear call to ahead
before of calling label, and in this case be sure it is a real label.

Diffstat:
Mflow.c | 10++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/flow.c b/flow.c @@ -153,14 +153,8 @@ label(void) { register struct symbol *sym = yyval.sym; - if (!ahead(':')) { - register struct node *np = expr(); /* it is an identifier */ - expect(';'); /* not a label */ - return np; - } - sym = newlabel(sym, yytext); - next(), next(); /* skip IDEN and ':' */ + next(), next(); /* skip IDEN and ':' */ return node2(OLABEL, nodesym(sym), stmt()); } @@ -253,7 +247,7 @@ stmt(void) case GOTO: return _goto(); case CASE: return _case(); case DEFAULT: return _default(); - case IDEN: return label(); + case IDEN: if (ahead(':')) return label(); } np = expr(); expect(';');