diff --git a/NouVeL/NVL.cpp b/NouVeL/NVL.cpp index 953d821..8a5ef35 100644 --- a/NouVeL/NVL.cpp +++ b/NouVeL/NVL.cpp @@ -36,20 +36,29 @@ namespace { stream.get(c); bool no_more_nesting_quotes = false; - for (auto const& x : current_scope.Scope) - if (x == '\'' || x == '\"') + for (auto& x : current_scope.Scope) + { + if (x == '\'' || x == '\"') + { no_more_nesting_quotes = true; + } + } + bool set_scope_on_this_iter = false; if (!no_more_nesting_quotes) { for (auto const& x : SCOPER_MAP) { if (c == x.first) { - current_scope.Scope.push_back(c); + current_scope.Scope.push_back(c); + set_scope_on_this_iter = true; break; } } } + if (!set_scope_on_this_iter && c == SCOPER_MAP.at(current_scope.Scope.back())) + current_scope.Scope.pop_back(); + if (c == '\\') // encounters an escaped sequence { char cc = stream.peek(); @@ -59,19 +68,17 @@ namespace { } } - if (c == SCOPER_MAP.at(current_scope.Scope.back())) - current_scope.Scope.pop_back(); - if (stream.eof()) { std::cerr << "Can't cope with scope!" << std::endl; throw; } + } final = stream.tellg(); stream.seekg(initial); - + return final; } @@ -114,7 +121,7 @@ namespace NVL char c{}; switch (nvl.peek()) { - case '[': // List, fucked + case '[': // List nvl.get(c); // do not exchange this line with the next one end = scope_cope('[', nvl); while (nvl.tellg() < end - static_cast(1)) @@ -133,6 +140,8 @@ namespace NVL while (nvl.tellg() < end - static_cast(1)) { nvl.get(c); + if (c == '\\' && (nvl.peek() == '\'' || nvl.peek() == '\"')) + continue; content = std::get(content) + c; } nvl.get(c); // rid of final scoper @@ -144,7 +153,7 @@ namespace NVL { content = std::get(content) + c; } - if (c == ']' || c == ',' || c == '}') + if (c == ']' || c == '}') nvl.putback(c); try @@ -175,12 +184,12 @@ namespace NVL 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 - ; + else if ((std::get>(parent_context.Scope_Hierarchy.back())).get().Value.index() == 4) // 4 for list + { std::get>((std::get>(parent_context.Scope_Hierarchy.back())).get().Value).push_back(this_object); } - else { - ; + else + { (std::get>(parent_context.Scope_Hierarchy.back())).get().Value = std::vector { this_object }; } } diff --git a/test.nvl b/test.nvl index 3877473..11ec514 100644 --- a/test.nvl +++ b/test.nvl @@ -1,10 +1,3 @@ -mmawesome -{ - mmawesome mmaji awesome asduhjaiodhj kl;d 3434.3434 true false -} - -dasijhdoisaj {} - -uihf98 { - dasdj [39439048 jidjao] [] [] [] [[][[][[[[[] hi [2323 d]]]]]]] +mmawesome { + lmao [gkepokge hee hee [2323.4 535 3434]] }