mirror of
https://github.com/gbdev/rgbds.git
synced 2026-10-06 04:05:38 +00:00
Factor out verboseDo to encapsulate magenta output color
This commit is contained in:
1 parent
ea3a8ee171
commit
304cbb464f
8 files changed
+59
-95
No files matched your search
+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
|
||||
|
||||
Reference in new issue
Block a user