ox.sublime-syntax (3651B)
1 %YAML 1.2 2 --- 3 name: Ox 4 file_extensions: 5 - ox 6 scope: source.ox 7 8 # ------------------------------------------------------------------ 9 # Top‑level contexts – the “main” context is what Sublime loads first 10 # ------------------------------------------------------------------ 11 contexts: 12 main: 13 - include: comments # block / line / shebang 14 - include: keywords 15 - include: numbers 16 - include: strings 17 - include: basic-types 18 - include: functions 19 - include: typedefs 20 - include: builtins 21 22 # ------------------------------------------------------------------ 23 # Comments 24 # ------------------------------------------------------------------ 25 comments: 26 - include: block-comment # /* … */ 27 - match: '//.*$' 28 scope: comment.line.double-slash 29 - match: '#!.*$' 30 scope: comment.line.double-slash 31 32 # ------------------------------------------------------------------ 33 # Block comments – allows nesting 34 # ------------------------------------------------------------------ 35 block-comment: 36 - match: '/\*' 37 scope: punctuation.definition.comment 38 push: 39 - meta_scope: comment.block 40 # end of block comment – pop back to the parent context 41 - match: '\*/' 42 scope: punctuation.definition.comment 43 pop: true 44 # allow nested block comments 45 - include: block-comment 46 47 # ------------------------------------------------------------------ 48 # Keywords, operators and constants 49 # ------------------------------------------------------------------ 50 keywords: 51 - match: '\b(const|else|for|if|pkg|record|return|typedef|match|case|while)\b' 52 scope: keyword.control 53 - match: '\b(and|by|in|not|or)\b' 54 scope: keyword.operator 55 - match: '\b(false|nil|true)\b' 56 scope: constant.language 57 58 # ------------------------------------------------------------------ 59 # Built‑in functions 60 # ------------------------------------------------------------------ 61 builtins: 62 - match: '\b(abs|len|assert|print|exit|panic)\b' 63 scope: variable.function support.function.builtin 64 65 # ------------------------------------------------------------------ 66 # Numbers 67 # ------------------------------------------------------------------ 68 numbers: 69 - match: '\b([+-])?[0-9]+(\.[0-9]*(e[0-9]+))?\b' 70 scope: constant.numeric 71 - match: '\b([+-])?0x[0-9A-Fa-f]+\b' 72 scope: constant.numeric 73 74 # ------------------------------------------------------------------ 75 # Basic types 76 # ------------------------------------------------------------------ 77 basic-types: 78 - match: '\b(int|void|float|char|string|bool)\b' 79 scope: storage.type 80 81 # ------------------------------------------------------------------ 82 # Function names look‑ahead for '(') 83 # ------------------------------------------------------------------ 84 functions: 85 - match: '\b([A-Za-z_][A-Za-z0-9_]*)\s*(?=$)' 86 scope: entity.name.function 87 88 # ------------------------------------------------------------------ 89 # Type names (capitalised identifiers) 90 # ------------------------------------------------------------------ 91 typedefs: 92 - match: '\b[A-Z][A-Za-z0-9_]*\b' 93 scope: entity.name.type 94 95 # ------------------------------------------------------------------ 96 # Strings (double‑quoted) 97 # ------------------------------------------------------------------ 98 strings: 99 - begin: '"' 100 end: '"' 101 scope: string.quoted.double 102 # enable escape handling inside the string 103 escaped: true 104 patterns: 105 - match: '\\.' 106 scope: constant.character.escape