@@ -87,6 +87,14 @@ public ASTStmtNode parseStmt() throws Exception {
8787 return parseIfElseStmt ();
8888 }
8989
90+ if (type == Type .LOOP ) {
91+ return parseForLoop ();
92+ }
93+
94+ if (type == Type .BREAK ){
95+ return parseBreakNode ();
96+ }
97+
9098 m_lexer .throwCompilerException ("Invalid begin of statement" , "DECLARE or IDENTIFIER or PRINT or NUMERIC_IF" );
9199 return null ; // unreachable
92100 }
@@ -303,6 +311,22 @@ ASTDoWhileLoopStmtNode parseDoWhileLoopStmt() throws Exception {
303311 m_lexer .expect (Type .SEMICOLON );
304312 return new ASTDoWhileLoopStmtNode (predicate , body );
305313 }
314+
315+ public ASTStmtNode parseForLoop () throws Exception {
316+ //loopstmt : loopstart [stmtlist] loopend
317+ m_lexer .expect (Type .LOOP );
318+ m_lexer .expect (Type .LBRACE );
319+ ASTStmtListNode body = parseStmtlist ();
320+ m_lexer .expect (Type .RBRACE );
321+ m_lexer .expect (Type .ENDLOOP );
322+ return new ASTLoopStmtNode (body );
323+
324+ }
325+
326+ private ASTStmtNode parseBreakNode () throws Exception {
327+ m_lexer .expect (Type .BREAK );
328+ return new ASTBreakExprNode ();
329+ }
306330
307331 ASTStmtNode parseExecuteNTimesStmt () throws Exception {
308332 // EXECUTE integer|identifier TIMES LBRACE stmtList RBRACE SEMICOLON
0 commit comments