vim/ril.vim 2.2 KiB raw
1
" ril.vim
2
" Syntax for Radiance IL (.ril) files
3
" (c) Alexis Sellier
4
"
5
if exists("b:current_syntax")
6
  finish
7
endif
8
9
syntax clear
10
11
" Comments (Radiance style)
12
syntax match rilComment "//.*$"
13
syntax keyword rilTodo TODO FIXME contained containedin=rilComment
14
15
" Keywords
16
syntax keyword rilKeyword fn data extern mut align
17
18
" Instructions (memory)
19
syntax keyword rilInstr reserve load sload store blit copy elem
20
" Instructions (arithmetic)
21
syntax keyword rilInstr add sub mul sdiv udiv srem urem neg
22
" Instructions (comparison)
23
syntax keyword rilInstr eq ne slt sge ult uge
24
" Instructions (bitwise)
25
syntax keyword rilInstr and or xor shl sshr ushr not
26
" Instructions (conversions)
27
syntax keyword rilInstr zext sext
28
" Instructions (pointer)
29
syntax keyword rilInstr ptr
30
" Instructions (calls and terminators)
31
syntax keyword rilInstr call ret jmp switch unreachable
32
" Instructions (intrinsics)
33
syntax keyword rilInstr ecall ebreak
34
35
" Branch instructions (br.eq, br.ne, br.slt, br.ult)
36
syntax match rilBranch "\<br\.\(eq\|ne\|slt\|ult\)\>"
37
38
" Data items
39
syntax keyword rilDataItem str sym undef
40
41
" Types
42
syntax keyword rilType w8 w16 w32 w64 ptr void
43
44
" Block labels (@identifier0, @eq#foobar1)
45
syntax match rilLabel "@[A-Za-z_][A-Za-z0-9_#]*"
46
47
" Symbol names ($name or $"qualified::name")
48
syntax match rilSymbol "\$[A-Za-z_][$A-Za-z0-9_]*"
49
syntax match rilSymbol '\$"[^"]*"'
50
51
" Registers (%0, %1, etc.)
52
syntax match rilReg "%\d\+"
53
54
" Numbers
55
syntax match rilNumber "\<-\?\d\+\>"
56
syntax match rilNumber "\<0[xX][a-fA-F0-9]\+\>"
57
58
" Strings
59
syntax region rilString start=+"+ skip=+\\"+ end=+"+
60
61
" Punctuation
62
syntax match rilPunct "[{}();:,]"
63
syntax match rilOperator "\*"
64
65
" Define highlighting
66
highlight default link rilKeyword Keyword
67
highlight default link rilInstr Statement
68
highlight default link rilBranch Statement
69
highlight default link rilDataItem Special
70
highlight default link rilType Type
71
highlight default link rilComment Comment
72
highlight default link rilTodo Todo
73
highlight default link rilLabel Label
74
highlight default link rilSymbol Function
75
highlight default link rilReg Identifier
76
highlight default link rilNumber Number
77
highlight default link rilString String
78
highlight default link rilPunct Delimiter
79
highlight default link rilOperator Operator
80
81
let b:current_syntax = "ril"