Mercurial > vim
annotate runtime/syntax/awk.vim @ 10705:f5cabb0cd638
Added tag v8.0.0242 for changeset 6736cb42572042c7517086af404d1464711d2af0
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 26 Jan 2017 22:15:04 +0100 |
parents | b11ceef7116e |
children | 350e1d3131d8 |
rev | line source |
---|---|
7 | 1 " Vim syntax file |
2 " Language: awk, nawk, gawk, mawk | |
3312 | 3 " Maintainer: Antonio Colombo <azc100@gmail.com> |
10140
b11ceef7116e
commit https://github.com/vim/vim/commit/64d8e25bf6efe5f18b032563521c3ce278c316ab
Christian Brabandt <cb@256bit.org>
parents:
9533
diff
changeset
|
4 " Last Change: 2016 Sep 05 |
7 | 5 |
9533
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
6 " AWK ref. is: Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger |
7 | 7 " The AWK Programming Language, Addison-Wesley, 1988 |
8 | |
9 " GAWK ref. is: Arnold D. Robbins | |
10 " Effective AWK Programming, Third Edition, O'Reilly, 2001 | |
6530 | 11 " Effective AWK Programming, Fourth Edition, O'Reilly, 2015 |
9533
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
12 " (also available and updated with the gawk source distribution) |
7 | 13 |
14 " MAWK is a "new awk" meaning it implements AWK ref. | |
15 " mawk conforms to the Posix 1003.2 (draft 11.3) | |
16 " definition of the AWK language which contains a few features | |
17 " not described in the AWK book, and mawk provides a small number of extensions. | |
18 | |
19 " TODO: | |
20 " Dig into the commented out syntax expressions below. | |
21 | |
9533
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
22 " Quit when a syntax file was already loaded |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
23 if exists("b:current_syntax") |
7 | 24 finish |
25 endif | |
26 | |
3312 | 27 let s:cpo_save = &cpo |
28 set cpo&vim | |
29 | |
7 | 30 " A bunch of useful Awk keywords |
31 " AWK ref. p. 188 | |
32 syn keyword awkStatement break continue delete exit | |
33 syn keyword awkStatement function getline next | |
34 syn keyword awkStatement print printf return | |
9533
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
35 " GAWK ref. Chapter 7-9 |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
36 syn keyword awkStatement switch nextfile |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
37 syn keyword awkStatement func |
6530 | 38 " |
39 " GAWK ref. Chapter 9, Functions | |
40 " Numeric Functions | |
9533
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
41 syn keyword awkFunction atan2 cos exp int intdiv log rand sin sqrt srand |
6530 | 42 " String Manipulation Functions |
43 syn keyword awkFunction asort asort1 gensub gsub index length match | |
44 syn keyword awkFunction patsplit split sprintf strtonum sub substr | |
7 | 45 syn keyword awkFunction tolower toupper |
6530 | 46 " Input Output Functions |
47 syn keyword awkFunction close fflush system | |
48 " Time Functions | |
49 syn keyword awkFunction mktime strftime systime | |
50 " Bit Manipulation Functions | |
51 syn keyword awkFunction and compl lshift or rshift xor | |
9533
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
52 " Getting Type Functions |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
53 syn keyword awkFunction isarray typeof |
6530 | 54 " String-Translation Functions |
55 syn keyword awkFunction bindtextdomain dcgettext dcngetext | |
7 | 56 |
57 syn keyword awkConditional if else | |
9533
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
58 syn keyword awkRepeat while for do |
7 | 59 |
9533
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
60 syn keyword awkTodo contained TODO |
7 | 61 |
9533
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
62 syn keyword awkPatterns BEGIN END BEGINFILE ENDFILE |
6530 | 63 |
64 " GAWK ref. Chapter 7 | |
65 " Built-in Variables That Control awk | |
66 syn keyword awkVariables BINMODE CONVFMT FIELDWIDTHS FPAT FS | |
67 syn keyword awkVariables IGNORECASE LINT OFMT OFS ORS PREC | |
68 syn keyword awkVariables ROUNDMODE RS SUBSEP TEXTDOMAIN | |
69 " Built-in Variables That Convey Information | |
70 syn keyword awkVariables ARGC ARGV ARGIND ENVIRON ERRNO FILENAME | |
71 syn keyword awkVariables FNR NF FUNCTAB NR PROCINFO RLENGTH RSTART | |
72 syn keyword awkVariables RT SYMTAB | |
7 | 73 |
10140
b11ceef7116e
commit https://github.com/vim/vim/commit/64d8e25bf6efe5f18b032563521c3ce278c316ab
Christian Brabandt <cb@256bit.org>
parents:
9533
diff
changeset
|
74 " Arithmetic operators: +, and - take care of ++, and -- |
b11ceef7116e
commit https://github.com/vim/vim/commit/64d8e25bf6efe5f18b032563521c3ce278c316ab
Christian Brabandt <cb@256bit.org>
parents:
9533
diff
changeset
|
75 syn match awkOperator "+\|-\|\*\|/\|%\|=" |
b11ceef7116e
commit https://github.com/vim/vim/commit/64d8e25bf6efe5f18b032563521c3ce278c316ab
Christian Brabandt <cb@256bit.org>
parents:
9533
diff
changeset
|
76 syn match awkOperator "+=\|-=\|\*=\|/=\|%=" |
b11ceef7116e
commit https://github.com/vim/vim/commit/64d8e25bf6efe5f18b032563521c3ce278c316ab
Christian Brabandt <cb@256bit.org>
parents:
9533
diff
changeset
|
77 syn match awkOperator "\^\|\^=" |
7 | 78 |
79 " Octal format character. | |
80 syn match awkSpecialCharacter display contained "\\[0-7]\{1,3\}" | |
81 " Hex format character. | |
82 syn match awkSpecialCharacter display contained "\\x[0-9A-Fa-f]\+" | |
83 | |
84 syn match awkFieldVars "\$\d\+" | |
85 | |
9533
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
86 " catch errors caused by wrong parenthesis |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
87 syn region awkParen transparent start="(" end=")" contains=ALLBUT,awkParenError,awkSpecialCharacter,awkArrayElement,awkArrayArray,awkTodo,awkRegExp,awkBrktRegExp,awkBrackets,awkCharClass,awkComment |
7 | 88 syn match awkParenError display ")" |
9533
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
89 "syn match awkInParen display contained "[{}]" |
7 | 90 |
91 " 64 lines for complex &&'s, and ||'s in a big "if" | |
92 syn sync ccomment awkParen maxlines=64 | |
93 | |
94 " Search strings & Regular Expressions therein. | |
95 syn region awkSearch oneline start="^[ \t]*/"ms=e start="\(,\|!\=\~\)[ \t]*/"ms=e skip="\\\\\|\\/" end="/" contains=awkBrackets,awkRegExp,awkSpecialCharacter | |
96 syn region awkBrackets contained start="\[\^\]\="ms=s+2 start="\[[^\^]"ms=s+1 end="\]"me=e-1 contains=awkBrktRegExp,awkCharClass | |
97 syn region awkSearch oneline start="[ \t]*/"hs=e skip="\\\\\|\\/" end="/" contains=awkBrackets,awkRegExp,awkSpecialCharacter | |
98 | |
99 syn match awkCharClass contained "\[:[^:\]]*:\]" | |
100 syn match awkBrktRegExp contained "\\.\|.\-[^]]" | |
101 syn match awkRegExp contained "/\^"ms=s+1 | |
102 syn match awkRegExp contained "\$/"me=e-1 | |
103 syn match awkRegExp contained "[?.*{}|+]" | |
104 | |
105 " String and Character constants | |
106 " Highlight special characters (those which have a backslash) differently | |
3513 | 107 syn region awkString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell,awkSpecialCharacter,awkSpecialPrintf |
7 | 108 syn match awkSpecialCharacter contained "\\." |
109 | |
110 " Some of these combinations may seem weird, but they work. | |
111 syn match awkSpecialPrintf contained "%[-+ #]*\d*\.\=\d*[cdefgiosuxEGX%]" | |
112 | |
113 " Numbers, allowing signs (both -, and +) | |
114 " Integer number. | |
115 syn match awkNumber display "[+-]\=\<\d\+\>" | |
116 " Floating point number. | |
117 syn match awkFloat display "[+-]\=\<\d\+\.\d+\>" | |
118 " Floating point number, starting with a dot. | |
119 syn match awkFloat display "[+-]\=\<.\d+\>" | |
120 syn case ignore | |
121 "floating point number, with dot, optional exponent | |
122 syn match awkFloat display "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\>" | |
123 "floating point number, starting with a dot, optional exponent | |
124 syn match awkFloat display "\.\d\+\(e[-+]\=\d\+\)\=\>" | |
125 "floating point number, without dot, with exponent | |
126 syn match awkFloat display "\<\d\+e[-+]\=\d\+\>" | |
127 syn case match | |
128 | |
129 "syn match awkIdentifier "\<[a-zA-Z_][a-zA-Z0-9_]*\>" | |
130 | |
131 " Comparison expressions. | |
6530 | 132 syn match awkExpression "==\|>=\|=>\|<=\|=<\|\!=" |
133 syn match awkExpression "\~\|\!\~" | |
134 syn match awkExpression "?\|:" | |
135 syn keyword awkExpression in | |
7 | 136 |
137 " Boolean Logic (OR, AND, NOT) | |
9533
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
138 syn match awkBoolLogic "||\|&&\|\!" |
7 | 139 |
140 " This is overridden by less-than & greater-than. | |
141 " Put this above those to override them. | |
142 " Put this in a 'match "\<printf\=\>.*;\="' to make it not override | |
143 " less/greater than (most of the time), but it won't work yet because | |
3513 | 144 " keywords always have precedence over match & region. |
7 | 145 " File I/O: (print foo, bar > "filename") & for nawk (getline < "filename") |
146 "syn match awkFileIO contained ">" | |
147 "syn match awkFileIO contained "<" | |
148 | |
149 " Expression separators: ';' and ',' | |
150 syn match awkSemicolon ";" | |
151 syn match awkComma "," | |
152 | |
3513 | 153 syn match awkComment "#.*" contains=@Spell,awkTodo |
7 | 154 |
155 syn match awkLineSkip "\\$" | |
156 | |
157 " Highlight array element's (recursive arrays allowed). | |
158 " Keeps nested array names' separate from normal array elements. | |
159 " Keeps numbers separate from normal array elements (variables). | |
160 syn match awkArrayArray contained "[^][, \t]\+\["me=e-1 | |
161 syn match awkArrayElement contained "[^][, \t]\+" | |
162 syn region awkArray transparent start="\[" end="\]" contains=awkArray,awkArrayElement,awkArrayArray,awkNumber,awkFloat | |
163 | |
164 " 10 should be enough. | |
165 " (for the few instances where it would be more than "oneline") | |
166 syn sync ccomment awkArray maxlines=10 | |
167 | |
9533
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
168 " Define the default highlighting. |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
169 hi def link awkConditional Conditional |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
170 hi def link awkFunction Function |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
171 hi def link awkRepeat Repeat |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
172 hi def link awkStatement Statement |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
173 hi def link awkString String |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
174 hi def link awkSpecialPrintf Special |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
175 hi def link awkSpecialCharacter Special |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
176 hi def link awkSearch String |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
177 hi def link awkBrackets awkRegExp |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
178 hi def link awkBrktRegExp awkNestRegExp |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
179 hi def link awkCharClass awkNestRegExp |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
180 hi def link awkNestRegExp Keyword |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
181 hi def link awkRegExp Special |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
182 hi def link awkNumber Number |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
183 hi def link awkFloat Float |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
184 hi def link awkFileIO Special |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
185 hi def link awkOperator Special |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
186 hi def link awkExpression Special |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
187 hi def link awkBoolLogic Special |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
188 hi def link awkPatterns Special |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
189 hi def link awkVariables Special |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
190 hi def link awkFieldVars Special |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
191 hi def link awkLineSkip Special |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
192 hi def link awkSemicolon Special |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
193 hi def link awkComma Special |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
194 hi def link awkIdentifier Identifier |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
195 hi def link awkComment Comment |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
196 hi def link awkTodo Todo |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
197 " Change this if you want nested array names to be highlighted. |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
198 hi def link awkArrayArray awkArray |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
199 hi def link awkArrayElement Special |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
200 hi def link awkParenError awkError |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
201 hi def link awkInParen awkError |
9f921133ee90
commit https://github.com/vim/vim/commit/269f595f9eef584937e7eae70fde68cdd7da5bcf
Christian Brabandt <cb@256bit.org>
parents:
6530
diff
changeset
|
202 hi def link awkError Error |
7 | 203 |
204 let b:current_syntax = "awk" | |
205 | |
3312 | 206 let &cpo = s:cpo_save |
207 unlet s:cpo_save | |
208 | |
7 | 209 " vim: ts=8 |