Better C highlighting

This commit is contained in:
Joshua Barretto 2025-10-01 13:43:12 +01:00
parent cf7aeff577
commit a6d3df4288

View file

@ -182,7 +182,7 @@ impl Highlighter {
pub fn generic_clike(self) -> Self { pub fn generic_clike(self) -> Self {
self self
// Keywords // Keywords
.with(TokenKind::Keyword, r"\b[(var)(enum)(let)(this)(fn)(struct)(class)(import)(if)(while)(for)(in)(loop)(else)(break)(continue)(const)(static)(type)(extern)(return)(async)(throw)(catch)(union)(auto)(namespace)(public)(private)(function)(func)(goto)(case)(default)(switch)(typedef)]\b") .with(TokenKind::Keyword, r"\b[(var)(enum)(let)(this)(fn)(struct)(class)(import)(if)(while)(for)(in)(loop)(else)(break)(continue)(const)(static)(typedef)(type)(extern)(return)(async)(throw)(catch)(union)(auto)(namespace)(public)(private)(function)(func)(goto)(case)(default)(switch)]\b")
// Primitives // Primitives
.with(TokenKind::Type, r"\b[(([(unsigned)(signed)][[:space:]])*u?int[0-9]*(_t)?)(float)(double)(bool)(char)(size_t)(void)]\b") .with(TokenKind::Type, r"\b[(([(unsigned)(signed)][[:space:]])*u?int[0-9]*(_t)?)(float)(double)(bool)(char)(size_t)(void)]\b")
.clike_comments() .clike_comments()
@ -271,7 +271,7 @@ impl Highlighter {
r"\b[(if(n)?[(eq)(def)]?)(endif)(else)]\b", r"\b[(if(n)?[(eq)(def)]?)(endif)(else)]\b",
) )
// Operators // Operators
.with(TokenKind::Operator, r"[=,:\@]") .with(TokenKind::Operator, r"[=,:\@\+(\+\+)\+]")
// Double-quoted strings // Double-quoted strings
.with( .with(
TokenKind::String, TokenKind::String,