hint that brackets may be required in AST_BlockStatement

This commit is contained in:
Mihai Bazon
2012-08-21 16:27:57 +03:00
parent ffe58a9961
commit 1b839eb35b
4 changed files with 16 additions and 18 deletions

View File

@@ -746,7 +746,7 @@ function parse($TEXT, exigent_mode) {
case "punc":
switch (S.token.value) {
case "{":
return block_();
return block_(false);
case "[":
case "(":
return simple_statement();
@@ -938,7 +938,7 @@ function parse($TEXT, exigent_mode) {
S.in_directives = true;
S.in_loop = 0;
S.labels = [];
var a = block_();
var a = block_(true);
--S.in_function;
S.in_loop = loop;
S.labels = labels;
@@ -960,7 +960,7 @@ function parse($TEXT, exigent_mode) {
});
};
function block_() {
function block_(required) {
var start = S.token;
expect("{");
var a = [];
@@ -971,9 +971,10 @@ function parse($TEXT, exigent_mode) {
var end = S.token;
next();
return new AST_BlockStatement({
start : start,
body : a,
end : end
required : required,
start : start,
body : a,
end : end
});
};
@@ -1011,14 +1012,15 @@ function parse($TEXT, exigent_mode) {
var end = S.token;
next();
return new AST_SwitchBlock({
start : start,
body : a,
end : end
required : true,
start : start,
body : a,
end : end
});
}));
function try_() {
var body = block_(), bcatch = null, bfinally = null;
var body = block_(true), bcatch = null, bfinally = null;
if (is("keyword", "catch")) {
var start = S.token;
next();
@@ -1028,7 +1030,7 @@ function parse($TEXT, exigent_mode) {
bcatch = new AST_Catch({
start : start,
argname : name,
body : block_(),
body : block_(true),
end : prev()
});
}
@@ -1037,7 +1039,7 @@ function parse($TEXT, exigent_mode) {
next();
bfinally = new AST_Finally({
start : start,
body : block_(),
body : block_(true),
end : prev()
});
}