From cb0182f612b7b1aa98b84121864422ab74a08eb7 Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Wed, 24 Dec 2008 12:18:54 +0000 Subject: [PATCH] fixed unop issues --- Test.hx | 3 +++ hscript/Parser.hx | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Test.hx b/Test.hx index 35fba99..36a12c0 100644 --- a/Test.hx +++ b/Test.hx @@ -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"); } diff --git a/hscript/Parser.hx b/hscript/Parser.hx index 4268cb1..314bc76 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -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); }