fixed unop issues

This commit is contained in:
Nicolas Cannasse
2008-12-24 12:18:54 +00:00
parent f151124b80
commit cb0182f612
2 changed files with 11 additions and 2 deletions
+3
View File
@@ -65,6 +65,9 @@ class Test {
test("var t = 0; for( x in new IntIter(1,10) ) t +=x; t",45,{ IntIter : IntIter });
test("var x = 1; try { var x = 66; throw 789; } catch( e : Dynamic ) e + x",790);
test("var x = 1; var f = function(x) throw x; try f(55) catch( e : Dynamic ) e + x",56);
test("var i=2; if( true ) --i; i",1);
test("var i=0; if( i++ > 0 ) i=3; i",1);
test("var a = 5/2; a",2.5);
trace("Done");
}
+8 -2
View File
@@ -335,8 +335,13 @@ class Parser {
switch( tk ) {
case TOp(op):
for( x in unopsSuffix )
if( x == op )
return EUnop(op,false,e1);
if( x == op ) {
if( isBlock(e1) || switch(e1) { case EParent(_): true; default: false; } ) {
tokens.add(tk);
return e1;
}
return parseExprNext(s,EUnop(op,false,e1));
}
return makeBinop(op,e1,parseExpr(s));
case TDot:
tk = token(s);
@@ -579,6 +584,7 @@ class Parser {
}
return token(s);
}
this.char = char;
return TOp(op);
}