|
1 | 1 | " Vim syntax file
|
2 | 2 | " Language: Pyret
|
3 |
| -" Maintainer: Joe Gibbs Politz ([email protected]) |
| 3 | +" Maintainer: Rachit Nigam ([email protected]) |
4 | 4 |
|
5 | 5 | if exists("b:current_syntax")
|
6 | 6 | finish
|
7 | 7 | endif
|
8 | 8 |
|
| 9 | +syn case match |
| 10 | +syn sync minlines=200 maxlines=1000 |
| 11 | + |
9 | 12 | set iskeyword+=-
|
10 |
| -set iskeyword+=: |
11 | 13 |
|
12 | 14 | syn match delimeter '!'
|
13 | 15 | syn match delimeter '\.'
|
14 |
| -syn match delimeter '|' |
15 |
| -syn match delimeter '(' |
16 |
| -syn match delimeter ')' |
17 |
| -syn match delimeter '->' |
18 | 16 | syn match delimeter '='
|
19 |
| -syn match delimeter '=>' |
20 | 17 | syn match delimeter ':='
|
21 |
| - |
22 |
| -syn match delimeter '\[' |
23 |
| -syn match delimeter '\]' |
24 |
| -syn match delimeter '{' |
25 |
| -syn match delimeter '}' |
26 | 18 | syn match delimeter ':'
|
27 |
| -syn match delimeter '::' |
28 |
| - |
29 |
| -syn keyword basic var fun end with: sharing: data include import provide as try: except when |
30 |
| -syn keyword basic for from check: where: doc: and or not else: if else cases |
31 |
| -syn keyword basic is is== is=~ is<=> is-not is-not== is-not=~ is-not<=> raises |
32 |
| -syn keyword basic deriving ref graph: m-graph: block: satisfies violates shadow lam type type-let provide-types newtype |
33 |
| -syn keyword basic let rec letrec ask: table: extend using row: select extract order sieve by |
34 |
| - |
35 |
| -syn match op ' + ' |
36 |
| -syn match op ' - ' |
37 |
| -syn match op ' / ' |
38 |
| -syn match op ' * ' |
39 |
| -syn match op ' > ' |
40 |
| -syn match op ' < ' |
41 |
| -syn match op ' >= ' |
42 |
| -syn match op ' <= ' |
43 |
| -syn match op ' <> ' |
44 |
| - |
45 |
| -syn match comment '\#.*$' |
46 |
| -syntax region comment start=/#|/ skip=/\./ end=/|#/ |
47 |
| - |
48 |
| -syntax region string start=/\v"/ skip=/\v\\./ end=/\v"/ |
49 |
| -syntax region string start=/\v'/ skip=/\v\\./ end=/\v'/ |
50 |
| -syntax region string start=/\v```/ skip=/\v\\./ end=/\v```/ |
51 |
| - |
52 |
| -syn match number "[0-9]+" |
53 |
| - |
54 |
| -hi def link comment Comment |
55 |
| -hi def link basic Function |
56 |
| -hi def link delimeter PreProc |
57 |
| -hi def link op Label |
58 |
| -hi def link string Constant |
59 |
| -hi def link number Constant |
60 |
| -hi def link literal Constant |
| 19 | + |
| 20 | +hi link delimeter PreProc |
| 21 | + |
| 22 | +" Keywords |
| 23 | +syn keyword pyretKeyword var from shadow ref |
| 24 | +hi link pyretKeyword Special |
| 25 | + |
| 26 | +" Imports and exports |
| 27 | +syn keyword pyretImport include import provide provide-types as |
| 28 | +hi link pyretImport PreProc |
| 29 | + |
| 30 | +" Block structures in pyret |
| 31 | +syn keyword pyretBlock end for check examples |
| 32 | +syn keyword pyretBlock except when |
| 33 | +syn keyword pyretBlock if else |
| 34 | +syn keyword pyretBlock deriving satisfies |
| 35 | +syn keyword pyretBlock violates type-let |
| 36 | +syn keyword pyretBlock let rec letrec extend using select |
| 37 | +syn keyword pyretBlock extract order sieve by raises newtype |
| 38 | +hi link pyretBlock Function |
| 39 | + |
| 40 | +" Built-in functions |
| 41 | +syn keyword pyretBuiltin is is== is=~ is<=> is-not is-not== is-not=~ is-not<=> |
| 42 | +syn keyword pyretBuiltin and or not |
| 43 | +syn keyword pyretBuiltin torepr to-repr tostring to-string raise |
| 44 | +syn keyword pyretBuiltin is-boolean is-number is-string is-raw-array is-nothing |
| 45 | +syn keyword pyretBuiltin is-function is-object |
| 46 | +hi link pyretBuiltin Constant |
| 47 | + |
| 48 | +" Operators |
| 49 | +syn match pyretOperator '+' |
| 50 | +syn match pyretOperator '-' |
| 51 | +syn match pyretOperator '/' |
| 52 | +syn match pyretOperator '*' |
| 53 | +syn match pyretOperator '>' |
| 54 | +syn match pyretOperator '<' |
| 55 | +syn match pyretOperator '>=' |
| 56 | +syn match pyretOperator '<=' |
| 57 | +syn match pyretOperator '<>' |
| 58 | +syn match pyretOperator '\^' |
| 59 | +hi link pyretOperator Label |
| 60 | + |
| 61 | +" Comments |
| 62 | +syn match pyretComment '\#.*$' contains=pyretTodo |
| 63 | +syntax region pyretComment start=/#|/ skip=/\./ end=/|#/ contains=pyretTodo |
| 64 | +hi link pyretComment Comment |
| 65 | + |
| 66 | +" Todo |
| 67 | +syn match pyretTodo /\v<(TODO|FIXME|NOTE)>/ contained |
| 68 | +hi link pyretTodo Todo |
| 69 | + |
| 70 | +" Strings |
| 71 | +syn region pyretString start=/\v"/ skip=/\v\\./ end=/\v("|$)/ |
| 72 | +syn region pyretString start=/\v'/ skip=/\v\\./ end=/\v('|$)/ |
| 73 | +syn region pyretString start=/\v```/ skip=/\v\\./ end=/\v```/ |
| 74 | +hi link pyretString String |
| 75 | +syn match pyretEscapedChar '\v\\.' containedin=pyretString contained |
| 76 | +hi link pyretEscapedChar Special |
| 77 | + |
| 78 | +" Numbers |
| 79 | +syn match pyretConstant "\v(\-|\+)?[0-9]+(\.[0-9]+)?(e[0-9]+)?" |
| 80 | +" Booleans |
| 81 | +syn keyword pyretConstant true |
| 82 | +syn keyword pyretConstant false |
| 83 | +" nothing |
| 84 | +syn keyword pyretConstant nothing |
| 85 | + |
| 86 | +hi link pyretConstant Constant |
| 87 | + |
| 88 | +" Template |
| 89 | +syntax match pyretTemplate '\v\.\.\.' |
| 90 | +hi link pyretTemplate ERROR |
| 91 | + |
| 92 | +" Variable names in pyret. Need to be higher priority than numbers |
| 93 | +syn match pyretName '\v[_a-zA-Z]((\-+)?[_a-zA-Z0-9]+)*' |
| 94 | + \ nextgroup=pyretColonColon skipwhite |
| 95 | +syn match pyretColonColon '::' nextgroup=@pyretAnn skipwhite |
| 96 | +hi link pyretColonColon Keyword |
| 97 | + |
| 98 | +" Keywords ending with :. Need to be after variables. |
| 99 | +syn match pyretBlock 'with:' |
| 100 | +syn match pyretBlock 'sharing:' |
| 101 | +syn match pyretBlock 'try:' |
| 102 | +syn match pyretBlock 'check:' |
| 103 | +syn match pyretBlock 'where:' |
| 104 | +syn match pyretBlock 'doc:' |
| 105 | +syn match pyretBlock 'else:' |
| 106 | +syn match pyretBlock 'graph:' |
| 107 | +syn match pyretBlock 'block:' |
| 108 | +syn match pyretBlock 'ask:' |
| 109 | +syn match pyretBlock 'table:' |
| 110 | +syn match pyretBlock 'row:' |
| 111 | +syn match pyretBlock 'm-graph:' |
| 112 | + |
| 113 | +" Variables bound by `from` |
| 114 | +syn match pyretFromName '\v[_a-zA-Z]((\-+)?[_a-zA-Z0-9]+)*\ze(\s+::\s+\S+)?\s+from' |
| 115 | +hi link pyretFromName Identifier |
| 116 | + |
| 117 | +" Type Annotations |
| 118 | +syn cluster pyretAnn |
| 119 | + \ contains=pyretSimpleAnn,pyretComplexAnn,pyretRecordAnn,pyretParenAnn,pyretAnnDot |
| 120 | + |
| 121 | +syn region pyretComplexAnn matchgroup=Keyword start='\v\<' end='\v\>' |
| 122 | + \ contained contains=@pyretAnn nextgroup=pyretAnnArrow,pyretRefineStart skipwhite |
| 123 | +hi link pyretComplexAnn Type |
| 124 | + |
| 125 | +syn match pyretSimpleAnn '\v%((\w+-\w+)|\w+)' contained |
| 126 | + \ nextgroup=pyretComplexAnn,pyretAnnArrow,pyretAnnDot,pyretRefineStart skipwhite |
| 127 | +hi link pyretSimpleAnn Type |
| 128 | + |
| 129 | +syn match pyretRefineStart '\v\%' contained nextgroup=pyretRefineAnn |
| 130 | +hi link pyretRefineStart Keyword |
| 131 | + |
| 132 | +syn region pyretRefineAnn matchgroup=Keyword start='\v\(' end='\v\)' contained |
| 133 | + \ contains=pyretName nextgroup=pyretAnnArrow skipwhite |
| 134 | + |
| 135 | +syn match pyretAnnDot '\.' contained nextgroup=pyretSimpleAnn |
| 136 | +hi link pyretAnnDot Keyword |
| 137 | + |
| 138 | +syn region pyretRecordAnn matchgroup=Keyword start='\v\{' end='\v\}' contained |
| 139 | + \ contains=@pyretAnn,pyretSemicolon nextgroup=pyretAnnArrow skipwhite |
| 140 | +hi link pyretRecordAnn Type |
| 141 | + |
| 142 | +syn match pyretSemicolon ';' contained |
| 143 | +hi link pyretSemicolon Keyword |
| 144 | + |
| 145 | +syn region pyretParenAnn matchgroup=Keyword start='\v\(' end='\v\)' contained |
| 146 | + \ contains=@pyretAnn skipwhite |
| 147 | +hi link pyretParenAnn Type |
| 148 | + |
| 149 | +syn match pyretAnnArrow '\v-\>' contained nextgroup=@pyretAnn skipwhite |
| 150 | +hi link pyretAnnArrow Keyword |
| 151 | + |
| 152 | +" `type` expressions |
| 153 | +syn region pyretTypeDecl matchgroup=Keyword start='\v<type>' end='\v$' |
| 154 | + \ contains=@pyretAnn,pyretComment skipwhite keepend |
| 155 | + |
| 156 | +" fun defintions |
| 157 | +syn keyword pyretBlock fun method nextgroup=pyretFunName skipwhite |
| 158 | +syn keyword pyretBlock lam nextgroup=pyretArgs,pyretFunTypeParam skipwhite |
| 159 | +syn match pyretFunComma ',' contained |
| 160 | +hi link pyretFunComma Special |
| 161 | + |
| 162 | +syn match pyretFunName '\v[_a-zA-Z]((\-+)?[_a-zA-Z0-9]+)*' contained |
| 163 | + \ nextgroup=pyretArgs,pyretFunTypeParam skipwhite |
| 164 | +hi link pyretFunName Constant |
| 165 | + |
| 166 | +syn region pyretFunTypeParam matchgroup=Keyword start='\v\<' end='\v\>' |
| 167 | + \ contained contains=@pyretAnn nextgroup=pyretArgs skipwhite |
| 168 | +hi link pyretFunTypeParam Type |
| 169 | + |
| 170 | +syn region pyretArgs matchgroup=Keyword start='\v\(' end='\v\)' |
| 171 | + \ contained contains=pyretArgName,pyretFunComma,pyretKeyword,pyretComment |
| 172 | + \ nextgroup=pyretAnnArrow skipwhite |
| 173 | +hi link pyretArgs Identifier |
| 174 | + |
| 175 | +syn match pyretArgName '\v[_a-zA-Z]((\-+)?[_a-zA-Z0-9]+)*' contained transparent |
| 176 | + \ nextgroup=pyretColonColon skipwhite |
| 177 | + |
| 178 | +" cases using | |
| 179 | +syn match pyretBar '\v\|' nextgroup=pyretFunName skipwhite |
| 180 | +hi link pyretBar Keyword |
| 181 | +syn match pyretCaseArrow '\v\=\>' |
| 182 | +hi link pyretCaseArrow Keyword |
| 183 | + |
| 184 | +" Data defintions |
| 185 | +syn keyword pyretBlock data nextgroup=pyretSimpleAnn skipwhite |
| 186 | + |
| 187 | +" cases keyword |
| 188 | +syn keyword pyretBlock cases nextgroup=pyretCaseType skipwhite |
| 189 | +syn region pyretCaseType matchgroup=Keyword start='\v\(' end='\v\)' |
| 190 | + \ contained contains=@pyretAnn skipwhite |
61 | 191 |
|
0 commit comments