Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions include/ulight/impl/lang/cowel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ Common_Number_Result match_number(std::u8string_view str);
[[nodiscard]]
std::size_t match_reserved_number(std::u8string_view str);

[[nodiscard]]
bool starts_with_escape_or_comment_or_directive(std::u8string_view str);

[[nodiscard]]
std::size_t match_blank(std::u8string_view str);

Expand Down
18 changes: 0 additions & 18 deletions include/ulight/impl/lang/cowel_chars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,6 @@ constexpr bool is_cowel_identifier(char32_t c) noexcept
return is_ascii(c) && is_cowel_identifier(char8_t(c));
}

inline constexpr Charset256 is_cowel_allowed_after_backslash_set //
= is_cowel_escapeable_set //
| is_cowel_identifier_start_set //
| detail::to_charset256(cowel_line_comment_char)
| detail::to_charset256(cowel_block_comment_char);

[[nodiscard]]
constexpr bool is_cowel_allowed_after_backslash(char8_t c) noexcept
{
return is_cowel_allowed_after_backslash_set.contains(c);
}

[[nodiscard]]
constexpr bool is_cowel_allowed_after_backslash(char32_t c) noexcept
{
return is_ascii(c) && is_cowel_allowed_after_backslash(char8_t(c));
}

inline constexpr Charset256 is_cowel_ascii_reserved_escapeable_set = is_ascii_set
- is_cowel_escapeable_set - is_cowel_identifier_start_set - detail::to_charset256(u8":*\n\r");

Expand Down
10 changes: 1 addition & 9 deletions src/main/cpp/lang/cowel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@ std::size_t match_reserved_number(const std::u8string_view str)
return length;
}

bool starts_with_escape_or_comment_or_directive(const std::u8string_view str)
{
return str.length() >= 2 && str[0] == u8'\\' && is_cowel_allowed_after_backslash(str[1]);
}

std::size_t match_blank(const std::u8string_view str)
{
std::size_t length = 0;
Expand Down Expand Up @@ -225,10 +220,7 @@ struct [[nodiscard]] Highlighter : Highlighter_Base {
for (; plain_length < remainder.length(); ++plain_length) {
const char8_t c = remainder[plain_length];
if (c == u8'\\') {
if (starts_with_escape_or_comment_or_directive(remainder.substr(plain_length))) {
goto done;
}
continue;
goto done;
}
switch (text_kind) {
case Text_Kind::document: {
Expand Down
2 changes: 1 addition & 1 deletion test/highlight/cowel/directive_names.cow.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
<h- data-h=mk_tag>\x</h->.y
<h- data-h=mk_tag>\xy</h->
<h- data-h=mk_tag>\xy0</h->
\0xy
<h- data-h=err>\0</h->xy
2 changes: 1 addition & 1 deletion test/highlight/cowel/escapes.cow.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
<h- data-h=mk_tag>\d</h-><h- data-h=str_esc>\{</h-><h- data-h=str_esc>\}</h->
awoo<h- data-h=str_esc>\</h->
chan<h- data-h=str_esc>\ </h->chan<h- data-h=str_esc>\ </h->
\-
<h- data-h=err>\-</h->
35 changes: 35 additions & 0 deletions test/highlight/cowel/escapes_reserved.cow
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
\!
\#
\$
\%
\&
\'
\(
\)
\+
\,
\-
\.
\/
\0
\1
\2
\3
\4
\5
\6
\7
\8
\9
\;
\?
\@
\[
\]
\]
\^
\^
\`
\~
\🇩🇪
35 changes: 35 additions & 0 deletions test/highlight/cowel/escapes_reserved.cow.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<h- data-h=err>\!</h->
<h- data-h=err>\#</h->
<h- data-h=err>\$</h->
<h- data-h=err>\%</h->
<h- data-h=err>\&amp;</h->
<h- data-h=err>\'</h->
<h- data-h=err>\(</h->
<h- data-h=err>\)</h->
<h- data-h=err>\+</h->
<h- data-h=err>\,</h->
<h- data-h=err>\-</h->
<h- data-h=err>\.</h->
<h- data-h=err>\/</h->
<h- data-h=err>\0</h->
<h- data-h=err>\1</h->
<h- data-h=err>\2</h->
<h- data-h=err>\3</h->
<h- data-h=err>\4</h->
<h- data-h=err>\5</h->
<h- data-h=err>\6</h->
<h- data-h=err>\7</h->
<h- data-h=err>\8</h->
<h- data-h=err>\9</h->
<h- data-h=err>\;</h->
<h- data-h=err>\?</h->
<h- data-h=err>\@</h->
<h- data-h=err>\[</h->
<h- data-h=err>\]</h->
<h- data-h=err>\]</h->
<h- data-h=err>\^</h->
<h- data-h=err>\^</h->
<h- data-h=err>\`</h->
<h- data-h=err>\~</h->
<h- data-h=err>\ä</h->
<h- data-h=err>\🇩</h->🇪