scc

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

commit b1ca62655dbb5c3539ba900d5d2b7d2530efb4a8
parent cf8e9e411ee41b2bdf227922c88038785319fc0c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 24 Apr 2014 09:22:10 +0200

Add break statement

Diffstat:
Mstmt.c | 11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)

diff --git a/stmt.c b/stmt.c @@ -124,6 +124,16 @@ Return(void) emitexp(np); } +static void +Break(Symbol *lbreak) +{ + expect(BREAK); + if (!lbreak) + error("break statement not within loop or switch"); + emitjump(lbreak, NULL); + expect(';'); +} + void compound(Symbol *lbreak, Symbol *lcont, Symbol *lswitch) { @@ -151,6 +161,7 @@ stmt(Symbol *lbreak, Symbol *lcont, Symbol *lswitch) case WHILE: While(lswitch); break; case FOR: For(lswitch); break; case DO: Dowhile(lswitch); break; + case BREAK: Break(lbreak); break; default: stmtexp(); break; } }