cleaned up some mess and started the actual compressor
This commit is contained in:
39
lib/parse.js
39
lib/parse.js
@@ -746,7 +746,7 @@ function parse($TEXT, exigent_mode) {
|
||||
case "punc":
|
||||
switch (S.token.value) {
|
||||
case "{":
|
||||
return new AST_BlockStatement({ body: block_() });
|
||||
return block_();
|
||||
case "[":
|
||||
case "(":
|
||||
return simple_statement();
|
||||
@@ -942,7 +942,7 @@ function parse($TEXT, exigent_mode) {
|
||||
--S.in_function;
|
||||
S.in_loop = loop;
|
||||
S.labels = labels;
|
||||
return new AST_BlockStatement({ body: a });
|
||||
return a;
|
||||
})()
|
||||
});
|
||||
};
|
||||
@@ -961,19 +961,25 @@ function parse($TEXT, exigent_mode) {
|
||||
};
|
||||
|
||||
function block_() {
|
||||
var start = S.token;
|
||||
expect("{");
|
||||
var a = [];
|
||||
while (!is("punc", "}")) {
|
||||
if (is("eof")) unexpected();
|
||||
a.push(statement());
|
||||
}
|
||||
var end = S.token;
|
||||
next();
|
||||
return a;
|
||||
return new AST_BlockStatement({
|
||||
start : start,
|
||||
body : a,
|
||||
end : end
|
||||
});
|
||||
};
|
||||
|
||||
var switch_block_ = embed_tokens(curry(in_loop, function(){
|
||||
expect("{");
|
||||
var a = [], cur = null, branch = null;
|
||||
var a = [], cur = null, branch = null, start = S.token;
|
||||
while (!is("punc", "}")) {
|
||||
if (is("eof")) unexpected();
|
||||
if (is("keyword", "case")) {
|
||||
@@ -1002,16 +1008,17 @@ function parse($TEXT, exigent_mode) {
|
||||
}
|
||||
}
|
||||
if (branch) branch.end = prev();
|
||||
var end = S.token;
|
||||
next();
|
||||
return new AST_SwitchBlock({ body: a });
|
||||
return new AST_SwitchBlock({
|
||||
start : start,
|
||||
body : a,
|
||||
end : end
|
||||
});
|
||||
}));
|
||||
|
||||
function try_() {
|
||||
var body = new AST_BlockStatement({
|
||||
start : S.token,
|
||||
body : block_(),
|
||||
end : prev()
|
||||
}), bcatch = null, bfinally = null;
|
||||
var body = block_(), bcatch = null, bfinally = null;
|
||||
if (is("keyword", "catch")) {
|
||||
var start = S.token;
|
||||
next();
|
||||
@@ -1021,11 +1028,7 @@ function parse($TEXT, exigent_mode) {
|
||||
bcatch = new AST_Catch({
|
||||
start : start,
|
||||
argname : name,
|
||||
body : new AST_BlockStatement({
|
||||
start : S.token,
|
||||
body : block_(),
|
||||
end : prev()
|
||||
}),
|
||||
body : block_(),
|
||||
end : prev()
|
||||
});
|
||||
}
|
||||
@@ -1034,11 +1037,7 @@ function parse($TEXT, exigent_mode) {
|
||||
next();
|
||||
bfinally = new AST_Finally({
|
||||
start : start,
|
||||
body : new AST_BlockStatement({
|
||||
start : S.token,
|
||||
body : block_(),
|
||||
end : prev()
|
||||
}),
|
||||
body : block_(),
|
||||
end : prev()
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user