rspivak / slimit

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

Problem with multiline strings #24

Closed davidkhess closed 12 years ago

davidkhess commented 12 years ago

First of all, thanks for slimit! Nice tool.

Ran into a bug with multiline strings. If you provide this input:

var a = " \
";

You get this traceback:

Illegal character '"'
Illegal character '\\'
Illegal character '"'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/databakery/deployments/deployment-development/virtualenv/lib/python2.6/site-packages/slimit/minifier.py", line 38, in minify
    tree = parser.parse(text)
  File "/home/databakery/deployments/deployment-development/virtualenv/lib/python2.6/site-packages/slimit/parser.py", line 64, in parse
    return self.parser.parse(text, lexer=self.lexer, debug=debug)
  File "/home/databakery/deployments/deployment-development/virtualenv/lib/python2.6/site-packages/ply/yacc.py", line 265, in parse
    return self.parseopt_notrack(input,lexer,debug,tracking,tokenfunc)
  File "/home/databakery/deployments/deployment-development/virtualenv/lib/python2.6/site-packages/ply/yacc.py", line 1047, in parseopt_notrack
    tok = self.errorfunc(errtoken)
  File "/home/databakery/deployments/deployment-development/virtualenv/lib/python2.6/site-packages/slimit/parser.py", line 84, in p_error
    self.lexer.prev_token, self.lexer.token())
SyntaxError: Unexpected token (SEMI, ';') at 1:13 between LexToken(LINE_TERMINATOR,'\n',1,11) and None
rspivak commented 12 years ago

I'll look into it. Thanks again for reporting.

rspivak commented 12 years ago

Hi David,

Took me a little bit longer than I anticipated but I've just committed the code to support multiline strings: 8839a0138d13a8614f3d6e14765aeef55239a47b

Could you install SlimIt from the master branch and check if it solves the issue you had.

Thanks

rspivak commented 12 years ago

Closing for now