micro/runtime/syntax/odin.yaml
ftphikari d3b9b37b07
runtime/syntax: add rudimentary Odin support (#2296)
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
2022-02-11 14:15:34 -08:00

65 lines
2.3 KiB
YAML

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(\\(.*\\))?:?"