Skip to content

Commit

Permalink
css2: Support tokenizing cdo tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
robinlinden committed Jan 23, 2025
1 parent b011f65 commit 95c49f2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions css2/tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ void Tokenizer::run() {
case ';':
emit(SemiColonToken{});
continue;
case '<':
if (peek_input(0) == '!' && peek_input(1) == '-' && peek_input(2) == '-') {
emit(CdoToken{});
pos_ += 3;
continue;
}

emit(DelimToken{'<'});
continue;
case '[':
emit(OpenSquareToken{});
continue;
Expand Down
12 changes: 12 additions & 0 deletions css2/tokenizer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,18 @@ int main() {
expect_token(output, IdentToken{"lol"});
});

s.add_test("<: delim", [](etest::IActions &a) {
auto output = run_tokenizer(a, "<hello");
expect_token(output, DelimToken{'<'});
expect_token(output, IdentToken{"hello"});
});

s.add_test("<: cdo", [](etest::IActions &a) {
auto output = run_tokenizer(a, "<!--lol");
expect_token(output, CdoToken{});
expect_token(output, IdentToken{"lol"});
});

s.add_test("number: ez", [](etest::IActions &a) {
auto output = run_tokenizer(a, "0.25");
expect_token(output, NumberToken{0.25});
Expand Down

0 comments on commit 95c49f2

Please sign in to comment.