diff options
Diffstat (limited to 'lib/ast.js')
-rw-r--r-- | lib/ast.js | 27 |
1 files changed, 10 insertions, 17 deletions
@@ -123,7 +123,7 @@ var AST_Directive = DEFNODE("Directive", "value scope", { }, AST_Statement); var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", { - $documentation: "A statement consisting of an expression, i.e. a = 1 + 2.", + $documentation: "A statement consisting of an expression, i.e. a = 1 + 2", _walk: function(visitor) { return visitor._visit(this, function(){ this.body._walk(visitor); @@ -131,17 +131,6 @@ var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", { } }, AST_Statement); -var AST_BlockStatement = DEFNODE("BlockStatement", "body", { - $documentation: "A block statement.", - _walk: function(visitor) { - return visitor._visit(this, function(){ - this.body.forEach(function(stat){ - stat._walk(visitor); - }); - }); - } -}, AST_Statement); - function walk_body(node, visitor) { if (node.body instanceof AST_Statement) { node.body._walk(visitor); @@ -152,7 +141,7 @@ function walk_body(node, visitor) { }; var AST_Block = DEFNODE("Block", "body", { - $documentation: "A block of statements (usually always bracketed)", + $documentation: "A body of statements (usually bracketed)", _walk: function(visitor) { return visitor._visit(this, function(){ walk_body(this, visitor); @@ -160,15 +149,19 @@ var AST_Block = DEFNODE("Block", "body", { } }, AST_Statement); +var AST_BlockStatement = DEFNODE("BlockStatement", null, { + $documentation: "A block statement", +}, AST_Block); + var AST_EmptyStatement = DEFNODE("EmptyStatement", null, { - $documentation: "The empty statement (empty block or simply a semicolon).", + $documentation: "The empty statement (empty block or simply a semicolon)", _walk: function(visitor) { return visitor._visit(this); } }, AST_Statement); var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", { - $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`.", + $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`", _walk: function(visitor) { return visitor._visit(this, function(){ this.body._walk(visitor); @@ -187,7 +180,7 @@ var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", { }, AST_StatementWithBody); var AST_DWLoop = DEFNODE("DWLoop", "condition", { - $documentation: "Base class for do/while statements.", + $documentation: "Base class for do/while statements", _walk: function(visitor) { return visitor._visit(this, function(){ this.condition._walk(visitor); @@ -469,7 +462,7 @@ var AST_Call = DEFNODE("Call", "expression args", { }); var AST_New = DEFNODE("New", null, { - $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties." + $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties" }, AST_Call); var AST_Seq = DEFNODE("Seq", "car cdr", { |