1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
" Vim syntax file
"
" Language: Colm
" Author: Adrian Thurston
syntax clear
"
" Regular Language Types
"
" Identifiers
syntax match rlId "[a-zA-Z_][a-zA-Z_0-9]*" contained
" Literals
syntax match rlLiteral "'\(\\.\|[^'\\]\)*'[i]*" contained
syntax match rlLiteral "\"\(\\.\|[^\"\\]\)*\"[i]*" contained
syntax match rlLiteral "\[\(\\.\|[^\]\\]\)*\]" contained
" Numbers
syntax match rlNumber "[0-9][0-9]*" contained
syntax match rlNumber "0x[0-9a-fA-F][0-9a-fA-F]*" contained
" Operators
syntax match rlOtherOps ":>" contained
syntax match rlOtherOps ":>>" contained
syntax match rlOtherOps "<:" contained
syntax cluster rlTypes contains=rlId,rlLiteral,rlNumber,rlOtherOps
syntax region rlTypeRegion matchgroup=regionDelimiter start="/" end="/"
\ contains=@rlTypes
syntax region cflTypeRegion matchgroup=regionDelimiter start="\[" end="\]"
\ contains=cflTypeRegion,patRegion,otLit,Type,Keyword,varCapture,qual
syntax region patRegion matchgroup=String start="\"" end="\"" end="\n"
\ contains=char,cflTypeRegion
syntax match char "[^\"\[]" contained
syntax match char "\\." contained
syntax match otLit "\~.*$"
syntax match otLit "'\(\\.\|[^'\\]\)*\('[i]*\)\?"
syntax match otLit "`[^ \t\r][^ \t\r\]`]*`\?"
"
" Other stuff
"
syntax match tlComment "#.*$"
syntax match tlIdentifier "[a-zA-Z_][a-zA-Z_0-9]*"
syntax match tlNumber "[0-9][0-9]*"
syntax match tlNumber "nil"
syntax match tlNumber "true"
syntax match tlNumber "false"
syntax keyword Type
\ int str bool any ref ptr void list_el map_el
\ commit literal iter
\ namespace lex reducefirst global include export
\ preeof left right nonassoc prec context struct alias
\ end eos print nonterm
\ construct cons parse parse_tree parse_stop reduce
\ match require send send_tree eos
syntax keyword Keyword
\ reject else elsif return yield for while if
\ typeid break
\ deref ni switch case default
\ in new cast
syntax match tokenName "[a-zA-Z_][a-zA-Z_0-9]*" contained
syntax match varCapture "[a-zA-Z_][a-zA-Z_0-9]*:"
syntax match qual "[a-zA-Z_][a-zA-Z_0-9]*::"
syntax region defTypes matchgroup=defKeywords
\ start="\<rl\>" start="\<def\>" start="\<token\>" start="\<ignore\>"
\ matchgroup=Function end="[a-zA-Z_][a-zA-Z0-9_]*" end="/"me=e-1 end="`"me=e-1
syntax region redTypes matchgroup=redBlock
\ start="\<reduction\>"
\ contains=externalCode,extComment
\ end="\<end\>"
syntax match extComment "#.*$" contained
syntax region externalCode contained
\ start="{"
\ contains=@redItems
\ end="}"
syntax cluster redItems contains=redRef,redType,redKeyword,redNumber,redIdentifier,redLiteral,redComment,externalCode
syntax region redComment start="\/\*" end="\*\/" contained
syntax match redComment "\/\/.*$" contained
syntax match redLiteral "'\(\\.\|[^'\\]\)*'" contained
syntax match redLiteral "\"\(\\.\|[^\"\\]\)*\"" contained
syntax match redRef "\$\$" contained
syntax match redRef "\$[a-zA-Z_][a-zA-Z0-9_]*" contained
syntax match redRef "\$\*[a-zA-Z_][a-zA-Z0-9_]*" contained
syntax match redRef "@[a-zA-Z_][a-zA-Z0-9_]*" contained
syntax match redRef "\$[0-9]\+" contained
syntax match redRef "\$\*[0-9]\+" contained
syntax match redRef "@[0-9]\+" contained
syntax match redNumber "[0-9][0-9]*" contained
syntax match redNumber "true" contained
syntax match redNumber "false" contained
syntax match redIdentifier "[a-zA-Z_][a-zA-Z_0-9]*" contained
syntax keyword redType unsigned signed void char short int long float double bool contained
syntax keyword redType inline static extern register const volatile auto contained
syntax keyword redType union enum struct class typedef contained
syntax keyword redType namespace template typename mutable contained
syntax keyword redKeyword break continue default do else for contained
syntax keyword redKeyword goto if return switch while contained
syntax keyword redKeyword new delete this using friend public private protected sizeof contained
syntax keyword redKeyword throw try catch operator typeid contained
syntax keyword redKeyword and bitor xor compl bitand and_eq or_eq xor_eq not not_eq contained
syntax keyword redKeyword static_cast dynamic_cast contained
syntax sync match colmSyncPat grouphere NONE "([{}]|\<reduction\>|\<token\>|\<ignore\>|\<def\>)"
"
" Specifying Groups
"
hi link tlComment Comment
hi link tlNumber Number
hi link otLit String
hi link rlNumber Number
hi link rlLiteral String
hi link defKeywords Type
hi link redBlock Type
hi link regionDelimiter Type
hi link char String
hi link tokenName Function
hi link varCapture Identifier
hi link extComment Comment
hi link redType Type
hi link redKeyword Keyword
hi link redLiteral String
hi link redRef Function
hi link redComment Comment
hi link redNumber Number
let b:current_syntax = "colm"
|