Browse Source

Util: Change Token element access to use at()

master
Riyyi 2 years ago
parent
commit
51e788a5ad
  1. 10
      src/util/json/parser.cpp

10
src/util/json/parser.cpp

@ -88,13 +88,13 @@ bool Parser::reachedEnd()
Token Parser::peek() Token Parser::peek()
{ {
return (*m_tokens)[m_index]; return m_tokens->at(m_index);
} }
bool Parser::seekForward(Token::Type type) bool Parser::seekForward(Token::Type type)
{ {
for (size_t index = m_index; index < m_tokens->size(); ++index) { for (size_t index = m_index; index < m_tokens->size(); ++index) {
if ((*m_tokens)[index].type == type) { if (m_tokens->at(index).type == type) {
m_index = index; m_index = index;
return true; return true;
} }
@ -354,7 +354,7 @@ Value Parser::getArray()
else if (token.type == Token::Type::BracketClose) { else if (token.type == Token::Type::BracketClose) {
// Trailing comma // Trailing comma
if (array.asArray().size() > 0) { if (array.asArray().size() > 0) {
reportError((*m_tokens)[m_index - 1], "invalid comma, expecting ']'"); reportError(m_tokens->at(m_index - 1), "invalid comma, expecting ']'");
break; break;
} }
} }
@ -378,7 +378,7 @@ Value Parser::getArray()
break; break;
} }
else { else {
reportError(token, "expecting comma or ']', not '" + token.symbol + "'"); reportError(m_tokens->at(m_index - 1), "expecting comma or ']', not '" + token.symbol + "'");
break; break;
} }
} }
@ -413,7 +413,7 @@ Value Parser::getObject()
if (token.type == Token::Type::BraceClose) { if (token.type == Token::Type::BraceClose) {
// Trailing comma // Trailing comma
if (object.asObject().size() > 0) { if (object.asObject().size() > 0) {
reportError((*m_tokens)[m_index - 1], "invalid comma, expecting '}'"); reportError(m_tokens->at(m_index - 1), "invalid comma, expecting '}'");
} }
// Empty object // Empty object
break; break;

Loading…
Cancel
Save