scc

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

commit d7a8adfd00c4d92615387463382ba1e000c3b61c
parent 824cc5f2899438f5865d942e855f907e26a5106c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 24 Apr 2014 17:57:59 +0200

Add default statement

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

diff --git a/stmt.c b/stmt.c @@ -249,6 +249,17 @@ Case(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) ++lswitch->nr; } +static void +Default(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) +{ + Symbol *ldefault = label(NULL, 1); + + expect(DEFAULT); + expect(':'); + emitlabel(ldefault); + lswitch->deflabel = ldefault; +} + void compound(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) { @@ -283,6 +294,7 @@ repeat: case GOTO: Goto(); break; case SWITCH: Switch(lcont); break; case CASE: Case(lbreak, lcont, lswitch); break; + case DEFAULT: Default(lbreak, lcont, lswitch); break; case IDEN: if (ahead() == ':') { Label();