]> git.lizzy.rs Git - micro.git/commitdiff
Improve C syntax highlighting (#2015)
authorrelrelb <relrelb@users.noreply.github.com>
Thu, 18 Feb 2021 03:28:19 +0000 (05:28 +0200)
committerGitHub <noreply@github.com>
Thu, 18 Feb 2021 03:28:19 +0000 (22:28 -0500)
runtime/syntax/c.yaml

index 15310ee82053fced3984192caa4b0597e3591a20..36fabcdea147ed160536f3bb547b4dc20ffff231 100644 (file)
@@ -5,7 +5,7 @@ detect:
 
 rules:
     - identifier: "\\b[A-Z_][0-9A-Z_]+\\b"
-    - type: "\\b(float|double|char|int|short|long|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline)\\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.extended: "\\b(bool)\\b"
     - statement: "\\b(volatile|register)\\b"
@@ -18,7 +18,12 @@ rules:
       # Operator Color
     - symbol.operator: "([.:;,+*|=!\\%]|<|>|/|-|&)"
     - symbol.brackets: "[(){}]|\\[|\\]"
-    - constant.number: "(\\b[0-9]+\\b|\\b0x[0-9A-Fa-f]+\\b)"
+      # Integer Constants
+    - constant.number: "(\\b([1-9][0-9]*|0[0-7]*|0[Xx][0-9A-Fa-f]+|0[Bb][01]+)([Uu]?[Ll][Ll]?|[Ll][Ll]?[Uu]?)?\\b)"
+      # Decimal Floating Constants
+    - constant.number: "(\\b(([0-9]*[.][0-9]+|[0-9]+[.][0-9]*)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)[FfLl]?\\b)"
+      # Hexadecimal Floating Constants
+    - constant.number: "(\\b0[Xx]([0-9A-Za-z]*[.][0-9A-Za-z]+|[0-9A-Za-z]+[.][0-9A-Za-z]*)[Pp][+-]?[0-9]+[FfLl]?\\b)"
     - constant.number: "NULL"
 
     - constant.string: