scc

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

commit 537e20492045bd44e48e57d5c664c9eccf0a5a06
parent 588948f9dc4651080d0d664b10cc62274614b706
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 24 Apr 2014 09:11:21 +0200

Add do-while statement

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

diff --git a/stmt.c b/stmt.c @@ -88,6 +88,22 @@ For(Symbol *lswitch) } 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 @@ stmt(Symbol *lbreak, Symbol *lcont, Symbol *lswitch) case RETURN: Return(); break; case WHILE: While(lswitch); break; case FOR: For(lswitch); break; + case DO: Dowhile(lswitch); break; default: stmtexp(); break; } }