hint that brackets may be required in AST_BlockStatement
This commit is contained in:
@@ -86,7 +86,7 @@ var AST_SimpleStatement = DEFNODE("SimpleStatement", null, {
|
|||||||
$documentation: "A statement consisting of an expression, i.e. a = 1 + 2."
|
$documentation: "A statement consisting of an expression, i.e. a = 1 + 2."
|
||||||
}, AST_Statement);
|
}, AST_Statement);
|
||||||
|
|
||||||
var AST_BlockStatement = DEFNODE("BlockStatement", null, {
|
var AST_BlockStatement = DEFNODE("BlockStatement", "required", {
|
||||||
$documentation: "A block statement.",
|
$documentation: "A block statement.",
|
||||||
_walk: function(visitor) {
|
_walk: function(visitor) {
|
||||||
return visitor._visit(this, function(){
|
return visitor._visit(this, function(){
|
||||||
|
|||||||
@@ -35,10 +35,6 @@ function Compressor(options) {
|
|||||||
return this;
|
return this;
|
||||||
});
|
});
|
||||||
|
|
||||||
AST_Token.DEFMETHOD("squeeze", function(){
|
|
||||||
return this;
|
|
||||||
});
|
|
||||||
|
|
||||||
function SQUEEZE(nodetype, squeeze) {
|
function SQUEEZE(nodetype, squeeze) {
|
||||||
nodetype.DEFMETHOD("squeeze", function(compressor){
|
nodetype.DEFMETHOD("squeeze", function(compressor){
|
||||||
compressor.push_node(this);
|
compressor.push_node(this);
|
||||||
|
|||||||
14
lib/parse.js
14
lib/parse.js
@@ -746,7 +746,7 @@ function parse($TEXT, exigent_mode) {
|
|||||||
case "punc":
|
case "punc":
|
||||||
switch (S.token.value) {
|
switch (S.token.value) {
|
||||||
case "{":
|
case "{":
|
||||||
return block_();
|
return block_(false);
|
||||||
case "[":
|
case "[":
|
||||||
case "(":
|
case "(":
|
||||||
return simple_statement();
|
return simple_statement();
|
||||||
@@ -938,7 +938,7 @@ function parse($TEXT, exigent_mode) {
|
|||||||
S.in_directives = true;
|
S.in_directives = true;
|
||||||
S.in_loop = 0;
|
S.in_loop = 0;
|
||||||
S.labels = [];
|
S.labels = [];
|
||||||
var a = block_();
|
var a = block_(true);
|
||||||
--S.in_function;
|
--S.in_function;
|
||||||
S.in_loop = loop;
|
S.in_loop = loop;
|
||||||
S.labels = labels;
|
S.labels = labels;
|
||||||
@@ -960,7 +960,7 @@ function parse($TEXT, exigent_mode) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function block_() {
|
function block_(required) {
|
||||||
var start = S.token;
|
var start = S.token;
|
||||||
expect("{");
|
expect("{");
|
||||||
var a = [];
|
var a = [];
|
||||||
@@ -971,6 +971,7 @@ function parse($TEXT, exigent_mode) {
|
|||||||
var end = S.token;
|
var end = S.token;
|
||||||
next();
|
next();
|
||||||
return new AST_BlockStatement({
|
return new AST_BlockStatement({
|
||||||
|
required : required,
|
||||||
start : start,
|
start : start,
|
||||||
body : a,
|
body : a,
|
||||||
end : end
|
end : end
|
||||||
@@ -1011,6 +1012,7 @@ function parse($TEXT, exigent_mode) {
|
|||||||
var end = S.token;
|
var end = S.token;
|
||||||
next();
|
next();
|
||||||
return new AST_SwitchBlock({
|
return new AST_SwitchBlock({
|
||||||
|
required : true,
|
||||||
start : start,
|
start : start,
|
||||||
body : a,
|
body : a,
|
||||||
end : end
|
end : end
|
||||||
@@ -1018,7 +1020,7 @@ function parse($TEXT, exigent_mode) {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
function try_() {
|
function try_() {
|
||||||
var body = block_(), bcatch = null, bfinally = null;
|
var body = block_(true), bcatch = null, bfinally = null;
|
||||||
if (is("keyword", "catch")) {
|
if (is("keyword", "catch")) {
|
||||||
var start = S.token;
|
var start = S.token;
|
||||||
next();
|
next();
|
||||||
@@ -1028,7 +1030,7 @@ function parse($TEXT, exigent_mode) {
|
|||||||
bcatch = new AST_Catch({
|
bcatch = new AST_Catch({
|
||||||
start : start,
|
start : start,
|
||||||
argname : name,
|
argname : name,
|
||||||
body : block_(),
|
body : block_(true),
|
||||||
end : prev()
|
end : prev()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1037,7 +1039,7 @@ function parse($TEXT, exigent_mode) {
|
|||||||
next();
|
next();
|
||||||
bfinally = new AST_Finally({
|
bfinally = new AST_Finally({
|
||||||
start : start,
|
start : start,
|
||||||
body : block_(),
|
body : block_(true),
|
||||||
end : prev()
|
end : prev()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(){
|
|||||||
// times on the same tree.
|
// times on the same tree.
|
||||||
|
|
||||||
// pass 1: setup scope chaining and handle definitions
|
// pass 1: setup scope chaining and handle definitions
|
||||||
var scope = null;
|
var scope = this.parent_scope;
|
||||||
var labels = {};
|
var labels = {};
|
||||||
var tw = new TreeWalker(function(node, descend){
|
var tw = new TreeWalker(function(node, descend){
|
||||||
if (node instanceof AST_Scope) {
|
if (node instanceof AST_Scope) {
|
||||||
|
|||||||
Reference in New Issue
Block a user