aboutsummaryrefslogtreecommitdiff
path: root/lib/ast.js
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-09-21 14:19:05 +0300
committerMihai Bazon <mihai@bazon.net>2012-09-21 14:19:05 +0300
commit5491e1d7b11e363c79bdd352883e92fa3b711e69 (patch)
tree3963c0888af492f12adf0cc1adc6556be79cd858 /lib/ast.js
parentc4f8c2103fd77e3a6666034c2ca19a5ef09fe68b (diff)
downloadtracifyjs-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.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/ast.js b/lib/ast.js
index 6e05a396..19d9fbcd 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -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);