diff options
author | Mihai Bazon <mihai@bazon.net> | 2012-09-21 14:19:05 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2012-09-21 14:19:05 +0300 |
commit | 5491e1d7b11e363c79bdd352883e92fa3b711e69 (patch) | |
tree | 3963c0888af492f12adf0cc1adc6556be79cd858 /lib/ast.js | |
parent | c4f8c2103fd77e3a6666034c2ca19a5ef09fe68b (diff) | |
download | tracifyjs-5491e1d7b11e363c79bdd352883e92fa3b711e69.tar.gz tracifyjs-5491e1d7b11e363c79bdd352883e92fa3b711e69.zip |
better support for multiple input files:
- use a single AST_Toplevel node for all files
- keep original source filename in the tokens
Diffstat (limited to 'lib/ast.js')
-rw-r--r-- | lib/ast.js | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -86,7 +86,7 @@ function DEFNODE(type, props, methods, base) { return ctor; }; -var AST_Token = DEFNODE("Token", "type value line col pos endpos nlb comments_before", { +var AST_Token = DEFNODE("Token", "type value line col pos endpos nlb comments_before file", { }, null); var AST_Node = DEFNODE("Node", "start end", { @@ -146,10 +146,12 @@ var AST_BlockStatement = DEFNODE("BlockStatement", null, { }, AST_Statement); function walk_body(node, visitor) { - if (node.body instanceof Array) node.body.forEach(function(stat){ + if (node.body instanceof AST_Statement) { + node.body._walk(visitor); + } + else node.body.forEach(function(stat){ stat._walk(visitor); }); - else if (node.body instanceof AST_Statement) node.body._walk(visitor); }; var AST_Block = DEFNODE("Block", null, { @@ -239,7 +241,7 @@ var AST_Scope = DEFNODE("Scope", "directives variables functions uses_with uses_ $documentation: "Base class for all statements introducing a lexical scope", }, AST_Block); -var AST_Toplevel = DEFNODE("Toplevel", null, { +var AST_Toplevel = DEFNODE("Toplevel", "globals", { $documentation: "The toplevel scope" }, AST_Scope); |