]> git.lizzy.rs Git - micro.git/commitdiff
runtime/syntax: add rudimentary Odin support (#2296)
authorftphikari <ftphikari@gmail.com>
Fri, 11 Feb 2022 22:15:34 +0000 (14:15 -0800)
committerGitHub <noreply@github.com>
Fri, 11 Feb 2022 22:15:34 +0000 (14:15 -0800)
Odin is a general-purpose programming language with distinct typing,
built for high performance, modern systems, and built-in data-oriented
data types. The Odin Programming Language, the C alternative for
the joy of programming. The Data-Oriented Language for Sane Software
Development.

https://odin-lang.org/
https://odin-lang.org/docs/overview/
https://github.com/odin-lang/Odin

runtime/syntax/groovy.yaml [changed mode: 0755->0644]
runtime/syntax/odin.yaml [new file with mode: 0644]

old mode 100755 (executable)
new mode 100644 (file)
diff --git a/runtime/syntax/odin.yaml b/runtime/syntax/odin.yaml
new file mode 100644 (file)
index 0000000..1326356
--- /dev/null
@@ -0,0 +1,64 @@
+filetype: odin
+
+detect:
+    filename: "\\.odin$"
+
+rules:
+    # Conditionals and control flow
+    - special: "\\b(asm|auto_cast|break|case|cast|context|continue|do|dynamic|fallthrough|return|transmute|using|where)\\b"
+    - statement: "\\b(else|for|if|switch|in|not_in|or_else|or_return|when)\\b"
+    - preproc: "\\b(assert|package|foreign|import|proc|defer|make|new|free|delete|copy|len|cap|append|raw_data)\\b"
+    - preproc: "\\b((size|align|offset|type|type_info|typeid)_of|offset_of_by_string)\\b"
+    - preproc: "\\b(swizzle|complex|quaternion|real|imag|jmag|kmag|conj|expand_to_tuple|min|max|abs|clamp|soa_zip|soa_unzip|transpose|outer_product|hadamard_product|matrix_flatten)\\b"
+    - symbol.operator: "[-+/*=<>!~%&|^@]|:\\s*=|:\\s*:|\\?"
+
+      # Types
+    - symbol: "(,|\\.)"
+    - type: "\\b(b(8|16|32|64)|(i|u)(8|(16|32|64|128)(le|be)?)|f(16|32|64)(le|be)?|complex(32|64|128)|quaternion(64|128|256))\\b"
+    - type: "\\b(any|bool|byte|rune|u?int|uintptr|rawptr|c?string|map|matrix|typeid)\\b"
+    - type.keyword: "\\b(distinct|struct|enum|union|bit_set)\\b"
+    - constant.bool: "\\b(true|false|nil)\\b"
+
+      # Brackets
+    - symbol.brackets: "(\\{|\\})"
+    - symbol.brackets: "(\\(|\\))"
+    - symbol.brackets: "(\\[|\\])"
+
+      # Numbers and strings
+    - constant.number: "\\b(0b[01]*|0o[0-7]*|0x[0-9a-fA-F]*|[0-9_]+|0d[0-9]*|0z[0-9abAB]*)\\b|'.'"
+
+    - constant.string:
+        start: "\""
+        end: "\""
+        skip: "\\\\."
+        rules:
+            - constant.specialChar: "%."
+            - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
+            - constant.specialChar: "\\\\([0-7]{1,3}|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})"
+
+    - constant.string:
+        start: "'"
+        end: "'"
+        skip: "\\\\."
+        rules:
+            - error: "..+"
+            - constant.specialChar: "%."
+            - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
+            - constant.specialChar: "\\\\([0-7]{1,3}|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})"
+
+    - constant.string:
+        start: "`"
+        end: "`"
+        rules: []
+
+    - comment:
+        start: "//"
+        end: "$"
+        rules:
+            - todo: "TODO:?|NOTE(\\(.*\\))?:?"
+
+    - comment:
+        start: "/\\*"
+        end: "\\*/"
+        rules:
+            - todo: "TODO:?|NOTE(\\(.*\\))?:?"