scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 153c82b0106fbc8fbe6e4852d0e9aa4e24332f50
parent 4eae9c9960daf75a98fbfa57c6343999c3b0ca1b
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 24 Apr 2014 09:49:03 +0200

Add labeled statements

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

diff --git a/stmt.c b/stmt.c @@ -135,6 +135,15 @@ Break(Symbol *lbreak) } static void +Label(void) +{ + emitlabel(label(yytext)); + + expect(IDEN); + expect(':'); +} + +static void Continue(Symbol *lcont) { expect(CONTINUE); @@ -165,6 +174,8 @@ compound(Symbol *lbreak, Symbol *lcont, Symbol *lswitch) static void stmt(Symbol *lbreak, Symbol *lcont, Symbol *lswitch) { + +repeat: switch (yytoken) { case '{': compound(lbreak, lcont, lswitch); break; case RETURN: Return(); break; @@ -173,6 +184,7 @@ stmt(Symbol *lbreak, Symbol *lcont, Symbol *lswitch) case DO: Dowhile(lswitch); break; case BREAK: Break(lbreak); break; case CONTINUE: Continue(lcont); break; + case IDEN: if (ahead() == ':') Label(); goto repeat; default: stmtexp(); break; } }