changeset 1131:46732cc0ab87

add continue statement
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 14 Dec 2017 01:38:47 -0700
parents bfbd5401353a
children b70102bab110
files src/luan/impl/LuanParser.java
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
diff -r bfbd5401353a -r 46732cc0ab87 src/luan/impl/LuanParser.java
--- a/src/luan/impl/LuanParser.java	Mon Dec 11 23:36:52 2017 -0700
+++ b/src/luan/impl/LuanParser.java	Thu Dec 14 01:38:47 2017 -0700
@@ -339,6 +339,7 @@
 			|| (stmt=LocalStmt()) != null
 			|| (stmt=LocalFunctionStmt()) != null
 			|| (stmt=BreakStmt()) != null
+			|| (stmt=ContinueStmt()) != null
 			|| (stmt=ForStmt()) != null
 			|| (stmt=DoStmt()) != null
 			|| (stmt=WhileStmt()) != null
@@ -482,6 +483,17 @@
 		return parser.success( stmt );
 	}
 
+	private Stmts ContinueStmt() throws ParseException {
+		parser.begin();
+		if( !Keyword("continue") )
+			return parser.failure(null);
+		if( frame.loops <= 0 )
+			throw parser.exception("'continue' outside of loop");
+		Stmts stmt = new Stmts();
+		stmt.add( "continue;  " );
+		return parser.success( stmt );
+	}
+
 	int forCounter = 0;
 
 	private Stmts ForStmt() throws ParseException {
@@ -1494,6 +1506,7 @@
 	private static final Set<String> keywords = new HashSet<String>(Arrays.asList(
 		"and",
 		"break",
+		"continue",
 		"do",
 		"else",
 		"elseif",