Le 20/10/2012 22:41, Nicolas Cannasse a écrit :
Le 20/10/2012 19:19, Konstantin Tcholokachvili a écrit :
Hello,

I'm implementing a tool which trans-compiles (yet not complete) Python
into neko.
I implemented the abs() built-in function in Python, it's supposed to
give the absolute value of a number, for example abs(-30) must give
back 30.

So I've done:

var abs = function(n)
{
if (n < 0)
{
return n * -1;

Seems like a bug in the Neko parser, since n * (-1) works well ;)

Ok, found and fixed the bug in the parser.

Since there's no unary operation in Neko AST, -e was translated to 0-e, but this was then rewritten as n*0-1 instead of n*(0-1). This is now fixed.

Best,
Nicolas



--
Neko : One VM to run them all
(http://nekovm.org)

Reply via email to