Use INFO macro from base.h
Instead of using TERM_YELLOW directly, along with C++'s shit stream based I/O, let's just use the nice macro defined in base.h
This commit is contained in:
38
src/main.cpp
38
src/main.cpp
@@ -59,15 +59,14 @@ int main(int argc, const char *argv[])
|
|||||||
(void)out_name;
|
(void)out_name;
|
||||||
|
|
||||||
#if VERBOSE >= 1
|
#if VERBOSE >= 1
|
||||||
printf("[%sASSEMBLER%s]: Assembling `%s` to `%s`\n", TERM_YELLOW, TERM_RESET,
|
INFO("ASSEMBLER", "Assembling `%s` to `%s`\n", source_name, out_name);
|
||||||
source_name, out_name);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto file_source = read_file(source_name);
|
auto file_source = read_file(source_name);
|
||||||
|
|
||||||
#if VERBOSE >= 1
|
#if VERBOSE >= 1
|
||||||
printf("[%sASSEMBLER%s]: `%s` -> %lu bytes\n", TERM_YELLOW, TERM_RESET,
|
SUCCESS("ASSEMBLER", "`%s` -> %lu bytes\n", source_name,
|
||||||
source_name, file_source.has_value() ? file_source.value().size() : 0);
|
file_source.has_value() ? file_source.value().size() : 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
string source_str;
|
string source_str;
|
||||||
@@ -104,19 +103,18 @@ int main(int argc, const char *argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if VERBOSE >= 1
|
#if VERBOSE >= 1
|
||||||
printf("[%sLEXER%s]: %lu bytes -> %lu tokens\n", TERM_GREEN, TERM_RESET,
|
SUCCESS("LEXER", "%lu bytes -> %lu tokens\n", source_str.size(),
|
||||||
source_str.size(), tokens.size());
|
tokens.size());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if VERBOSE == 2
|
#if VERBOSE == 2
|
||||||
printf("[%sLEXER%s]: Tokens "
|
SUCCESS("LEXER", "Tokens parsed:%s\n", "");
|
||||||
"parsed:\n----------------------------------------------------------"
|
printf("-------------------------------------------------------------------"
|
||||||
"----------------------\n",
|
"-------------\n");
|
||||||
TERM_GREEN, TERM_RESET);
|
|
||||||
for (auto token : tokens)
|
for (auto token : tokens)
|
||||||
cout << "\t" << *token << endl;
|
cout << "\t" << *token << endl;
|
||||||
printf("-------------------------------------------------------------"
|
printf("-------------------------------------------------------------------"
|
||||||
"-------------------\n");
|
"-------------\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,20 +129,18 @@ int main(int argc, const char *argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if VERBOSE >= 1
|
#if VERBOSE >= 1
|
||||||
printf("[%sPREPROCESSER%s]: %lu tokens -> %lu units\n", TERM_GREEN,
|
SUCCESS("PREPROCESSER", "%lu tokens -> %lu units\n", tokens.size(),
|
||||||
TERM_RESET, tokens.size(), units.size());
|
units.size());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if VERBOSE == 2
|
#if VERBOSE == 2
|
||||||
printf("[%sPREPROCESSER%s]: Units "
|
SUCCESS("PREPROCESSER", "Units constructed:%s\n", "");
|
||||||
"constructed:\n-----------------------------------------------------"
|
printf("-------------------------------------------------------------------"
|
||||||
"-----"
|
"-------------\n");
|
||||||
"----------------------\n",
|
|
||||||
TERM_GREEN, TERM_RESET);
|
|
||||||
for (auto unit : units)
|
for (auto unit : units)
|
||||||
cout << unit << endl;
|
cout << unit << endl;
|
||||||
printf("-------------------------------------------------------------"
|
printf("-------------------------------------------------------------------"
|
||||||
"-------------------\n");
|
"-------------\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
#include <src/lexer.hpp>
|
#include <src/lexer.hpp>
|
||||||
#include <src/preprocesser.hpp>
|
#include <src/preprocesser.hpp>
|
||||||
|
|
||||||
|
#include <lib/base.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@@ -69,9 +71,10 @@ namespace Preprocesser
|
|||||||
{
|
{
|
||||||
i = end;
|
i = end;
|
||||||
#if VERBOSE >= 2
|
#if VERBOSE >= 2
|
||||||
std::cout << "[" TERM_YELLOW "PREPROCESSER" TERM_RESET "]: <" << depth
|
INFO("PREPROCESSER",
|
||||||
<< "> [" << i << "]:\n\tPreserving definition of `"
|
"<%d> [%lu]:\n\t Preserving definition of `%s` from outer "
|
||||||
<< const_name << "` from outer scope\n";
|
"scope\n",
|
||||||
|
depth, i, const_name.c_str());
|
||||||
#endif
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -84,8 +87,8 @@ namespace Preprocesser
|
|||||||
i = end;
|
i = end;
|
||||||
|
|
||||||
#if VERBOSE >= 2
|
#if VERBOSE >= 2
|
||||||
std::cout << "[" TERM_YELLOW "PREPROCESSER" TERM_RESET "]: <" << depth
|
INFO("PREPROCESSER", "<%d> [%lu]:\n\tConstant `%s` {\n", depth, i,
|
||||||
<< "> [" << i << "]:\n\tConstant `" << const_name << "` {\n";
|
const_name.c_str());
|
||||||
|
|
||||||
for (size_t j = 0; j < body.size(); ++j)
|
for (size_t j = 0; j < body.size(); ++j)
|
||||||
{
|
{
|
||||||
@@ -110,9 +113,8 @@ namespace Preprocesser
|
|||||||
|
|
||||||
const auto name = tokens[i + 1]->content;
|
const auto name = tokens[i + 1]->content;
|
||||||
#if VERBOSE >= 2
|
#if VERBOSE >= 2
|
||||||
std::cout << "[" TERM_YELLOW "PREPROCESSER" TERM_RESET "]: <" << depth
|
INFO("PREPROCESSER", "<%d> [%lu]: (", depth, i);
|
||||||
<< "> [" << i << "]: (" << *tokens[i] << "): FILENAME=`"
|
std::cout << *tokens[i] << "): FILENAME=`" << name << "`\n";
|
||||||
<< name << "`\n";
|
|
||||||
#endif
|
#endif
|
||||||
// If file has never been encountered, let's tokenise, preprocess then
|
// If file has never been encountered, let's tokenise, preprocess then
|
||||||
// cache the result
|
// cache the result
|
||||||
|
|||||||
Reference in New Issue
Block a user