aboutsummaryrefslogtreecommitdiff
path: root/lib/parse.js
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-08-21 15:45:05 +0300
committerMihai Bazon <mihai@bazon.net>2012-08-21 16:14:43 +0300
commitffe58a9961ced012b40c16b93f9fe2370293431b (patch)
treee1436f3ebfb25d1abe37be859c5a9622f8aaba47 /lib/parse.js
parent7ae1c600a24e2f43feb839c5fd1625f6261751b5 (diff)
downloadtracifyjs-ffe58a9961ced012b40c16b93f9fe2370293431b.tar.gz
tracifyjs-ffe58a9961ced012b40c16b93f9fe2370293431b.zip
cleaned up some mess and started the actual compressor
Diffstat (limited to 'lib/parse.js')
-rw-r--r--lib/parse.js39
1 files changed, 19 insertions, 20 deletions
diff --git a/lib/parse.js b/lib/parse.js
index 78b8bb7c..7f144295 100644
--- a/lib/parse.js
+++ b/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()
});
}