rspivak / slimit

SlimIt - a JavaScript minifier/parser in Python
MIT License
551 stars 94 forks source link

Slimit crashes on Flot #2

Closed RuiPereira closed 13 years ago

RuiPereira commented 13 years ago

While using slimit on flot (https://github.com/flot/flot), it crashes:

$ cat jquery.flot.js | slimit
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/slimit", line 9, in 
    load_entry_point('slimit==0.6dev', 'console_scripts', 'slimit')()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/slimit-0.6dev-py2.6.egg/slimit/minifier.py", line 62, in main
    minified = minify(text, mangle=options.mangle)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/slimit-0.6dev-py2.6.egg/slimit/minifier.py", line 38, in minify
    tree = parser.parse(text)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/slimit-0.6dev-py2.6.egg/slimit/parser.py", line 64, in parse
    return self.parser.parse(text, lexer=self.lexer, debug=debug)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ply/yacc.py", line 265, in parse
    return self.parseopt_notrack(input,lexer,debug,tracking,tokenfunc)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ply/yacc.py", line 1047, in parseopt_notrack
    tok = self.errorfunc(errtoken)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/slimit-0.6dev-py2.6.egg/slimit/parser.py", line 87, in p_error
    self.lexer.prev_token, self.lexer.token())
SyntaxError: Unexpected token (NULL, 'null') at 1:25224 between LexToken(VAR,'var',1,25220) and LexToken(ID,'ify',1,25228)

Quite possibly on line 558:

var nullify = p == null;
rspivak commented 13 years ago

Thanks for the bug report. I've made a fix and released a new version 0.5.1. I've also added you to the CREDIT file.

RuiPereira commented 13 years ago

Great, it works now, thanks.

rspivak commented 13 years ago

You're welcome.