sublime/ril.sublime-syntax 2.7 KiB raw
1
%YAML 1.2
2
---
3
name: Radiance IL
4
file_extensions:
5
  - ril
6
scope: source.ril
7
8
variables:
9
  label: '[A-Za-z_][A-Za-z0-9_#.]*'
10
  symbol: '[A-Za-z_][$A-Za-z0-9_]*'
11
  keywords: '\b(?:align|data|extern|fn|mut)\b'
12
  instructions: '\b(?:add|and|blit|call|copy|ebreak|ecall|eq|jmp|load|mul|ne|neg|not|or|reserve|ret|sdiv|sext|sge|shl|sload|slt|srem|sshr|store|sub|switch|udiv|uge|ult|unreachable|urem|ushr|xor|zext)\b'
13
  dataItems: '\b(?:str|sym|undef|undefined)\b'
14
  types: '\b(?:void|w8|w16|w32|w64)\b'
15
16
contexts:
17
  main:
18
    - include: comments
19
    - include: symbols
20
    - include: strings
21
    - include: labels
22
    - include: registers
23
    - include: branches
24
    - include: keywords
25
    - include: numbers
26
    - include: punctuation
27
28
  comments:
29
    - match: '//'
30
      scope: punctuation.definition.comment.ril
31
      push: lineComment
32
33
  lineComment:
34
    - meta_scope: comment.line.double-slash.ril
35
    - match: '\b(?:TODO|FIXME)\b'
36
      scope: keyword.other.todo.ril
37
    - match: '$'
38
      pop: true
39
40
  strings:
41
    - match: '"'
42
      scope: punctuation.definition.string.begin.ril
43
      push: doubleQuotedString
44
45
  doubleQuotedString:
46
    - meta_scope: string.quoted.double.ril
47
    - match: '\\.'
48
      scope: constant.character.escape.ril
49
    - match: '"'
50
      scope: punctuation.definition.string.end.ril
51
      pop: true
52
53
  symbols:
54
    - match: '(\$)(")([^"]*)(")'
55
      captures:
56
        1: punctuation.definition.variable.ril
57
        2: punctuation.definition.string.begin.ril
58
        3: variable.other.symbol.quoted.ril
59
        4: punctuation.definition.string.end.ril
60
    - match: '\${{symbol}}'
61
      scope: variable.other.symbol.ril
62
63
  labels:
64
    - match: '@{{label}}'
65
      scope: entity.name.label.ril
66
67
  registers:
68
    - match: '%[A-Za-z0-9_]+'
69
      scope: variable.other.register.ril
70
71
  branches:
72
    - match: '\b(br)\.(eq|ne|slt|ult)\b'
73
      scope: keyword.control.branch.ril
74
      captures:
75
        1: keyword.control.branch.ril
76
        2: keyword.operator.comparison.ril
77
78
  keywords:
79
    - match: '{{types}}'
80
      scope: storage.type.ril
81
    - match: '{{dataItems}}'
82
      scope: constant.language.ril
83
    - match: '{{instructions}}'
84
      scope: keyword.other.instruction.ril
85
    - match: '{{keywords}}'
86
      scope: keyword.control.ril
87
88
  numbers:
89
    - match: '(?<![A-Za-z0-9_])-?0[xX][0-9A-Fa-f]+'
90
      scope: constant.numeric.integer.hexadecimal.ril
91
    - match: '(?<![A-Za-z0-9_])-?[0-9]+'
92
      scope: constant.numeric.integer.decimal.ril
93
94
  punctuation:
95
    - match: '[{}]'
96
      scope: punctuation.section.block.ril
97
    - match: '[()]'
98
      scope: punctuation.section.group.ril
99
    - match: '[;:,]'
100
      scope: punctuation.separator.ril
101
    - match: '\*'
102
      scope: keyword.operator.ril