changeset 159:0abc9181061a

revert rev 154 but only allow FnCall, AndExpr, or OrExpr in ExpressionsStmt git-svn-id: https://luan-java.googlecode.com/svn/trunk@160 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Thu, 19 Jun 2014 04:40:12 +0000
parents cced1c4d3575
children 138b9baee80b
files src/luan/interp/ExpressionsStmt.java src/luan/interp/FnCallStmt.java src/luan/interp/LuanParser.java
diffstat 3 files changed, 24 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
diff -r cced1c4d3575 -r 0abc9181061a src/luan/interp/ExpressionsStmt.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/luan/interp/ExpressionsStmt.java	Thu Jun 19 04:40:12 2014 +0000
@@ -0,0 +1,17 @@
+package luan.interp;
+
+import luan.LuanException;
+
+
+final class ExpressionsStmt implements Stmt {
+	private final Expressions expressions;
+
+	ExpressionsStmt(Expressions expressions) {
+		this.expressions = expressions;
+	}
+
+	@Override public void eval(LuanStateImpl luan) throws LuanException {
+		expressions.eval(luan);
+	}
+
+}
diff -r cced1c4d3575 -r 0abc9181061a src/luan/interp/FnCallStmt.java
--- a/src/luan/interp/FnCallStmt.java	Wed Jun 18 21:49:06 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-package luan.interp;
-
-import luan.LuanException;
-
-
-final class FnCallStmt implements Stmt {
-	private final FnCall fnCall;
-
-	FnCallStmt(FnCall fnCall) {
-		this.fnCall = fnCall;
-	}
-
-	@Override public void eval(LuanStateImpl luan) throws LuanException {
-		fnCall.eval(luan);
-	}
-
-}
diff -r cced1c4d3575 -r 0abc9181061a src/luan/interp/LuanParser.java
--- a/src/luan/interp/LuanParser.java	Wed Jun 18 21:49:06 2014 +0000
+++ b/src/luan/interp/LuanParser.java	Thu Jun 19 04:40:12 2014 +0000
@@ -257,7 +257,7 @@
 			|| (stmt=RepeatStmt()) != null
 			|| (stmt=IfStmt()) != null
 			|| (stmt=SetStmt()) != null
-			|| (stmt=FnCallStmt()) != null
+			|| (stmt=ExpressionsStmt()) != null
 		) {
 			stmts.add(stmt);
 		}
@@ -272,7 +272,7 @@
 		fnExp = new IndexExpr( se(start), fnExp, new ConstExpr("stdout") );
 		fnExp = new IndexExpr( se(start), fnExp, new ConstExpr("write") );
 		FnCall fnCall = new FnCall( se(start), fnExp, exp );
-		return new FnCallStmt(fnCall);
+		return new ExpressionsStmt(fnCall);
 	}
 
 	private Expressions TemplateExpressions(In in) throws ParseException {
@@ -543,13 +543,12 @@
 		return parser.success( new SetStmt( vars.toArray(new Settable[0]), values ) );
 	}
 
-	private Stmt FnCallStmt() throws ParseException {
+	private Stmt ExpressionsStmt() throws ParseException {
 		parser.begin();
-		Expressions exp = VarExp(In.NOTHING);
-		if( !(exp instanceof FnCall) )
-			return parser.failure(null);
-		FnCall fnCall = (FnCall)exp;
-		return parser.success( new FnCallStmt(fnCall) );
+		Expressions exp = Expr(In.NOTHING);
+		if( exp instanceof FnCall || exp instanceof AndExpr || exp instanceof OrExpr )
+			return parser.success( new ExpressionsStmt(exp) );
+		return parser.failure(null);
 	}
 
 	private Settable SettableVar() throws ParseException {