Problem with multiline strings #24

Closed
davidkhess opened this Issue Mar 13, 2012 · 3 comments

Comments

Projects
None yet
2 participants
@davidkhess

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

@ghost ghost assigned rspivak Mar 16, 2012

@rspivak

This comment has been minimized.

Show comment
Hide comment
@rspivak

rspivak Mar 16, 2012

Owner

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

Owner

rspivak commented Mar 16, 2012

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

@rspivak

This comment has been minimized.

Show comment
Hide comment
@rspivak

rspivak Apr 9, 2012

Owner

Hi David,

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

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

Thanks

Owner

rspivak commented Apr 9, 2012

Hi David,

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

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

Thanks

@rspivak

This comment has been minimized.

Show comment
Hide comment
@rspivak

rspivak Apr 17, 2012

Owner

Closing for now

Owner

rspivak commented Apr 17, 2012

Closing for now

@rspivak rspivak closed this Apr 17, 2012

acatton added a commit to acatton/fork--rspivak--slimit that referenced this issue Jan 26, 2015

Multiline string support - rspivak#24
Added support for JavaScript strings written across multiple lines
of code, as in:

var a = "hello \
world";

metatoaster added a commit to metatoaster/calmjs.parse that referenced this issue Apr 22, 2018

Rework correction of line continuation in strings
- Actually provide line continuation in strings that complies to the
  specification, which the fix provided by rspivak/slimit#24 was
  problematic (breaks position tracking) and incomplete as it amounted
  to no more than a clumsy workaround (come on, duplicated regex code).
- Also provide the expected minified output that would strip out these
  line continuation fragments.

metatoaster added a commit to metatoaster/calmjs.parse that referenced this issue Apr 22, 2018

Rework correction of line continuation in strings
- Actually provide line continuation in strings that complies to the
  specification, which the fix provided by rspivak/slimit#24 was
  problematic (breaks position tracking) and incomplete as it amounted
  to no more than a clumsy workaround (come on, duplicated regex code).
- Also provide the expected minified output that would strip out these
  line continuation fragments.

metatoaster added a commit to metatoaster/calmjs.parse that referenced this issue Apr 22, 2018

Rework correction of line continuation in strings
- Actually provide line continuation in strings that complies to the
  specification, which the fix provided by rspivak/slimit#24 was
  problematic (breaks position tracking) and incomplete as it amounted
  to no more than a clumsy workaround (come on, duplicated regex code).
- Also provide the expected minified output that would strip out these
  line continuation fragments.

metatoaster added a commit to metatoaster/calmjs.parse that referenced this issue Apr 22, 2018

Rework correction of line continuation in strings
- Actually provide line continuation in strings that complies to the
  specification, which the fix provided by rspivak/slimit#24 was
  problematic (breaks position tracking) and incomplete as it amounted
  to no more than a clumsy workaround (come on, duplicated regex code).
- Also provide the expected minified output that would strip out these
  line continuation fragments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment