diff --git a/NouVeL/NVL.cpp b/NouVeL/NVL.cpp index 50e97f0..06e525b 100644 --- a/NouVeL/NVL.cpp +++ b/NouVeL/NVL.cpp @@ -151,7 +151,7 @@ namespace NVL { Object this_object; Context this_context = parent_context; - this_context.Scope_Hierarchy.push_back(this_object); + this_context.Scope_Hierarchy.push_back(&this_object); skip_ws(nvl); @@ -247,11 +247,13 @@ namespace NVL this_object.Is_Symbol = is_symbol; if (is_parent_call) - (std::get>(parent_context.Scope_Hierarchy.back())).get().Objects.push_back(this_object); - else if ((std::get>(parent_context.Scope_Hierarchy.back())).get().Value.index() == 4) // 4 for list, indicates that parent is an object that is already a vector of objects - std::get>((std::get>(parent_context.Scope_Hierarchy.back())).get().Value).push_back(this_object); + std::get(parent_context.Scope_Hierarchy.back())->Objects.push_back(this_object); + else if (std::get(parent_context.Scope_Hierarchy.back())->Value.index() == 4) // 4 for list, indicates that parent is an object that is already a vector of objects + std::get>( + std::get(parent_context.Scope_Hierarchy.back())->Value + ).push_back(this_object); else // parent is not yet vector, initialize as (change from nil to) vector - (std::get>(parent_context.Scope_Hierarchy.back())).get().Value = std::vector { this_object }; + std::get(parent_context.Scope_Hierarchy.back())->Value = std::vector { this_object }; } void parse_Call(Context parent_context, std::ifstream& nvl) @@ -259,7 +261,7 @@ namespace NVL Call this_call; Context this_context = parent_context; - this_context.Scope_Hierarchy.push_back(this_call); + this_context.Scope_Hierarchy.push_back(&this_call); // parse the symbol (first obj in call) parse_Object(this_context, nvl); @@ -270,14 +272,14 @@ namespace NVL parse_Object(this_context, nvl); } - (std::get>(parent_context.Scope_Hierarchy.back())).get().Calls.push_back(this_call); + std::get(parent_context.Scope_Hierarchy.back())->Calls.push_back(this_call); } void parse_Sequence(Context parent_context, std::ifstream& nvl) { Sequence this_sequence; Context this_context = parent_context; - this_context.Scope_Hierarchy.push_back(this_sequence); + this_context.Scope_Hierarchy.push_back(&this_sequence); skip_ws(nvl); @@ -306,7 +308,7 @@ namespace NVL nvl.get(c); // get } - std::get>(parent_context.Scope_Hierarchy.back()).get().Sequences.push_back(this_sequence); + std::get(parent_context.Scope_Hierarchy.back())->Sequences.push_back(this_sequence); } void parse_NVL(Tree& root, std::string path) @@ -316,7 +318,7 @@ namespace NVL if (nvl.is_open()) { Context current_context; - current_context.Scope_Hierarchy.push_back(root); + current_context.Scope_Hierarchy.push_back(&root); while (!nvl.eof()) { // parse_Sequence() already takes care of comments before a sequence diff --git a/NouVeL/NVL.h b/NouVeL/NVL.h index c8b9c57..4977d05 100644 --- a/NouVeL/NVL.h +++ b/NouVeL/NVL.h @@ -56,10 +56,10 @@ namespace NVL struct Context { std::vector, - std::reference_wrapper, - std::reference_wrapper, - std::reference_wrapper + Tree*, + Sequence*, + Call*, + Object* >> Scope_Hierarchy; };