Skip to content
This repository

division with "this" fails #6

Closed
wkornewald opened this Issue September 29, 2011 · 5 comments

2 participants

Waldemar Kornewald Ruslan Spivak
Waldemar Kornewald

I'm trying to minify code generated by pyjs/pyjamas. Slimit fails on this snippet:

Number.prototype.rfloordiv = function (y) {
if (!y.number || isNaN(y = y.valueOf())) return @{{NotImplemented}};
if (this == 0) throw @{{ZeroDivisionError}}('float divmod');
return Math.floor(y / this);
};

Traceback (most recent call last):
...
File "...\slimit\minifier.py", line 38, in minify
tree = parser.parse(text)
File "...\slimit\parser.py", line 64, in parse
return self.parser.parse(text, lexer=self.lexer, debug=debug)
File "C:\Python26\lib\site-packages\ply\yacc.py", line 265, in parse
return self.parseopt_notrack(input,lexer,debug,tracking,tokenfunc)
File "C:\Python26\lib\site-packages\ply\yacc.py", line 1047, in parseopt_notrack
tok = self.errorfunc(errtoken)
File "...\slimit\parser.py", line 84, in p_error
self.lexer.prev_token, self.lexer.token())
SyntaxError: Unexpected token (REGEX, "/ y);\n};\n\nNumber.prototype.rfloordiv = function (y) {\n if (!y.number || isNaN(y = y.valueOf())) return $p['NotImplemented'];\n if (this == 0) throw $m'ZeroDivisionError';\n return Math.floor(y /") at 1:601787 between LexToken(THIS,'this',1,601782) and LexToken(THIS,'this',1,602015)

I tried browsing the code, but it would take me much too long to understand the parser (I've only worked with OMeta/PyMeta2). Could you please help?

Ruslan Spivak
Owner

Hey Waldemar,

Thanks for reporting the issue, I'll take a look at it today.

Ruslan Spivak
Owner

Could you provide a block of code that is located just above

Number.prototype.rfloordiv = function (y) {
if (!y.number || isNaN(y = y.valueOf())) return @{{NotImplemented}};
if (this == 0) throw @{{ZeroDivisionError}}('float divmod');
return Math.floor(y / this);
};
Waldemar Kornewald

Sure. I've uploaded the whole JS file here: http://dl.dropbox.com/u/20937738/pyjslib.js

Thank you!

Ruslan Spivak
Owner

I've made a fix and released a new version 0.5.4

Enjoy it :)

P.S.: I've also added your name to CREDIT file

Ruslan Spivak rspivak closed this September 30, 2011
Waldemar Kornewald

Thanks a lot. Next issue is coming... :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.