Mercurial Hosting > luan
comparison src/luan/interp/LuanParser.java @ 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 | 94bbc4cbc106 |
comparison
equal
deleted
inserted
replaced
158:cced1c4d3575 | 159:0abc9181061a |
---|---|
255 || (stmt=WhileStmt()) != null | 255 || (stmt=WhileStmt()) != null |
256 || (stmt=FunctionStmt()) != null | 256 || (stmt=FunctionStmt()) != null |
257 || (stmt=RepeatStmt()) != null | 257 || (stmt=RepeatStmt()) != null |
258 || (stmt=IfStmt()) != null | 258 || (stmt=IfStmt()) != null |
259 || (stmt=SetStmt()) != null | 259 || (stmt=SetStmt()) != null |
260 || (stmt=FnCallStmt()) != null | 260 || (stmt=ExpressionsStmt()) != null |
261 ) { | 261 ) { |
262 stmts.add(stmt); | 262 stmts.add(stmt); |
263 } | 263 } |
264 } | 264 } |
265 | 265 |
270 return null; | 270 return null; |
271 Expr fnExp = (Expr)nameVar(start,"Io").expr(); | 271 Expr fnExp = (Expr)nameVar(start,"Io").expr(); |
272 fnExp = new IndexExpr( se(start), fnExp, new ConstExpr("stdout") ); | 272 fnExp = new IndexExpr( se(start), fnExp, new ConstExpr("stdout") ); |
273 fnExp = new IndexExpr( se(start), fnExp, new ConstExpr("write") ); | 273 fnExp = new IndexExpr( se(start), fnExp, new ConstExpr("write") ); |
274 FnCall fnCall = new FnCall( se(start), fnExp, exp ); | 274 FnCall fnCall = new FnCall( se(start), fnExp, exp ); |
275 return new FnCallStmt(fnCall); | 275 return new ExpressionsStmt(fnCall); |
276 } | 276 } |
277 | 277 |
278 private Expressions TemplateExpressions(In in) throws ParseException { | 278 private Expressions TemplateExpressions(In in) throws ParseException { |
279 if( in.template ) | 279 if( in.template ) |
280 return null; | 280 return null; |
541 if( values==null ) | 541 if( values==null ) |
542 throw parser.exception("Expressions expected"); | 542 throw parser.exception("Expressions expected"); |
543 return parser.success( new SetStmt( vars.toArray(new Settable[0]), values ) ); | 543 return parser.success( new SetStmt( vars.toArray(new Settable[0]), values ) ); |
544 } | 544 } |
545 | 545 |
546 private Stmt FnCallStmt() throws ParseException { | 546 private Stmt ExpressionsStmt() throws ParseException { |
547 parser.begin(); | 547 parser.begin(); |
548 Expressions exp = VarExp(In.NOTHING); | 548 Expressions exp = Expr(In.NOTHING); |
549 if( !(exp instanceof FnCall) ) | 549 if( exp instanceof FnCall || exp instanceof AndExpr || exp instanceof OrExpr ) |
550 return parser.failure(null); | 550 return parser.success( new ExpressionsStmt(exp) ); |
551 FnCall fnCall = (FnCall)exp; | 551 return parser.failure(null); |
552 return parser.success( new FnCallStmt(fnCall) ); | |
553 } | 552 } |
554 | 553 |
555 private Settable SettableVar() throws ParseException { | 554 private Settable SettableVar() throws ParseException { |
556 int start = parser.begin(); | 555 int start = parser.begin(); |
557 Var var = VarZ(In.NOTHING); | 556 Var var = VarZ(In.NOTHING); |