scc

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

commit 2b7e1beeced12f7553789848e55c97f857811bb7
parent 153c82b0106fbc8fbe6e4852d0e9aa4e24332f50
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 24 Apr 2014 12:18:56 +0200

Add goto statement

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

diff --git a/stmt.c b/stmt.c @@ -153,6 +153,18 @@ Continue(Symbol *lcont) expect(';'); } +static void +Goto(void) +{ + expect(GOTO); + + if (yytoken != IDEN) + error("unexpected '%s'", yytext); + emitjump(label(yytext), NULL); + next(); + expect(';'); +} + void compound(Symbol *lbreak, Symbol *lcont, Symbol *lswitch) { @@ -184,6 +196,7 @@ repeat: case DO: Dowhile(lswitch); break; case BREAK: Break(lbreak); break; case CONTINUE: Continue(lcont); break; + case GOTO: Goto(); break; case IDEN: if (ahead() == ':') Label(); goto repeat; default: stmtexp(); break; }