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

Loading…
Cancel
Save