Browse Source

Util: Break Lexer strings on quote and new lines

master
Riyyi 3 years ago
parent
commit
d65f56bf03
  1. 7
      src/util/json/lexer.cpp

7
src/util/json/lexer.cpp

@ -180,6 +180,9 @@ bool Lexer::getString()
size_t column = m_column;
std::string symbol = "";
// Break on "\r\n
std::string breakOnGrammar = std::string("\"") + '\r' + '\n';
bool escape = false;
char character = consume();
for (;;) {
@ -192,7 +195,7 @@ bool Lexer::getString()
continue;
}
if (!escape && character == '"') {
if (!escape && breakOnGrammar.find(character) != std::string::npos) {
break;
}
@ -219,7 +222,7 @@ bool Lexer::getNumberOrLiteral(Token::Type type)
{
size_t column = m_column;
std::string symbol = "";
std::string breakOnGrammar = std::string() + "{}[]:,\" " + '\t' + '\r' + '\n';
std::string breakOnGrammar = std::string("{}[]:,\" ") + '\t' + '\r' + '\n';
for (char character;;) {
character = peek();

Loading…
Cancel
Save