ref: d73d54388b6c16e61ecceecb21a3df258f33c434
parent: 220d3dfdc7f4c5ae8967a03194bbae868c9f8ac8
parent: 49fa88c18b94c425e6f86beacbf8752f7564b7f3
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Jan 18 19:10:36 EST 2016
Merge pull request #52 from andrewchambers/issue51 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