better support for multiple input files:

- use a single AST_Toplevel node for all files
- keep original source filename in the tokens
This commit is contained in:
Mihai Bazon
2012-09-21 14:19:05 +03:00
parent c4f8c2103f
commit 5491e1d7b1
6 changed files with 96 additions and 93 deletions

View File

@@ -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);