Mercurial Hosting > luan
changeset 158:cced1c4d3575
only allow TemplateExpressions at end of expr list;
change LuanParser.Expressions() to Expression();
git-svn-id: https://luan-java.googlecode.com/svn/trunk@159 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Wed, 18 Jun 2014 21:49:06 +0000 |
parents | 1de3e4a6e82d |
children | 0abc9181061a |
files | src/luan/interp/LuanCompiler.java src/luan/interp/LuanParser.java |
diffstat | 2 files changed, 17 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/interp/LuanCompiler.java Wed Jun 18 21:07:11 2014 +0000 +++ b/src/luan/interp/LuanCompiler.java Wed Jun 18 21:49:06 2014 +0000 @@ -38,7 +38,7 @@ private static FnDef parse(LuanState luan,LuanParser parser,boolean allowExpr) throws LuanException { try { if( allowExpr ) { - FnDef fnDef = parser.Expressions(); + FnDef fnDef = parser.Expression(); if( fnDef != null ) return fnDef; }
--- a/src/luan/interp/LuanParser.java Wed Jun 18 21:07:11 2014 +0000 +++ b/src/luan/interp/LuanParser.java Wed Jun 18 21:49:06 2014 +0000 @@ -180,12 +180,12 @@ return new FnDef( se(start), stmt, frame.stackSize, symbolsSize(), frame.isVarArg, frame.upValueGetters.toArray(NO_UP_VALUE_GETTERS) ); } - FnDef Expressions() throws ParseException { + FnDef Expression() throws ParseException { Spaces(In.NOTHING); int start = parser.begin(); - Expressions exprs = ExpList(In.NOTHING); - if( exprs != null && parser.endOfInput() ) { - Stmt stmt = new ReturnStmt( se(start), exprs ); + Expressions expr = Expr(In.NOTHING); + if( expr != null && parser.endOfInput() ) { + Stmt stmt = new ReturnStmt( se(start), expr ); return parser.success(newFnDef(start,stmt)); } return parser.failure(null); @@ -569,7 +569,6 @@ parser.begin(); Expressions exp; return (exp = VarArgs(in)) != null - || (exp = TemplateExpressions(in)) != null || (exp = OrExpr(in)) != null ? parser.success(exp) : parser.failure((Expressions)null) @@ -887,7 +886,7 @@ if( parser.match('(') ) { In inParens = in.parens(); Spaces(inParens); - Expr exp = expr(Expr(inParens)); + Expr exp = expr(RequiredExpr(inParens)); RequiredMatch(')'); Spaces(in); return parser.success(exprVar(exp)); @@ -1010,12 +1009,22 @@ private boolean ExpList(In in,List<Expressions> builder) throws ParseException { parser.begin(); - Expressions exp = Expr(in); + Expressions exp = TemplateExpressions(in); + if( exp != null ) { + builder.add(exp); + return parser.success(); + } + exp = Expr(in); if( exp==null ) return parser.failure(); builder.add(exp); while( parser.match(',') ) { Spaces(in); + exp = TemplateExpressions(in); + if( exp != null ) { + builder.add(exp); + return parser.success(); + } builder.add( RequiredExpr(in) ); } return parser.success();