Open doerwalter opened 10 years ago
Hello.Where can I download PY3k ready Slimit version? Is some URL avail?
I successfully used my own fork, see https://github.com/rspivak/slimit/pull/65.
I see err with Py3.2 (embedded, can't use 3.3). I need 3.3 or...?
Python 3.2.5 (default, May 15 2013, 23:06:03) [MSC v.1500 32 bit (Intel)]
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "D:\S\Py\syn_js_minifier\__init__.py", line 8, in <module>
import slimit
File "D:\S\Py\syn_js_minifier\slimit\__init__.py", line 27, in <module>
from slimit.minifier import minify
File "D:\S\Py\syn_js_minifier\slimit\minifier.py", line 31, in <module>
from slimit import mangler
File "D:\S\Py\syn_js_minifier\slimit\mangler.py", line 27, in <module>
from slimit.scope import SymbolTable
File "D:\S\Py\syn_js_minifier\slimit\scope.py", line 34, in <module>
from slimit.lexer import Lexer
File "D:\S\Py\syn_js_minifier\slimit\lexer.py", line 29, in <module>
from slimit.unicode_chars import (
File "D:\S\Py\syn_js_minifier\slimit\unicode_chars.py", line 33
u'[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6'
^
SyntaxError: invalid syntax
File "D:\S\Py\syn_js_minifier\slimit\unicode_chars.py", line 33
u'[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6' ^ SyntaxError: invalid syntax
Yes, you need Python 3.3: the u'XY' syntax has been reintroduced in that version to make it easier sharing code between the 2.x line and >=3.3.
It seems that with ply 3.4 and slimit 0.8.1 the slice handling is the only remaining problem on Python 3.3. I can monkeypath around that problem like this:
from ply import yacc
import slimit
def __getitem__(self,n):
if isinstance(n, slice):
return self.__getslice__(n.start, n.stop)
if n >= 0: return self.slice[n].value
else: return self.stack[n].value
yacc.YaccProduction.__getitem__ = __getitem__
s = "function x(){switch (x) { case 17: break; case 23: break; }} "
print(slimit.minify(s))
I also tried the ply
version from github with some more errors. Maynbe you can fork ply with your current fix and relase it under a another name ... ugly i know
SyntaxError: Unexpected token (RBRACE, '}') at 1:1730813 between LexToken(ID,'disabled',1,1730804) and LexToken(RPAREN,')',1,1730814)
Do you mean that you tried mine fork of ply, and that gave you the reported error?
No sorry for the confusion,i tried the 3.5 vanilla version.
I'm trying to use slimit on Python 3 and get the following exception:
The problem seems to be that in Python 3 slices are handled via
__getitem__
not via__getslice__
.