ref: 153c82b0106fbc8fbe6e4852d0e9aa4e24332f50
parent: 4eae9c9960daf75a98fbfa57c6343999c3b0ca1b
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Apr 24 05:49:03 EDT 2014
Add labeled statements
--- a/stmt.c
+++ b/stmt.c
@@ -135,6 +135,15 @@
}
static void
+Label(void)
+{
+ emitlabel(label(yytext));
+
+ expect(IDEN);
+ expect(':');
+}
+
+static void
Continue(Symbol *lcont)
{
expect(CONTINUE);
@@ -165,6 +174,8 @@
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 @@
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;
}
}