sublime/radiance.sublime-syntax 3.2 KiB raw
1
%YAML 1.2
2
---
3
name: Radiance
4
file_extensions:
5
  - rad
6
scope: source.radiance
7
8
variables:
9
  ident: '[A-Za-z_][A-Za-z0-9_]*'
10
  keywords: '\b(?:align|and|as|assert|break|case|catch|constant|continue|else|export|fn|for|if|in|instance|let|log|loop|match|mod|mut|not|or|panic|record|return|set|static|super|throw|throws|trait|try|union|use|while)\b'
11
  constants: '\b(?:false|nil|true|undefined)\b'
12
  types: '\b(?:bit|bool|f32|i8|i16|i32|i64|opaque|u8|u16|u32|u64|void)\b'
13
14
contexts:
15
  main:
16
    - include: comments
17
    - include: strings
18
    - include: builtins
19
    - include: namespaces
20
    - include: keywords
21
    - include: functions
22
    - include: numbers
23
    - include: operators
24
    - include: punctuation
25
26
  comments:
27
    - match: '//'
28
      scope: punctuation.definition.comment.radiance
29
      push: lineComment
30
    - match: '--'
31
      scope: punctuation.definition.comment.radiance
32
      push: lineComment
33
34
  lineComment:
35
    - meta_scope: comment.line.radiance
36
    - match: '\b(?:TODO|FIXME)\b'
37
      scope: keyword.other.todo.radiance
38
    - match: '$'
39
      pop: true
40
41
  strings:
42
    - match: '"'
43
      scope: punctuation.definition.string.begin.radiance
44
      push: doubleQuotedString
45
    - match: "'"
46
      scope: punctuation.definition.string.begin.radiance
47
      push: character
48
49
  doubleQuotedString:
50
    - meta_scope: string.quoted.double.radiance
51
    - match: '\\["''nrtvfab\\]'
52
      scope: constant.character.escape.radiance
53
    - match: '\\.'
54
      scope: invalid.illegal.escape.radiance
55
    - match: '"'
56
      scope: punctuation.definition.string.end.radiance
57
      pop: true
58
59
  character:
60
    - meta_scope: string.quoted.single.radiance
61
    - match: '\\["''nrtvfab\\]'
62
      scope: constant.character.escape.radiance
63
    - match: '\\.'
64
      scope: invalid.illegal.escape.radiance
65
    - match: "'"
66
      scope: punctuation.definition.string.end.radiance
67
      pop: true
68
69
  builtins:
70
    - match: '@{{ident}}'
71
      scope: support.function.builtin.radiance
72
73
  namespaces:
74
    - match: '\b{{ident}}\b(?=\s*::)'
75
      scope: entity.name.namespace.radiance
76
    - match: '::'
77
      scope: punctuation.accessor.double-colon.radiance
78
79
  functions:
80
    - match: '\b{{ident}}\b(?=\s*\??\()'
81
      scope: entity.name.function.radiance
82
83
  keywords:
84
    - match: '{{types}}'
85
      scope: storage.type.radiance
86
    - match: '{{constants}}'
87
      scope: constant.language.radiance
88
    - match: '{{keywords}}'
89
      scope: keyword.control.radiance
90
    - match: '\b_\b'
91
      scope: constant.language.placeholder.radiance
92
93
  numbers:
94
    - match: '(?<![A-Za-z0-9_])[+-]?0[xX][0-9A-Fa-f]+'
95
      scope: constant.numeric.integer.hexadecimal.radiance
96
    - match: '(?<![A-Za-z0-9_])[+-]?0[bB][01]+'
97
      scope: constant.numeric.integer.binary.radiance
98
    - match: '(?<![A-Za-z0-9_])[+-]?(?:[0-9]+\.[0-9]+|[0-9]+)'
99
      scope: constant.numeric.radiance
100
101
  operators:
102
    - match: '=>|->|\.\.|<<=|>>=|==|<>|<=|>=|\+=|-=|\*=|/=|%=|&=|\|=|\^=|<<|>>|[.!?~&|^%+\-*/=<>:]'
103
      scope: keyword.operator.radiance
104
105
  punctuation:
106
    - match: '[{}]'
107
      scope: punctuation.section.block.radiance
108
    - match: '[()]'
109
      scope: punctuation.section.group.radiance
110
    - match: '[\[\]]'
111
      scope: punctuation.section.brackets.radiance
112
    - match: '[,;]'
113
      scope: punctuation.separator.radiance