From db4976d89a539b32f538223d6347532944f6c18b Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Thu, 3 Sep 2015 21:01:52 +0200 Subject: [PATCH] fix *=- (close #35) --- Test.hx | 1 + hscript/Parser.hx | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Test.hx b/Test.hx index 49fdb4b..9ab6238 100644 --- a/Test.hx +++ b/Test.hx @@ -90,6 +90,7 @@ class Test { test("var x=-3; x", -3); test("var a:Array=[1,2,4]; a[2]", 4, null, true); test("/**/0", 0); + test("x=1;x*=-2", -2); trace("Done"); } diff --git a/hscript/Parser.hx b/hscript/Parser.hx index 6d55306..607e8ba 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -1063,14 +1063,16 @@ class Parser { default: if( ops[char] ) { var op = String.fromCharCode(char); + var prev = -1; while( true ) { char = readChar(); - if( !ops[char] ) { + if( !ops[char] || prev == '='.code ) { if( op.charCodeAt(0) == '/'.code ) return tokenComment(op,char); this.char = char; return TOp(op); } + prev = char; op += String.fromCharCode(char); } }