Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

global symbol table is now a module and the parent of all root modules

  • Loading branch information...
commit cd5cb3694c48ddf3848d4d86d417df88ff9c37bf 1 parent 565d946
@ohjames authored
View
3  src/nyah/mousedeer/global_symbol_table.d
@@ -115,11 +115,12 @@ private struct SymbolTableBuilder {
}
}
-class GlobalSymbolTable : GlobalNamespace {
+class GlobalSymbolTable : Module {
// import code from ast of single object module into global symbol table
void import_(Ast ast) {
SymbolTableBuilder builder;
builder.namespace_ = this;
+ builder.parent_ = cast(Module)this;
builder.import_(ast);
}
View
11 src/nyah/mousedeer/io/symbol_table.d
@@ -12,9 +12,14 @@ struct SymbolTablePrinter {
private void printModule(Module v) {
print("module ");
- print(v.ids()[0].str);
- foreach (id ; v.ids()[1..$])
- print("." ~ id.str);
+ if (v.isGlobal) {
+ print("global");
+ }
+ else {
+ print(v.ids()[0].str);
+ foreach (id ; v.ids()[1..$])
+ print("." ~ id.str);
+ }
}
private void printGlobal(Global v) {
View
2  src/nyah/mousedeer/parser/nyah.d
@@ -347,6 +347,8 @@ class Module : GlobalNamespace {
JoinedPlusTight!(Char!".", Identifier),
Many!(Choice!(Function, VariableDefinition, Class)));
+ bool isGlobal() { return ids.length == 0; }
+
ref Range[] ids() { return value_[0]; }
auto ref members() { return value_[1]; }
}
View
4 src/nyah/mousedeer/test/output/class
@@ -55,14 +55,14 @@ ast beard.variant.Variant {
)
]
global {
- hello: module - parent [empty] {
+ hello: module - parent [module global] {
mod: module - parent [module hello] {
Bool: class - parent [module hello.mod] {
value: variable definition - parent [class Bool]
}
}
}
- another: module - parent [empty] {
+ another: module - parent [module global] {
subfriend: module - parent [module another] {
friend: variable definition - parent [module another.subfriend]
}
View
18 src/nyah/mousedeer/test/output/function
@@ -263,13 +263,13 @@ ast beard.variant.Variant {
)
]
global {
- vec4: function - parent [empty]
- puu: function - parent [empty]
- empty: function - parent [empty]
- add: function - parent [empty]
- vec1: function - parent [empty]
- vec5: function - parent [empty]
- tpar: function - parent [empty]
- vec2: function - parent [empty]
- vec3: function - parent [empty]
+ vec4: function - parent [module global]
+ puu: function - parent [module global]
+ empty: function - parent [module global]
+ add: function - parent [module global]
+ vec1: function - parent [module global]
+ vec5: function - parent [module global]
+ tpar: function - parent [module global]
+ vec2: function - parent [module global]
+ vec3: function - parent [module global]
}
View
6 src/nyah/mousedeer/test/output/misc
@@ -220,7 +220,7 @@ ast beard.variant.Variant {
)
]
global {
- hey: function - parent [empty]
- b: variable definition - parent [empty]
- c: variable definition - parent [empty]
+ hey: function - parent [module global]
+ b: variable definition - parent [module global]
+ c: variable definition - parent [module global]
}
Please sign in to comment.
Something went wrong with that request. Please try again.