added ~ unary operator

This commit is contained in:
Nicolas Cannasse
2008-09-24 15:18:17 +00:00
parent 6ea8469987
commit 05edd05f7a
3 changed files with 9 additions and 2 deletions
+1
View File
@@ -30,6 +30,7 @@ class Test {
test("0 < 0",false);
test("-1 <= -1",true);
test("1 + 2",3);
test("~545",-546);
test("'abc' + 55","abc55");
test("'abc' + 'de'","abcde");
test("-1 + 2",1);
+6
View File
@@ -246,6 +246,12 @@ class Interp {
return increment(e,prefix,1);
case "--":
return increment(e,prefix,-1);
case "~":
#if neko
return haxe.Int32.complement(expr(e));
#else
return ~expr(e);
#end
default:
throw Error.EInvalidOp(op);
}
+2 -2
View File
@@ -61,7 +61,7 @@ class Parser {
public function new() {
line = 1;
opChars = "+*/-=!><&|^%";
opChars = "+*/-=!><&|^%~";
identChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
opPriority = [
"...",
@@ -74,7 +74,7 @@ class Parser {
"*","/",
"%"
];
unopsPrefix = ["!","++","--","-"];
unopsPrefix = ["!","++","--","-","~"];
unopsSuffix = ["++","--"];
}