From b66ec2bf7a71effe2c001eedad7704683f7f7f70 Mon Sep 17 00:00:00 2001 From: Rosetta H&S Date: Wed, 2 Jun 2021 07:33:40 +0800 Subject: [PATCH] Add highlighting for user-defined types (#2107) * Added highlighting for user-defined types Provides automatic highlighting of user-defined types ending with either "_t" or "_T", as is seen in editors such as Nano, or within GitHub itself. * Update cpp.yaml --- runtime/syntax/c.yaml | 1 + runtime/syntax/cpp.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/runtime/syntax/c.yaml b/runtime/syntax/c.yaml index 36fabcde..e0bea2ce 100644 --- a/runtime/syntax/c.yaml +++ b/runtime/syntax/c.yaml @@ -7,6 +7,7 @@ rules: - identifier: "\\b[A-Z_][0-9A-Z_]+\\b" - type: "\\b(auto|float|double|char|int|short|long|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline)\\b" - type: "\\b((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\\b" + - type: "\\b[a-z_][0-9a-z_]+(_t|_T)\\b" - type.extended: "\\b(bool)\\b" - statement: "\\b(volatile|register)\\b" - statement: "\\b(for|if|while|do|else|case|default|switch)\\b" diff --git a/runtime/syntax/cpp.yaml b/runtime/syntax/cpp.yaml index c213baa3..0da1da6f 100644 --- a/runtime/syntax/cpp.yaml +++ b/runtime/syntax/cpp.yaml @@ -7,6 +7,7 @@ rules: - identifier: "\\b[A-Z_][0-9A-Z_]*\\b" - type: "\\b(float|double|bool|char|int|short|long|enum|void|struct|union|typedef|(un)?signed|inline)\\b" - type: "\\b(((s?size)|((u_?)?int(8|16|32|64|ptr))|char(8|16|32))_t|wchar_t)\\b" + - type: "\\b[a-z_][0-9a-z_]+(_t|_T)\\b" - type: "\\b(final|override)\\b" - type.keyword: "\\b(auto|volatile|const(expr|eval|init)?|mutable|register|thread_local|static|extern|decltype|explicit|virtual)\\b" - statement: "\\b(class|namespace|template|typename|this|friend|using|public|protected|private|noexcept)\\b"