diff src/luan/interp/LuanParser.java @ 151:c9100f29fae0

conditions must be type boolean git-svn-id: https://luan-java.googlecode.com/svn/trunk@152 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Mon, 16 Jun 2014 10:37:06 +0000
parents f99fd64291b3
children fa03671f59a0
line wrap: on
line diff
--- a/src/luan/interp/LuanParser.java	Mon Jun 16 10:11:48 2014 +0000
+++ b/src/luan/interp/LuanParser.java	Mon Jun 16 10:37:06 2014 +0000
@@ -451,24 +451,24 @@
 	}
 
 	private Stmt WhileStmt() throws ParseException {
-		parser.begin();
+		int start = parser.begin();
 		if( !Keyword("while",In.NOTHING) )
 			return parser.failure(null);
 		Expr cnd = expr(RequiredExpr(In.NOTHING));
 		RequiredKeyword("do",In.NOTHING);
 		Stmt loop = RequiredLoopBlock();
 		RequiredKeyword("end",In.NOTHING);
-		return parser.success( new WhileStmt(cnd,loop) );
+		return parser.success( new WhileStmt(se(start),cnd,loop) );
 	}
 
 	private Stmt RepeatStmt() throws ParseException {
-		parser.begin();
+		int start = parser.begin();
 		if( !Keyword("repeat",In.NOTHING) )
 			return parser.failure(null);
 		Stmt loop = RequiredLoopBlock();
 		RequiredKeyword("until",In.NOTHING);
 		Expr cnd = expr(RequiredExpr(In.NOTHING));
-		return parser.success( new RepeatStmt(loop,cnd) );
+		return parser.success( new RepeatStmt(se(start),loop,cnd) );
 	}
 
 	private Stmt RequiredLoopBlock() throws ParseException {
@@ -486,6 +486,7 @@
 	}
 
 	private Stmt IfStmt2() throws ParseException {
+		int start = parser.currentIndex();
 		Expr cnd = expr(RequiredExpr(In.NOTHING));
 		RequiredKeyword("then",In.NOTHING);
 		Stmt thenBlock = RequiredBlock();
@@ -496,7 +497,7 @@
 			elseBlock = Keyword("else",In.NOTHING) ? RequiredBlock() : Stmt.EMPTY;
 			RequiredKeyword("end",In.NOTHING);
 		}
-		return new IfStmt(cnd,thenBlock,elseBlock);
+		return new IfStmt(se(start),cnd,thenBlock,elseBlock);
 	}
 
 	private Stmt SetStmt() throws ParseException {