Skip to content
This repository
Browse code

Merge branch 'release/0.3.1'

  • Loading branch information...
commit 55b44ff4f2964422dfca5e2f31defd1883ea5fca 2 parents eb31d0c + e96cdb8
Ruslan Spivak authored
4 CHANGES
... ... @@ -1,6 +1,10 @@
1 1 Change History
2 2 --------------
3 3
  4 +0.3.1 (2011-05-09)
  5 +******************
  6 +- Use pre-generated lex and yacc tables when called from the command line
  7 +
4 8 0.3 (2011-05-09)
5 9 ****************
6 10 - Added minifier
2  setup.py
@@ -17,7 +17,7 @@ def read(*rel_names):
17 17
18 18 setup(
19 19 name='slimit',
20   - version='0.3',
  20 + version='0.3.1',
21 21 url='http://slimit.org',
22 22 license='MIT',
23 23 description='SlimIt - JavaScript minifier',
9 src/slimit/lextab.py
... ... @@ -0,0 +1,9 @@
  1 +# lextab.py. This file automatically created by PLY (version 3.4). Don't edit!
  2 +_tabversion = '3.4'
  3 +_lextokens = {'BLOCK_COMMENT': 1, 'SWITCH': 1, 'DIVEQUAL': 1, 'RSHIFT': 1, 'RSHIFTEQUAL': 1, 'DO': 1, 'EQEQ': 1, 'BOR': 1, 'NUMBER': 1, 'FUNCTION': 1, 'LBRACKET': 1, 'WHILE': 1, 'COLON': 1, 'BNOT': 1, 'LSHIFT': 1, 'NEW': 1, 'DIV': 1, 'NULL': 1, 'TRUE': 1, 'MINUS': 1, 'MULT': 1, 'STRING': 1, 'CASE': 1, 'LE': 1, 'RPAREN': 1, 'URSHIFT': 1, 'SEMI': 1, 'LINE_TERMINATOR': 1, 'BXOR': 1, 'MODEQUAL': 1, 'NE': 1, 'MULTEQUAL': 1, 'FINALLY': 1, 'DEFAULT': 1, 'LT': 1, 'CONTINUE': 1, 'PLUS': 1, 'CATCH': 1, 'COMMA': 1, 'STREQ': 1, 'VOID': 1, 'ID': 1, 'REGEX': 1, 'INSTANCEOF': 1, 'GT': 1, 'LINE_COMMENT': 1, 'RBRACE': 1, 'FOR': 1, 'PLUSPLUS': 1, 'PERIOD': 1, 'ELSE': 1, 'TRY': 1, 'BAND': 1, 'GE': 1, 'STRNEQ': 1, 'LPAREN': 1, 'IN': 1, 'VAR': 1, 'MINUSMINUS': 1, 'EQ': 1, 'OREQUAL': 1, 'IF': 1, 'AND': 1, 'RETURN': 1, 'LBRACE': 1, 'FALSE': 1, 'PLUSEQUAL': 1, 'THIS': 1, 'WITH': 1, 'MINUSEQUAL': 1, 'CONDOP': 1, 'XOREQUAL': 1, 'THROW': 1, 'BREAK': 1, 'URSHIFTEQUAL': 1, 'LSHIFTEQUAL': 1, 'TYPEOF': 1, 'NOT': 1, 'ANDEQUAL': 1, 'RBRACKET': 1, 'DELETE': 1, 'OR': 1, 'DEBUGGER': 1, 'MOD': 1}
  4 +_lexreflags = 0
  5 +_lexliterals = ''
  6 +_lexstateinfo = {'regex': 'exclusive', 'INITIAL': 'inclusive'}
  7 +_lexstatere = {'regex': [('(?P<t_regex_REGEX>(?:\n / # opening slash\n # First character is..\n (?: [^*\\\\/[] # anything but * \\ / or [\n | \\\\. # or an escape sequence\n | \\[ # or a class, which has\n (?: [^\\]\\\\] # anything but \\ or ]\n | \\\\. # or an escape sequence\n )* # many times\n \\]\n )\n # Following characters are same, except for excluding a star\n (?: [^\\\\/[] # anything but \\ / or [\n | \\\\. # or an escape sequence\n | \\[ # or a class, which has\n (?: [^\\]\\\\] # anything but \\ or ]\n | \\\\. # or an escape sequence\n )* # many times\n \\]\n )* # many times\n / # closing slash\n [a-zA-Z0-9]* # trailing flags\n )\n )', [None, (None, 'REGEX')])], 'INITIAL': [(u'(?P<t_NULL>null)|(?P<t_TRUE>true)|(?P<t_FALSE>false)|(?P<t_ID>(?:[a-zA-Z_$]|[A-Za-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0523\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0621-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971\u0972\u097b-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d3d\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc\u0edd\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8b\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10d0-\u10fa\u10fc\u1100-\u1159\u115f-\u11a2\u11a8-\u11f9\u1200-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u1676\u1681-\u169a\u16a0-\u16ea\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19a9\u19c1-\u19c7\u1a00-\u1a16\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u2094\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2183\u2184\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2c6f\u2c71-\u2c7d\u2c80-\u2ce4\u2d00-\u2d25\u2d30-\u2d65\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005\u3006\u3031-\u3035\u303b\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31b7\u31f0-\u31ff\u3400\u4db5\u4e00\u9fc3\ua000-\ua48c\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua65f\ua662-\ua66e\ua67f-\ua697\ua717-\ua71f\ua722-\ua788\ua78b\ua78c\ua7fb-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua90a-\ua925\ua930-\ua946\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uac00\ud7a3\uf900-\ufa2d\ufa30-\ufa6a\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc])+(?:[\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09c1-\u09c4\u09cd\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b62\u0b63\u0b82\u0bc0\u0bcd\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc6\u0ccc\u0ccd\u0ce2\u0ce3\u0d41-\u0d44\u0d4d\u0d62\u0d63\u0dca\u0dd2-\u0dd4\u0dd6\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\ufb1e\ufe00-\ufe0f\ufe20-\ufe26]|[\u0903\u093e-\u0940\u0949-\u094c\u094e\u0982\u0983\u09be-\u09c0\u09c7\u09c8\u09cb\u09cc\u09d7\u0a03\u0a3e-\u0a40\u0a83\u0abe-\u0ac0\u0ac9\u0acb\u0acc\u0b02\u0b03\u0b3e\u0b40\u0b47\u0b48\u0b4b\u0b4c\u0b57\u0bbe\u0bbf\u0bc1\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcc\u0bd7\u0c01-\u0c03\u0c41-\u0c44\u0c82\u0c83\u0cbe\u0cc0-\u0cc4\u0cc7\u0cc8\u0cca\u0ccb\u0cd5\u0cd6\u0d02\u0d03\u0d3e-\u0d40\u0d46-\u0d48\u0d4a-\u0d4c\u0d57\u0d82\u0d83\u0dcf-\u0dd1\u0dd8-\u0ddf\u0df2\u0df3\u0f3e\u0f3f\u0f7f\u102b\u102c\u1031\u1038\u103b\u103c\u1056\u1057\u1062-\u1064\u1067-\u106d\u1083\u1084\u1087-\u108c\u108f\u109a-\u109c\u17b6\u17be-\u17c5\u17c7\u17c8\u1923-\u1926\u1929-\u192b\u1930\u1931\u1933-\u1938\u19b0-\u19c0\u19c8\u19c9\u1a19-\u1a1b\u1a55\u1a57\u1a61\u1a63\u1a64\u1a6d-\u1a72\u1b04\u1b35\u1b3b\u1b3d-\u1b41\u1b43\u1b44\u1b82\u1ba1\u1ba6\u1ba7\u1baa\u1c24-\u1c2b\u1c34\u1c35\u1ce1\u1cf2\ua823\ua824\ua827\ua880\ua881\ua8b4-\ua8c3\ua952\ua953\ua983\ua9b4\ua9b5\ua9ba\ua9bb\ua9bd-\ua9c0\uaa2f\uaa30\uaa33\uaa34\uaa4d\uaa7b\uabe3\uabe4\uabe6\uabe7\uabe9\uabea\uabec]|[0-9a-zA-Z_$]|[0-9\u0660-\u0669\u06f0-\u06f9\u07c0-\u07c9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be6-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29\u1040-\u1049\u1090-\u1099\u17e0-\u17e9\u1810-\u1819\u1946-\u194f\u19d0-\u19da\u1a80-\u1a89\u1a90-\u1a99\u1b50-\u1b59\u1bb0-\u1bb9\u1c40-\u1c49\u1c50-\u1c59\ua620-\ua629\ua8d0-\ua8d9\ua900-\ua909\ua9d0-\ua9d9\uaa50-\uaa59\uabf0-\uabf9\uff10-\uff19]|[_\u203f\u2040\u2054\ufe33\ufe34\ufe4d-\ufe4f\uff3f])*)|(?P<t_STRING>\n (?:\n # double quoted string\n (?:" # opening double quote\n (?: [^"\\\\\\n\\r] # no escape chars, line terminators or "\n | \\\\[a-zA-Z\\\\\\\'"?] # or escaped characters\n | \\\\x[0-9a-fA-F]{2} # or hex_escape_sequence\n | \\\\u[0-9a-fA-F]{4} # or unicode_escape_sequence\n )*? # zero or many times\n ") # closing double quote\n |\n # single quoted string\n (?:\' # opening single quote\n (?: [^\'\\\\\\n\\r] # no escape chars, line terminators or \'\n | \\\\[a-zA-Z\\\\\'"?] # or escaped characters\n | \\\\x[0-9a-fA-F]{2} # or hex_escape_sequence\n | \\\\u[0-9a-fA-F]{4} # or unicode_escape_sequence\n )*? # zero or many times\n \') # closing single quote\n )\n )|(?P<t_NUMBER>\n (?:\n 0[xX][0-9a-fA-F]+ # hex_integer_literal\n | 0[0-7]+ # or octal_integer_literal (spec B.1.1)\n | (?: # or decimal_literal\n (?:0|[1-9][0-9]*) # decimal_integer_literal\n \\. # dot\n [0-9]* # decimal_digits_opt\n (?:[eE][+-]?[0-9]+)? # exponent_part_opt\n |\n \\. # dot\n [0-9]+ # decimal_digits\n (?:[eE][+-]?[0-9]+)? # exponent_part_opt\n |\n (?:0|[1-9][0-9]*) # decimal_integer_literal\n (?:[eE][+-]?[0-9]+)? # exponent_part_opt\n )\n )\n )|(?P<t_BLOCK_COMMENT>/\\*[^*]*\\*+([^/*][^*]*\\*+)*/)|(?P<t_LINE_COMMENT>//[^\\r\\n]*)|(?P<t_LINE_TERMINATOR>[\\n\\r]+)|(?P<t_PLUSPLUS>\\+\\+)|(?P<t_OR>\\|\\|)|(?P<t_URSHIFTEQUAL>>>>=)|(?P<t_XOREQUAL>\\^=)|(?P<t_OREQUAL>\\|=)|(?P<t_LSHIFTEQUAL><<=)|(?P<t_STRNEQ>!==)|(?P<t_RSHIFTEQUAL>>>=)|(?P<t_URSHIFT>>>>)|(?P<t_PLUSEQUAL>\\+=)|(?P<t_MULTEQUAL>\\*=)|(?P<t_STREQ>===)|(?P<t_PERIOD>\\.)|(?P<t_PLUS>\\+)|(?P<t_MODEQUAL>%=)|(?P<t_DIVEQUAL>/=)|(?P<t_RBRACKET>\\])|(?P<t_CONDOP>\\?)|(?P<t_BOR>\\|)|(?P<t_LSHIFT><<)|(?P<t_LE><=)|(?P<t_BXOR>\\^)|(?P<t_LPAREN>\\()|(?P<t_MULT>\\*)|(?P<t_NE>!=)|(?P<t_MINUSMINUS>--)|(?P<t_AND>&&)|(?P<t_LBRACKET>\\[)|(?P<t_GE>>=)|(?P<t_RPAREN>\\))|(?P<t_RSHIFT>>>)|(?P<t_ANDEQUAL>&=)|(?P<t_MINUSEQUAL>-=)|(?P<t_EQEQ>==)|(?P<t_LBRACE>{)|(?P<t_LT><)|(?P<t_COMMA>,)|(?P<t_EQ>=)|(?P<t_BNOT>~)|(?P<t_RBRACE>})|(?P<t_DIV>/)|(?P<t_MOD>%)|(?P<t_SEMI>;)|(?P<t_MINUS>-)|(?P<t_GT>>)|(?P<t_COLON>:)|(?P<t_BAND>&)|(?P<t_NOT>!)', [None, (u't_NULL', 'NULL'), (u't_TRUE', 'TRUE'), (u't_FALSE', 'FALSE'), (u't_ID', 'ID'), (None, 'STRING'), (None, 'NUMBER'), (None, 'BLOCK_COMMENT'), None, (None, 'LINE_COMMENT'), (None, 'LINE_TERMINATOR'), (None, 'PLUSPLUS'), (None, 'OR'), (None, 'URSHIFTEQUAL'), (None, 'XOREQUAL'), (None, 'OREQUAL'), (None, 'LSHIFTEQUAL'), (None, 'STRNEQ'), (None, 'RSHIFTEQUAL'), (None, 'URSHIFT'), (None, 'PLUSEQUAL'), (None, 'MULTEQUAL'), (None, 'STREQ'), (None, 'PERIOD'), (None, 'PLUS'), (None, 'MODEQUAL'), (None, 'DIVEQUAL'), (None, 'RBRACKET'), (None, 'CONDOP'), (None, 'BOR'), (None, 'LSHIFT'), (None, 'LE'), (None, 'BXOR'), (None, 'LPAREN'), (None, 'MULT'), (None, 'NE'), (None, 'MINUSMINUS'), (None, 'AND'), (None, 'LBRACKET'), (None, 'GE'), (None, 'RPAREN'), (None, 'RSHIFT'), (None, 'ANDEQUAL'), (None, 'MINUSEQUAL'), (None, 'EQEQ'), (None, 'LBRACE'), (None, 'LT'), (None, 'COMMA'), (None, 'EQ'), (None, 'BNOT'), (None, 'RBRACE'), (None, 'DIV'), (None, 'MOD'), (None, 'SEMI'), (None, 'MINUS'), (None, 'GT'), (None, 'COLON'), (None, 'BAND'), (None, 'NOT')])]}
  8 +_lexstateignore = {'regex': ' \t', 'INITIAL': ' \t'}
  9 +_lexstateerrorf = {'regex': 't_regex_error', 'INITIAL': 't_error'}
15 src/slimit/minifier.py
@@ -32,8 +32,8 @@
32 32 from slimit.visitors.minvisitor import ECMAMinifier
33 33
34 34
35   -def minify(text):
36   - parser = Parser()
  35 +def minify(text, lextab='lextab', yacctab='yacctab'):
  36 + parser = Parser(lextab=lextab, yacctab=yacctab)
37 37 tree = parser.parse(text)
38 38 minified = ECMAMinifier().visit(tree)
39 39 return minified
@@ -48,10 +48,19 @@ def main():
48 48 parser = optparse.OptionParser(usage=usage)
49 49 options, args = parser.parse_args()
50 50
  51 + # Hack to load lextab and yacctab when installed via pip/easy_install
  52 + # and used from the command line via call to 'slimit'
  53 + try:
  54 + lextab = __import__('lextab')
  55 + yacctab = __import__('yacctab')
  56 + except ImportError:
  57 + lextab = 'lextab'
  58 + yacctab = 'yacctab'
  59 +
51 60 if len(args) == 1:
52 61 text = open(args[1]).read()
53 62 else:
54 63 text = sys.stdin.read()
55 64
56   - minified = minify(text)
  65 + minified = minify(text, lextab=lextab, yacctab=yacctab)
57 66 sys.stdout.write(minified)
326 src/slimit/yacctab.py
326 additions, 0 deletions not shown

0 comments on commit 55b44ff

Please sign in to comment.
Something went wrong with that request. Please try again.