Util: Remove debugging printf() statements
This commit is contained in:
@@ -26,35 +26,24 @@ Lexer::~Lexer()
|
|||||||
|
|
||||||
void Lexer::analyze()
|
void Lexer::analyze()
|
||||||
{
|
{
|
||||||
printf("---------\n");
|
|
||||||
printf("Input JSON:\n%s\n", m_job->input().c_str());
|
|
||||||
printf("---------\n");
|
|
||||||
printf("Lexing:\n");
|
|
||||||
|
|
||||||
while (m_index < m_job->input().length()) {
|
while (m_index < m_job->input().length()) {
|
||||||
switch (peek()) {
|
switch (peek()) {
|
||||||
case '{':
|
case '{':
|
||||||
printf("Pushing -> BraceOpen: \"{\"\t%zu[%zu]\n", m_line, m_column);
|
|
||||||
m_tokens->push_back({ Token::Type::BraceOpen, m_line, m_column, "{" });
|
m_tokens->push_back({ Token::Type::BraceOpen, m_line, m_column, "{" });
|
||||||
break;
|
break;
|
||||||
case '}':
|
case '}':
|
||||||
printf("Pushing -> BraceClose: \"}\"\t%zu[%zu]\n", m_line, m_column);
|
|
||||||
m_tokens->push_back({ Token::Type::BraceClose, m_line, m_column, "}" });
|
m_tokens->push_back({ Token::Type::BraceClose, m_line, m_column, "}" });
|
||||||
break;
|
break;
|
||||||
case '[':
|
case '[':
|
||||||
printf("Pushing -> BracketOpen: \"[\"\t%zu[%zu]\n", m_line, m_column);
|
|
||||||
m_tokens->push_back({ Token::Type::BracketOpen, m_line, m_column, "[" });
|
m_tokens->push_back({ Token::Type::BracketOpen, m_line, m_column, "[" });
|
||||||
break;
|
break;
|
||||||
case ']':
|
case ']':
|
||||||
printf("Pushing -> BracketClose: \"]\"\t%zu[%zu]\n", m_line, m_column);
|
|
||||||
m_tokens->push_back({ Token::Type::BracketClose, m_line, m_column, "]" });
|
m_tokens->push_back({ Token::Type::BracketClose, m_line, m_column, "]" });
|
||||||
break;
|
break;
|
||||||
case ':':
|
case ':':
|
||||||
printf("Pushing -> Colon: \":\"\t%zu[%zu]\n", m_line, m_column);
|
|
||||||
m_tokens->push_back({ Token::Type::Colon, m_line, m_column, ":" });
|
m_tokens->push_back({ Token::Type::Colon, m_line, m_column, ":" });
|
||||||
break;
|
break;
|
||||||
case ',':
|
case ',':
|
||||||
printf("Pushing -> Comma: \",\"\t%zu[%zu]\n", m_line, m_column);
|
|
||||||
m_tokens->push_back({ Token::Type::Comma, m_line, m_column, "," });
|
m_tokens->push_back({ Token::Type::Comma, m_line, m_column, "," });
|
||||||
break;
|
break;
|
||||||
case '"':
|
case '"':
|
||||||
@@ -207,7 +196,6 @@ bool Lexer::getString()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Pushing -> String: \"%s\"\t%zu[%zu]\n", symbol.c_str(), m_line, column);
|
|
||||||
m_tokens->push_back({ Token::Type::String, m_line, column, symbol });
|
m_tokens->push_back({ Token::Type::String, m_line, column, symbol });
|
||||||
|
|
||||||
if (character != '"') {
|
if (character != '"') {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#define JSON_LEXER_H
|
#define JSON_LEXER_H
|
||||||
|
|
||||||
// The JavaScript Object Notation (JSON) Data Interchange Format
|
// The JavaScript Object Notation (JSON) Data Interchange Format
|
||||||
// home/rick/code/cpp/manafiles/ https://www.rfc-editor.org/rfc/pdfrfc/rfc8259.txt.pdf
|
// https://www.rfc-editor.org/rfc/pdfrfc/rfc8259.txt.pdf
|
||||||
|
|
||||||
#include <cstddef> // size_t
|
#include <cstddef> // size_t
|
||||||
#include <memory> // shared_ptr
|
#include <memory> // shared_ptr
|
||||||
|
|||||||
@@ -33,9 +33,6 @@ Parser::~Parser()
|
|||||||
|
|
||||||
Value Parser::parse()
|
Value Parser::parse()
|
||||||
{
|
{
|
||||||
printf("---------\n");
|
|
||||||
printf("Parsing:\n");
|
|
||||||
|
|
||||||
Value result;
|
Value result;
|
||||||
|
|
||||||
Token token;
|
Token token;
|
||||||
@@ -320,15 +317,12 @@ Value Parser::getArray()
|
|||||||
token = peek();
|
token = peek();
|
||||||
|
|
||||||
if (token.type == Token::Type::Literal) {
|
if (token.type == Token::Type::Literal) {
|
||||||
printf("Adding literal to array.. v:{%s}, t:{%d}\n", token.symbol.c_str(), (int)token.type);
|
|
||||||
array.emplace_back(getLiteral());
|
array.emplace_back(getLiteral());
|
||||||
}
|
}
|
||||||
else if (token.type == Token::Type::Number) {
|
else if (token.type == Token::Type::Number) {
|
||||||
printf("Adding number to array.. v:{%s}, t:{%d} -> %f\n", token.symbol.c_str(), (int)token.type, std::stod(token.symbol));
|
|
||||||
array.emplace_back(getNumber());
|
array.emplace_back(getNumber());
|
||||||
}
|
}
|
||||||
else if (token.type == Token::Type::String) {
|
else if (token.type == Token::Type::String) {
|
||||||
printf("Adding string to array.. v:{%s}, t:{%d}\n", token.symbol.c_str(), (int)token.type);
|
|
||||||
array.emplace_back(getString());
|
array.emplace_back(getString());
|
||||||
}
|
}
|
||||||
else if (token.type == Token::Type::BracketOpen) {
|
else if (token.type == Token::Type::BracketOpen) {
|
||||||
@@ -424,17 +418,12 @@ Value Parser::getObject()
|
|||||||
// Add member (name:value pair) to object
|
// Add member (name:value pair) to object
|
||||||
token = peek();
|
token = peek();
|
||||||
if (token.type == Token::Type::Literal) {
|
if (token.type == Token::Type::Literal) {
|
||||||
printf("Adding literal to object.. k:{%s}, v:{%s}, t:{%d}\n", name.c_str(), token.symbol.c_str(), (int)token.type);
|
|
||||||
object[name] = getLiteral();
|
object[name] = getLiteral();
|
||||||
}
|
}
|
||||||
else if (token.type == Token::Type::Number) {
|
else if (token.type == Token::Type::Number) {
|
||||||
printf("Adding number to object.. k:{%s}, v:{%s}, t:{%d} -> %f\n", name.c_str(), token.symbol.c_str(), (int)token.type, std::stod(token.symbol));
|
|
||||||
object[name] = getNumber();
|
object[name] = getNumber();
|
||||||
}
|
}
|
||||||
else if (token.type == Token::Type::String) {
|
else if (token.type == Token::Type::String) {
|
||||||
#ifdef JSON_DEBUG
|
|
||||||
printf("Adding string to object.. k:{%s}, v:{%s}, t:{%d}\n", name.c_str(), token.symbol.c_str(), (int)token.type);
|
|
||||||
#endif
|
|
||||||
object[name] = getString();
|
object[name] = getString();
|
||||||
}
|
}
|
||||||
else if (token.type == Token::Type::BracketOpen) {
|
else if (token.type == Token::Type::BracketOpen) {
|
||||||
|
|||||||
Reference in New Issue
Block a user