diff --git a/src/headers/misc.hpp b/src/headers/misc.hpp index 0962dee..f741593 100644 --- a/src/headers/misc.hpp +++ b/src/headers/misc.hpp @@ -6,6 +6,6 @@ void outputFileContent(const string& file, string_view content); #include "lex.hpp" #include "parsing/Parser.hpp" -inline auto parseString(const string& toParse) { return Parser::parseVector(lex(toParse)); } +inline auto parseString(const string& toParse) { return Parser::parse(lex(toParse)); } #endif //YERBACON_MISC_HPP \ No newline at end of file diff --git a/src/headers/parsing/Parser.hpp b/src/headers/parsing/Parser.hpp index 69ac05e..20e612d 100644 --- a/src/headers/parsing/Parser.hpp +++ b/src/headers/parsing/Parser.hpp @@ -5,6 +5,7 @@ #include "ParseComponents.hpp" #include "../Yerbacon.hpp" #include +#include namespace Parser { typedef Yerbacon::Exception ParsingException; @@ -16,7 +17,7 @@ namespace Parser { const bool& quoteTokenText = false ) { error(token, text, token.line, quoteTokenText); } IS(ParseTree) - T parseVector(const vector& lexed) { + T parse(const span&& lexed) { T parseTree; using namespace StandardComponents; using enum tok::type; @@ -63,11 +64,11 @@ namespace Parser { } case LPAR: case LBRACE: case LBRACKET: { const auto inverseCharacter = tok::inverseLCharacter(current.toktype); - const auto closingCharacter = find_if(lexed.cbegin() + i, lexed.cend(), [&inverseCharacter](const tok& it){ + const auto closingCharacter = find_if(lexed.begin() + i, lexed.end(), [&inverseCharacter](const tok& it){ return it.toktype == inverseCharacter; }); - if (closingCharacter != lexed.cend()) { - vector subTokens(lexed.cbegin() + i + 1, closingCharacter); + if (closingCharacter != lexed.end()) { + vector subTokens(lexed.begin() + i + 1, closingCharacter); if (current.toktype == LPAR || current.toktype == LBRACKET) { if (subTokens.size() >= 2 && subTokens[1].toktype != RPAR) { for (auto iterator = subTokens.cbegin(); iterator < (subTokens.cend() - 1); ++iterator) { @@ -79,12 +80,12 @@ namespace Parser { } } switch (current.toktype) { - case LPAR: parseTree << parseVector(subTokens); break; + case LPAR: parseTree << parse(subTokens); break; case LBRACE: // TODO Add structures for class/function bodies case LBRACKET: - default: parseTree << parseVector(subTokens); break; + default: parseTree << parse(subTokens); break; } - i = distance(lexed.cbegin(), closingCharacter); + i = distance(lexed.begin(), closingCharacter); } else parsingError(current, string(" is missing a closing \"").append(1, inverseCharacter) + '"', true); break; }