mirror of
https://github.com/gbdev/rgbds.git
synced 2026-09-24 06:37:07 +00:00
Factor out verboseDo to encapsulate magenta output color
This commit is contained in:
+11
-15
@@ -2315,26 +2315,22 @@ yy::parser::symbol_type yylex() {
|
||||
return yy::parser::symbol_type(token.type, std::get<uint32_t>(token.value));
|
||||
} else if (std::holds_alternative<std::string>(token.value)) {
|
||||
// LCOV_EXCL_START
|
||||
if (checkVerbosity(VERB_TRACE)) {
|
||||
style_Set(stderr, STYLE_MAGENTA, false);
|
||||
verboseDo(VERB_TRACE, [&]() {
|
||||
fprintf(stderr, "Lexed `%s` token (", yy::parser::symbol_type(token.type).name());
|
||||
verboseOutputString(std::get<std::string>(token.value));
|
||||
fputs(")\n", stderr);
|
||||
style_Reset(stderr);
|
||||
}
|
||||
});
|
||||
// LCOV_EXCL_STOP
|
||||
return yy::parser::symbol_type(token.type, std::get<std::string>(token.value));
|
||||
} else if (std::holds_alternative<InternedStr>(token.value)) {
|
||||
// LCOV_EXCL_START
|
||||
if (checkVerbosity(VERB_TRACE)) {
|
||||
style_Set(stderr, STYLE_MAGENTA, false);
|
||||
verboseDo(VERB_TRACE, [&]() {
|
||||
fprintf(
|
||||
stderr, "Lexed `%s` token (interned ", yy::parser::symbol_type(token.type).name()
|
||||
);
|
||||
verboseOutputString(std::get<InternedStr>(token.value).str());
|
||||
fputs(")\n", stderr);
|
||||
style_Reset(stderr);
|
||||
}
|
||||
});
|
||||
// LCOV_EXCL_STOP
|
||||
return yy::parser::symbol_type(token.type, std::get<InternedStr>(token.value));
|
||||
} else {
|
||||
@@ -2392,13 +2388,13 @@ static Capture makeCapture(char const *name, InvocableR<int, int> auto callback)
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START
|
||||
if (checkVerbosity(VERB_TRACE) && capture.span.ptr) {
|
||||
style_Set(stderr, STYLE_MAGENTA, false);
|
||||
fprintf(stderr, "Captured %s (", name);
|
||||
verboseOutputString(std::string_view{capture.span.ptr.get(), capture.span.size});
|
||||
fputs(")\n", stderr);
|
||||
style_Reset(stderr);
|
||||
}
|
||||
verboseDo(VERB_TRACE, [&]() {
|
||||
if (capture.span.ptr) {
|
||||
fprintf(stderr, "Captured %s (", name);
|
||||
verboseOutputString(std::string_view{capture.span.ptr.get(), capture.span.size});
|
||||
fputs(")\n", stderr);
|
||||
}
|
||||
});
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
assume(!lexerState->atLineStart); // `skipToLeadingKeyword` moves past the start of the line
|
||||
|
||||
+2
-10
@@ -24,7 +24,7 @@
|
||||
#include "helpers.hpp"
|
||||
#include "parser.hpp" // Generated from parser.y
|
||||
#include "platform.hpp"
|
||||
#include "style.hpp"
|
||||
#include "style.hpp" // style_Parse
|
||||
#include "usage.hpp"
|
||||
#include "util.hpp" // UpperMap
|
||||
#include "verbosity.hpp"
|
||||
@@ -373,12 +373,6 @@ static void parseArg(int ch, char *arg) {
|
||||
|
||||
// LCOV_EXCL_START
|
||||
static void verboseOutputConfig() {
|
||||
if (!checkVerbosity(VERB_CONFIG)) {
|
||||
return;
|
||||
}
|
||||
|
||||
style_Set(stderr, STYLE_MAGENTA, false);
|
||||
|
||||
usage.printVersion(true);
|
||||
|
||||
printVVVVVVerbosity();
|
||||
@@ -490,8 +484,6 @@ static void verboseOutputConfig() {
|
||||
}
|
||||
}
|
||||
fputs("Ready for assembly\n", stderr);
|
||||
|
||||
style_Reset(stderr);
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
@@ -519,7 +511,7 @@ int main(int argc, char *argv[]) {
|
||||
options.targetFileName = options.objectFileName;
|
||||
}
|
||||
|
||||
verboseOutputConfig();
|
||||
verboseDo(VERB_CONFIG, verboseOutputConfig);
|
||||
|
||||
if (!localOptions.inputFileName) {
|
||||
usage.printAndExit("No input file specified (pass \"-\" to read from standard input)");
|
||||
|
||||
Reference in New Issue
Block a user