scc

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

commit 7d00111f794d7d658e9faeacdc136b2b28f80461
parent 8582d9985a73836ca6e53a5f7c50b71ec7466168
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 21 Aug 2012 22:18:49 +0200

Fixed bug parsing statements

Only it is necessary the ; after an expresion, not after an statement (for
example after a compound is not necessary).

Diffstat:
Mflow.c | 27+++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/flow.c b/flow.c @@ -87,26 +87,21 @@ stmt(void) register struct node *np; switch (yytoken) { - case '{': np = compound(); break; - case SWITCH: np = do_switch(); break; - case IF: np = do_if(); break; - case FOR: np = do_for(); break; - case DO: np = do_do(); break; - case WHILE: np = do_while(); break; + case '{': return compound(); + case SWITCH: return do_switch(); + case IF: return do_if(); + case FOR: return do_for(); + case DO: return do_do(); + case WHILE: return do_while(); case CONTINUE: case BREAK: case RETURN: - case GOTO: np = do_goto(); break; - case CASE: - /* TODO */ - case DEFAULT: - /* TODO */ - break; - case IDEN: - /* TODO: check if it can be a label */ - default: np = expr(); break; - + case GOTO: return do_goto(); + case CASE: /* TODO */ + case DEFAULT: /* TODO */ + case IDEN: /* TODO: check if it can be a label */; } + np = expr(); expect(';'); return np; }