Skip to content

Commit 837121a

Browse files
committed
vaev-engine: Replaced more compile-time debug switch with Debug::Flag.
1 parent 55ff22f commit 837121a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/vaev-engine/html/lexer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ module;
55
export module Vaev.Engine:html.lexer;
66

77
import Karm.Core;
8+
import Karm.Debug;
89

910
import :html.token;
1011

1112
using namespace Karm;
1213

1314
namespace Vaev::Html {
1415

15-
static constexpr bool DEBUG_HTML_LEXER = false;
16+
static Debug::Flag debugLexer{"web-html-lexer"};
1617

1718
struct HtmlEntity {
1819
Str name;
@@ -78,6 +79,7 @@ export struct HtmlLexer {
7879
void _emit() {
7980
if (not _sink)
8081
panic("no sink");
82+
logDebugIf(debugLexer, "emiting token: {}", _ensure());
8183
_sink->accept(_ensure());
8284
_last = std::move(_token);
8385
}
@@ -140,7 +142,7 @@ export struct HtmlLexer {
140142
}
141143

142144
void consume(Rune rune, bool isEof = false) {
143-
logDebugIf(DEBUG_HTML_LEXER, "Lexing '{#c}' {#x} in {}", rune, rune, _state);
145+
logDebugIf(debugLexer, "Lexing '{#c}' {#x} in {}", rune, rune, _state);
144146

145147
switch (_state) {
146148

src/vaev-engine/html/parser.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ module;
55
export module Vaev.Engine:html.parser;
66

77
import Karm.Gc;
8+
import Karm.Debug;
89
import :dom;
910
import :html.token;
1011
import :html.lexer;
1112

1213
namespace Vaev::Html {
1314

14-
static constexpr bool DEBUG_HTML_PARSER = false;
15+
static Debug::Flag debugParser{"web-html-parser"s};
1516

1617
#define FOREACH_INSERTION_MODE(MODE) \
1718
MODE(INITIAL) \
@@ -165,7 +166,7 @@ export struct HtmlParser : HtmlSink {
165166
// 13.2.5 MARK: Tokenization
166167
// https://html.spec.whatwg.org/multipage/parsing.html#tokenization
167168
void _acknowledgeSelfClosingFlag(HtmlToken const&) {
168-
logDebugIf(DEBUG_HTML_PARSER, "acknowledgeSelfClosingFlag not implemented");
169+
logDebugIf(debugParser, "acknowledgeSelfClosingFlag not implemented");
169170
}
170171

171172
// 13.2.6 MARK: Tree construction
@@ -2608,7 +2609,7 @@ export struct HtmlParser : HtmlSink {
26082609

26092610
void _acceptIn(Mode mode, HtmlToken& t) {
26102611
if (t.type != HtmlToken::CHARACTER)
2611-
logDebugIf(DEBUG_HTML_PARSER, "Parsing {} in {}", t, mode);
2612+
logDebugIf(debugParser, "Parsing {} in {}", t, mode);
26122613

26132614
switch (mode) {
26142615

0 commit comments

Comments
 (0)