Skip to content

Commit 99c173e

Browse files
authored
Simplify and improve Ü syntax highlighting. (#116)
Support all langauge operator symbols ($:.@?). Remove extra rules for functions, classes, import directives etc., since their detection can't work properly in all cases - lexical analysis only isn't enough.
1 parent aafcb3e commit 99c173e

File tree

1 file changed

+9
-19
lines changed
  • src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages

1 file changed

+9
-19
lines changed

src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/u.cpp

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,16 @@ void addU() {
1010
{ "Ü",
1111
{ "%.u$", "%.uh$" },
1212
{
13-
{ { "//.-\n" }, "comment" },
14-
{ { "/%*", "%*/" }, "comment" },
15-
{ { "\"", "[\"\n]", "\\" }, "string" },
16-
{ { "'", "'", "\\" }, "string" },
17-
{ { "(class|template|namespace|enum)\\s+([A-Za-z]\\w*)" },
18-
{ "keyword", "keyword", "keyword2" },
19-
"",
20-
SyntaxPatternMatchType::RegEx },
21-
{ { "$%(([%a_]%w*)%)" }, { "operator", "keyword2", "keyword2" } },
22-
{ { "^%s*(import)%s+([<%\"][%w%d%.%\\%/%_%-]+[>%\"])" },
23-
{ "keyword", "keyword", "literal" } },
24-
{ { "cpp_number_parser" }, "number", "", SyntaxPatternMatchType::Parser },
25-
{ { "[%+%-=/%*%^%%<>!~|&]" }, "operator" },
26-
{ { "[%a_][%w_]*%f[(]" }, "function" },
27-
{ { "ust%:%:[%w_]*" }, "keyword2" },
28-
{ { "[%a_][%w_]*" }, "symbol" },
29-
13+
{ { "//.-\n" }, "comment" }, // Single-line comments.
14+
{ { "/%*", "%*/" }, "comment" }, // Multi-line comments.
15+
{ { "\"", "[\"\n]", "\\" }, "string" }, // String literals.
16+
{ { "'", "'", "\\" }, "string" }, // Char literals.
17+
{ { "cpp_number_parser" }, "number", "", SyntaxPatternMatchType::Parser }, // Numbers. TODO - support Ü-specific formats.
18+
{ { "[%+%-=/%*%^%%<>!~|&$:.@?]" }, "operator" }, // Various operators.
19+
{ { "[%a_][%w_]*" }, "symbol" }, // Regular identifiers.
3020
},
3121
{
32-
33-
{ "pretty_main", "function" },
22+
// Keywords.
3423
{ "fn", "keyword" },
3524
{ "op", "keyword" },
3625
{ "var", "keyword" },
@@ -119,6 +108,7 @@ void addU() {
119108
{ "cast_ref_unsafe", "keyword" },
120109
{ "cast_mut", "keyword" },
121110
{ "uninitialized", "keyword" },
111+
// Built-in type keywords.
122112
{ "void", "keyword2" },
123113
{ "bool", "keyword2" },
124114
{ "i8", "keyword2" },

0 commit comments

Comments
 (0)