MediaWiki REL1_34
|
JSMinPlus version 1.4. More...
Go to the source code of this file.
Classes | |
class | JSCompilerContext |
class | JSMinPlus |
class | JSNode |
class | JSParser |
class | JSToken |
class | JSTokenizer |
Variables | |
const | DECLARED_FORM 0 |
const | EXPRESSED_FORM 1 |
const | JS_ARRAY_INIT 107 |
const | JS_BLOCK 101 |
const | JS_CALL 104 |
const | JS_FOR_IN 103 |
const | JS_GETTER 110 |
const | JS_GROUP 112 |
const | JS_INDEX 106 |
const | JS_LABEL 102 |
const | JS_LIST 113 |
const | JS_MINIFIED 999 |
const | JS_NEW_WITH_ARGS 105 |
const | JS_OBJECT_INIT 108 |
const | JS_PROPERTY_INIT 109 |
const | JS_SCRIPT 100 |
const | JS_SETTER 111 |
const | KEYWORD_BREAK 'break' |
const | KEYWORD_CASE 'case' |
const | KEYWORD_CATCH 'catch' |
const | KEYWORD_CONST 'const' |
const | KEYWORD_CONTINUE 'continue' |
const | KEYWORD_DEBUGGER 'debugger' |
const | KEYWORD_DEFAULT 'default' |
const | KEYWORD_DELETE 'delete' |
const | KEYWORD_DO 'do' |
const | KEYWORD_ELSE 'else' |
const | KEYWORD_ENUM 'enum' |
const | KEYWORD_FALSE 'false' |
const | KEYWORD_FINALLY 'finally' |
const | KEYWORD_FOR 'for' |
const | KEYWORD_FUNCTION 'function' |
const | KEYWORD_IF 'if' |
const | KEYWORD_IN 'in' |
const | KEYWORD_INSTANCEOF 'instanceof' |
const | KEYWORD_NEW 'new' |
const | KEYWORD_NULL 'null' |
const | KEYWORD_RETURN 'return' |
const | KEYWORD_SWITCH 'switch' |
const | KEYWORD_THIS 'this' |
const | KEYWORD_THROW 'throw' |
const | KEYWORD_TRUE 'true' |
const | KEYWORD_TRY 'try' |
const | KEYWORD_TYPEOF 'typeof' |
const | KEYWORD_VAR 'var' |
const | KEYWORD_VOID 'void' |
const | KEYWORD_WHILE 'while' |
const | KEYWORD_WITH 'with' |
const | OP_AND '&&' |
const | OP_ASSIGN '=' |
const | OP_BITWISE_AND '&' |
const | OP_BITWISE_NOT '~' |
const | OP_BITWISE_OR '|' |
const | OP_BITWISE_XOR '^' |
const | OP_COLON ':' |
const | OP_COMMA ',' |
const | OP_CONDCOMMENT_END '@*/' |
const | OP_DECREMENT '--' |
const | OP_DIV '/' |
const | OP_DOT '.' |
const | OP_EQ '==' |
const | OP_GE '>=' |
const | OP_GT '>' |
const | OP_HOOK '?' |
const | OP_INCREMENT '++' |
const | OP_LE '<=' |
const | OP_LEFT_BRACKET '[' |
const | OP_LEFT_CURLY '{' |
const | OP_LEFT_PAREN '(' |
const | OP_LSH '<<' |
const | OP_LT '<' |
const | OP_MINUS '-' |
const | OP_MOD '%' |
const | OP_MUL '*' |
const | OP_NE '!=' |
const | OP_NOT '!' |
const | OP_OR '||' |
const | OP_PLUS '+' |
const | OP_RIGHT_BRACKET ']' |
const | OP_RIGHT_CURLY '}' |
const | OP_RIGHT_PAREN ')' |
const | OP_RSH '>>' |
const | OP_SEMICOLON ';' |
const | OP_STRICT_EQ '===' |
const | OP_STRICT_NE '!==' |
const | OP_UNARY_MINUS 'U-' |
const | OP_UNARY_PLUS 'U+' |
const | OP_URSH '>>>' |
const | STATEMENT_FORM 2 |
const | TOKEN_CONDCOMMENT_END 8 |
const | TOKEN_CONDCOMMENT_START 7 |
const | TOKEN_END 1 |
const | TOKEN_IDENTIFIER 3 |
const | TOKEN_NEWLINE 6 |
const | TOKEN_NUMBER 2 |
const | TOKEN_REGEXP 5 |
const | TOKEN_STRING 4 |
JSMinPlus version 1.4.
Minifies a javascript file using a javascript parser
This implements a PHP port of Brendan Eich's Narcissus open source javascript engine (in javascript) References: https://en.wikipedia.org/wiki/Narcissus_(JavaScript_engine) Narcissus sourcecode: https://mxr.mozilla.org/mozilla/source/js/narcissus/ JSMinPlus weblog: https://crisp.tweakblogs.net/blog/cat/716
Tino Zijdel crisp.nosp@m.@twe.nosp@m.akers.nosp@m..net
Usage: $minified = JSMinPlus::minify($script [, $filename])
Versionlog (see also changelog.txt): 23-07-2011 - remove dynamic creation of OP_* and KEYWORD_* defines and declare them on top reduce memory footprint by minifying by block-scope some small byte-saving and performance improvements 12-05-2009 - fixed hook:colon precedence, fixed empty body in loop and if-constructs 18-04-2009 - fixed crashbug in PHP 5.2.9 and several other bugfixes 12-04-2009 - some small bugfixes and performance improvements 09-04-2009 - initial open sourced version 1.0
Latest version of this script: http://files.tweakers.net/jsminplus/jsminplus.zip
Definition in file jsminplus.php.
const DECLARED_FORM 0 |
Definition at line 94 of file jsminplus.php.
Referenced by JSParser\FunctionDefinition(), JSMinPlus\parseTree(), and JSParser\Statement().
const EXPRESSED_FORM 1 |
Definition at line 95 of file jsminplus.php.
Referenced by JSParser\Expression().
const JS_ARRAY_INIT 107 |
Definition at line 84 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const JS_BLOCK 101 |
Definition at line 78 of file jsminplus.php.
Referenced by JSMinPlus\parseTree(), JSParser\Statement(), and JSParser\Statements().
const JS_CALL 104 |
Definition at line 81 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const JS_FOR_IN 103 |
Definition at line 80 of file jsminplus.php.
Referenced by JSMinPlus\parseTree(), and JSParser\Statement().
const JS_GETTER 110 |
Definition at line 87 of file jsminplus.php.
Referenced by JSParser\FunctionDefinition(), and JSMinPlus\parseTree().
const JS_GROUP 112 |
Definition at line 89 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const JS_INDEX 106 |
Definition at line 83 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const JS_LABEL 102 |
Definition at line 79 of file jsminplus.php.
Referenced by JSMinPlus\parseTree(), and JSParser\Statement().
const JS_LIST 113 |
Definition at line 90 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const JS_MINIFIED 999 |
Definition at line 92 of file jsminplus.php.
Referenced by JSMinPlus\parseTree(), and JSParser\Script().
const JS_NEW_WITH_ARGS 105 |
Definition at line 82 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const JS_OBJECT_INIT 108 |
Definition at line 85 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const JS_PROPERTY_INIT 109 |
Definition at line 86 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const JS_SCRIPT 100 |
Definition at line 77 of file jsminplus.php.
Referenced by JSMinPlus\parseTree(), and JSParser\Script().
const JS_SETTER 111 |
Definition at line 88 of file jsminplus.php.
Referenced by JSParser\FunctionDefinition().
const KEYWORD_BREAK 'break' |
Definition at line 142 of file jsminplus.php.
Referenced by JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const KEYWORD_CASE 'case' |
Definition at line 143 of file jsminplus.php.
Referenced by JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const KEYWORD_CATCH 'catch' |
Definition at line 144 of file jsminplus.php.
Referenced by JSParser\isKeyword(), and JSParser\Statement().
const KEYWORD_CONST 'const' |
Definition at line 145 of file jsminplus.php.
Referenced by JSParser\isKeyword(), JSMinPlus\parseTree(), JSParser\Statement(), and JSParser\Variables().
const KEYWORD_CONTINUE 'continue' |
Definition at line 146 of file jsminplus.php.
Referenced by JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const KEYWORD_DEBUGGER 'debugger' |
Definition at line 147 of file jsminplus.php.
Referenced by JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const KEYWORD_DEFAULT 'default' |
Definition at line 148 of file jsminplus.php.
Referenced by JSParser\isKeyword(), and JSParser\Statement().
const KEYWORD_DELETE 'delete' |
Definition at line 149 of file jsminplus.php.
Referenced by JSParser\Expression(), JSParser\isKeyword(), and JSMinPlus\parseTree().
const KEYWORD_DO 'do' |
Definition at line 150 of file jsminplus.php.
Referenced by JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const KEYWORD_ELSE 'else' |
Definition at line 151 of file jsminplus.php.
Referenced by JSParser\isKeyword(), and JSParser\Statement().
const KEYWORD_ENUM 'enum' |
Definition at line 152 of file jsminplus.php.
Referenced by JSParser\isKeyword().
const KEYWORD_FALSE 'false' |
Definition at line 153 of file jsminplus.php.
Referenced by JSParser\Expression(), JSParser\isKeyword(), and JSMinPlus\parseTree().
const KEYWORD_FINALLY 'finally' |
Definition at line 154 of file jsminplus.php.
Referenced by JSParser\isKeyword(), and JSParser\Statement().
const KEYWORD_FOR 'for' |
Definition at line 155 of file jsminplus.php.
Referenced by JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const KEYWORD_FUNCTION 'function' |
Definition at line 156 of file jsminplus.php.
Referenced by JSParser\Expression(), JSParser\FunctionDefinition(), JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const KEYWORD_IF 'if' |
Definition at line 157 of file jsminplus.php.
Referenced by JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const KEYWORD_IN 'in' |
Definition at line 158 of file jsminplus.php.
Referenced by JSParser\Expression(), JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const KEYWORD_INSTANCEOF 'instanceof' |
Definition at line 159 of file jsminplus.php.
Referenced by JSParser\Expression(), JSParser\isKeyword(), and JSMinPlus\parseTree().
const KEYWORD_NEW 'new' |
Definition at line 160 of file jsminplus.php.
Referenced by JSParser\Expression(), JSParser\isKeyword(), and JSMinPlus\parseTree().
const KEYWORD_NULL 'null' |
Definition at line 161 of file jsminplus.php.
Referenced by JSParser\Expression(), JSParser\isKeyword(), and JSMinPlus\parseTree().
const KEYWORD_RETURN 'return' |
Definition at line 162 of file jsminplus.php.
Referenced by JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const KEYWORD_SWITCH 'switch' |
Definition at line 163 of file jsminplus.php.
Referenced by JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const KEYWORD_THIS 'this' |
Definition at line 164 of file jsminplus.php.
Referenced by JSParser\Expression(), JSParser\isKeyword(), and JSMinPlus\parseTree().
const KEYWORD_THROW 'throw' |
Definition at line 165 of file jsminplus.php.
Referenced by JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const KEYWORD_TRUE 'true' |
Definition at line 166 of file jsminplus.php.
Referenced by JSParser\Expression(), JSParser\isKeyword(), and JSMinPlus\parseTree().
const KEYWORD_TRY 'try' |
Definition at line 167 of file jsminplus.php.
Referenced by JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const KEYWORD_TYPEOF 'typeof' |
Definition at line 168 of file jsminplus.php.
Referenced by JSParser\Expression(), JSParser\isKeyword(), and JSMinPlus\parseTree().
const KEYWORD_VAR 'var' |
Definition at line 169 of file jsminplus.php.
Referenced by JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const KEYWORD_VOID 'void' |
Definition at line 170 of file jsminplus.php.
Referenced by JSParser\Expression(), JSParser\isKeyword(), and JSMinPlus\parseTree().
const KEYWORD_WHILE 'while' |
Definition at line 171 of file jsminplus.php.
Referenced by JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const KEYWORD_WITH 'with' |
Definition at line 172 of file jsminplus.php.
Referenced by JSParser\isKeyword(), JSMinPlus\parseTree(), and JSParser\Statement().
const OP_AND '&&' |
Definition at line 104 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_ASSIGN '=' |
Definition at line 110 of file jsminplus.php.
Referenced by JSParser\Expression(), JSTokenizer\get(), JSMinPlus\parseTree(), and JSParser\Variables().
const OP_BITWISE_AND '&' |
Definition at line 107 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_BITWISE_NOT '~' |
Definition at line 128 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_BITWISE_OR '|' |
Definition at line 105 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_BITWISE_XOR '^' |
Definition at line 106 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_COLON ':' |
Definition at line 102 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSParser\Statement().
const OP_COMMA ',' |
Definition at line 100 of file jsminplus.php.
Referenced by JSParser\Expression(), JSParser\FunctionDefinition(), JSMinPlus\parseTree(), and JSParser\Variables().
const OP_CONDCOMMENT_END '@*/' |
Definition at line 136 of file jsminplus.php.
const OP_DECREMENT '--' |
Definition at line 121 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_DIV '/' |
Definition at line 125 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_DOT '.' |
Definition at line 129 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_EQ '==' |
Definition at line 109 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_GE '>=' |
Definition at line 118 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_GT '>' |
Definition at line 119 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_HOOK '?' |
Definition at line 101 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_INCREMENT '++' |
Definition at line 120 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_LE '<=' |
Definition at line 114 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_LEFT_BRACKET '[' |
Definition at line 130 of file jsminplus.php.
Referenced by JSParser\Expression().
const OP_LEFT_CURLY '{' |
Definition at line 132 of file jsminplus.php.
Referenced by JSParser\Block(), JSParser\Expression(), JSParser\FunctionDefinition(), and JSParser\Statement().
const OP_LEFT_PAREN '(' |
Definition at line 134 of file jsminplus.php.
Referenced by JSParser\Expression(), JSParser\FunctionDefinition(), JSParser\ParenExpression(), and JSParser\Statement().
const OP_LSH '<<' |
Definition at line 113 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_LT '<' |
Definition at line 115 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_MINUS '-' |
Definition at line 123 of file jsminplus.php.
Referenced by JSParser\Expression(), JSTokenizer\get(), and JSMinPlus\parseTree().
const OP_MOD '%' |
Definition at line 126 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_MUL '*' |
Definition at line 124 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_NE '!=' |
Definition at line 112 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_NOT '!' |
Definition at line 127 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_OR '||' |
Definition at line 103 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_PLUS '+' |
Definition at line 122 of file jsminplus.php.
Referenced by JSParser\Expression(), JSTokenizer\get(), and JSMinPlus\parseTree().
const OP_RIGHT_BRACKET ']' |
Definition at line 131 of file jsminplus.php.
Referenced by JSParser\Expression().
const OP_RIGHT_CURLY '}' |
Definition at line 133 of file jsminplus.php.
Referenced by JSParser\Block(), JSParser\Expression(), JSParser\FunctionDefinition(), JSParser\Statement(), and JSParser\Statements().
const OP_RIGHT_PAREN ')' |
Definition at line 135 of file jsminplus.php.
Referenced by JSParser\Expression(), JSParser\FunctionDefinition(), JSParser\ParenExpression(), and JSParser\Statement().
const OP_RSH '>>' |
Definition at line 117 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_SEMICOLON ';' |
Definition at line 99 of file jsminplus.php.
Referenced by JSParser\Expression(), JSMinPlus\parseTree(), and JSParser\Statement().
const OP_STRICT_EQ '===' |
Definition at line 108 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_STRICT_NE '!==' |
Definition at line 111 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const OP_UNARY_MINUS 'U-' |
Definition at line 139 of file jsminplus.php.
Referenced by JSParser\Expression(), JSTokenizer\get(), and JSMinPlus\parseTree().
const OP_UNARY_PLUS 'U+' |
Definition at line 138 of file jsminplus.php.
Referenced by JSParser\Expression(), JSTokenizer\get(), and JSMinPlus\parseTree().
const OP_URSH '>>>' |
Definition at line 116 of file jsminplus.php.
Referenced by JSParser\Expression(), and JSMinPlus\parseTree().
const STATEMENT_FORM 2 |
Definition at line 96 of file jsminplus.php.
Referenced by JSParser\Statement().
const TOKEN_CONDCOMMENT_END 8 |
Definition at line 75 of file jsminplus.php.
Referenced by JSParser\Expression(), JSTokenizer\get(), JSMinPlus\parseTree(), and JSParser\Statement().
const TOKEN_CONDCOMMENT_START 7 |
Definition at line 74 of file jsminplus.php.
Referenced by JSParser\Expression(), JSTokenizer\get(), JSMinPlus\parseTree(), and JSParser\Statement().
const TOKEN_END 1 |
Definition at line 68 of file jsminplus.php.
Referenced by JSParser\Expression(), JSTokenizer\get(), JSTokenizer\isDone(), and JSParser\Statement().
const TOKEN_IDENTIFIER 3 |
Definition at line 70 of file jsminplus.php.
Referenced by JSParser\Expression(), JSParser\FunctionDefinition(), JSTokenizer\get(), JSMinPlus\parseTree(), JSParser\Statement(), and JSParser\Variables().
const TOKEN_NEWLINE 6 |
Definition at line 73 of file jsminplus.php.
Referenced by JSTokenizer\get(), JSTokenizer\peek(), and JSParser\Statement().
const TOKEN_NUMBER 2 |
Definition at line 69 of file jsminplus.php.
Referenced by JSParser\Expression(), JSTokenizer\get(), and JSMinPlus\parseTree().
const TOKEN_REGEXP 5 |
Definition at line 72 of file jsminplus.php.
Referenced by JSParser\Expression(), JSTokenizer\get(), and JSMinPlus\parseTree().
const TOKEN_STRING 4 |
Definition at line 71 of file jsminplus.php.
Referenced by JSParser\Expression(), JSTokenizer\get(), and JSMinPlus\parseTree().