shithub: mc

Download patch

ref: 49fa88c18b94c425e6f86beacbf8752f7564b7f3
parent: 220d3dfdc7f4c5ae8967a03194bbae868c9f8ac8
author: andrewc <andrew_chambers@trimble.com>
date: Tue Jan 19 11:23:05 EST 2016

fix #51, loops without cond stmts

--- a/parse/gram.y
+++ b/parse/gram.y
@@ -870,8 +870,11 @@
 	{$$ = mkexpr($1->loc, Ocontinue, NULL);}
 	;
 
-forstmt : Tfor optexprln optexprln optexprln block
-	{$$ = mkloopstmt($1->loc, $2, $3, $4, $5);}
+forstmt : Tfor optexprln optexprln optexprln block {
+		if(!$3)
+			$3 = mkboollit($1->loc, 1);
+		$$ = mkloopstmt($1->loc, $2, $3, $4, $5);
+	}
 	| Tfor expr Tin exprln block
 	{$$ = mkiterstmt($1->loc, $2, $4, $5);}
 	| Tfor decl Tendln optexprln optexprln block {
--- /dev/null
+++ b/test/fornocond.myr
@@ -1,0 +1,14 @@
+use std
+
+const main = {
+	var i
+	
+	for i = 0; ; i++
+		if i == 10
+			break;
+		;;
+	;;
+	if i == 10
+		std.put("pass\n")
+	;;
+}
--- a/test/tests
+++ b/test/tests
@@ -149,3 +149,4 @@
 F arityhigh
 F badop
 B voideffect	P	pass
+B fornocond	P	pass