shithub: scc

Download patch

ref: 537e20492045bd44e48e57d5c664c9eccf0a5a06
parent: 588948f9dc4651080d0d664b10cc62274614b706
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Apr 24 05:11:21 EDT 2014

Add do-while statement

--- a/stmt.c
+++ b/stmt.c
@@ -88,6 +88,22 @@
 }
 
 static void
+Dowhile(Symbol *lswitch)
+{
+	Symbol *begin= label(NULL), *end = label(NULL);
+
+
+	expect(DO);
+	emitbloop();
+	emitlabel(begin);
+	stmt(begin, end, lswitch);
+	expect(WHILE);
+	emitjump(begin, condition());
+	emiteloop();
+	emitlabel(end);
+}
+
+static void
 Return(void)
 {
 	Node *np;
@@ -132,6 +148,7 @@
 	case RETURN: Return(); break;
 	case WHILE: While(lswitch); break;
 	case FOR: For(lswitch); break;
+	case DO: Dowhile(lswitch); break;
 	default: stmtexp(); break;
 	}
 }