3 " Maintainer: Dave Eggum (opine at bluebottle dOt com)
4 " Last Change: 2005 Dec 19
6 " NOTE: extra white space at the end of the line will be highlighted if you
7 " add this line to your colorscheme:
9 " highlight SpaceError guibg=#204050
11 " (change the value for guibg to any color you like)
13 " For version 5.x: Clear all syntax items
14 " For version 6.x: Quit when a syntax file was already loaded
17 elseif exists("b:current_syntax")
21 " A bunch of useful Vera keywords
22 syn keyword veraStatement break return continue fork join terminate
23 syn keyword veraStatement breakpoint proceed
25 syn keyword veraLabel bad_state bad_trans bind constraint coverage_group
26 syn keyword veraLabel class CLOCK default function interface m_bad_state
27 syn keyword veraLabel m_bad_trans m_state m_trans program randseq state
28 syn keyword veraLabel task trans
30 syn keyword veraConditional if else case casex casez randcase
31 syn keyword veraRepeat repeat while for do foreach
32 syn keyword veraModifier after all any around assoc_size async
33 syn keyword veraModifier before big_endian bit_normal bit_reverse export
34 syn keyword veraModifier extends extern little_endian local hdl_node hdl_task
35 syn keyword veraModifier negedge none packed protected posedge public rules
36 syn keyword veraModifier shadow soft static super this typedef unpacked var
37 syn keyword veraModifier vca virtual virtuals wildcard with
39 syn keyword veraType reg string enum event bit
40 syn keyword veraType rand randc integer port prod
42 syn keyword veraDeprecated call_func call_task close_conn get_bind get_bind_id
43 syn keyword veraDeprecated get_conn_err mailbox_receive mailbox_send make_client
44 syn keyword veraDeprecated make_server simwave_plot up_connections
46 " predefined tasks and functions
47 syn keyword veraTask alloc assoc_index cast_assign cm_coverage
48 syn keyword veraTask cm_get_coverage cm_get_limit delay error error_mode
49 syn keyword veraTask exit fclose feof ferror fflush flag fopen fprintf
50 syn keyword veraTask freadb freadh freadstr get_cycle get_env get_memsize
51 syn keyword veraTask get_plus_arg getstate get_systime get_time get_time_unit
52 syn keyword veraTask initstate lock_file mailbox_get mailbox_put os_command
53 syn keyword veraTask printf prodget prodset psprintf query query_str query_x
54 syn keyword veraTask rand48 random region_enter region_exit rewind
55 syn keyword veraTask semaphore_get semaphore_put setstate signal_connect
56 syn keyword veraTask sprintf srandom sscanf stop suspend_thread sync
57 syn keyword veraTask timeout trace trigger unit_delay unlock_file urand48
58 syn keyword veraTask urandom urandom_range vera_bit_reverse vera_crc
59 syn keyword veraTask vera_pack vera_pack_big_endian vera_plot
60 syn keyword veraTask vera_report_profile vera_unpack vera_unpack_big_endian
61 syn keyword veraTask vsv_call_func vsv_call_task vsv_get_conn_err
62 syn keyword veraTask vsv_make_client vsv_make_server vsv_up_connections
63 syn keyword veraTask vsv_wait_for_done vsv_wait_for_input wait_child wait_var
65 syn cluster veraOperGroup contains=veraOperator,veraOperParen,veraNumber,veraString,veraOperOk,veraType
66 " syn match veraOperator "++\|--\|&\|\~&\||\|\~|\|^\|\~^\|\~\|><"
67 " syn match veraOperator "*\|/\|%\|+\|-\|<<\|>>\|<\|<=\|>\|>=\|!in"
68 " syn match veraOperator "=?=\|!?=\|==\|!=\|===\|!==\|&\~\|^\~\||\~"
69 " syn match veraOperator "&&\|||\|=\|+=\|-=\|*=\|/=\|%=\|<<=\|>>=\|&="
70 " syn match veraOperator "|=\|^=\|\~&=\|\~|=\|\~^="
72 syn match veraOperator "[&|\~><!*@+/=,.\^\-]"
73 syn keyword veraOperator or in dist not
75 " open vera class methods
76 syn keyword veraMethods atobin atohex atoi atooct backref bittostr capacity
77 syn keyword veraMethods compare Configure constraint_mode delete DisableTrigger
78 syn keyword veraMethods DoAction empty EnableCount EnableTrigger Event find
79 syn keyword veraMethods find_index first first_index GetAssert get_at_least
80 syn keyword veraMethods get_auto_bin getc GetCount get_coverage_goal get_cov_weight
81 syn keyword veraMethods get_cross_bin_max GetFirstAssert GetName GetNextAssert
82 syn keyword veraMethods get_status get_status_msg hide hash icompare insert
83 syn keyword veraMethods inst_get_at_least inst_get_auto_bin_max inst_get_collect
84 syn keyword veraMethods inst_get_coverage_goal inst_get_cov_weight inst_getcross_bin_max
85 syn keyword veraMethods inst_query inst_set_at_least inst_set_auto_bin_max
86 syn keyword veraMethods inst_set_bin_activiation inst_set_collect inst_set_coverage_goal
87 syn keyword veraMethods inst_set_cov_weight inst_set_cross_bin_max itoa last last_index
88 syn keyword veraMethods len load match max max_index min min_index new object_compare
89 syn keyword veraMethods object_compare object_copy object_print pack pick_index
90 syn keyword veraMethods pop_back pop_front post_boundary postmatch post_pack post_pack
91 syn keyword veraMethods post_randomize post_randomize post_unpack post_unpack
92 syn keyword veraMethods pre_boundary prematch pre_pack pre_pack pre_randomize
93 syn keyword veraMethods pre-randomize pre_unpack push_back push_front putc query
94 syn keyword veraMethods query_str rand_mode randomize reserve reverse rsort search
95 syn keyword veraMethods set_at_least set_auto_bin_max set_bin_activiation
96 syn keyword veraMethods set_coverage_goal set_cov_weight set_cross_bin_max set_name
97 syn keyword veraMethods size sort substr sum thismatch tolower toupper unique_index
98 syn keyword veraMethods unpack Wait
101 syn keyword veraInterface ASYNC CLOCK gnr gr0 gr1 grx grz NHOLD nr NR0 NR1
102 syn keyword veraInterface NRZ NRZ NSAMPLE PHOLD PR0 PR1 PRX PRZ r0 r1 rx snr
103 syn keyword veraInterface sr0 sr1 srx srz depth inout input output
104 syn match veraInterface "\$\w\+"
107 syn keyword veraTodo contained TODO FIXME XXX FINISH
109 " veraCommentGroup allows adding matches for special things in comments
110 syn cluster veraCommentGroup contains=veraTodo
112 " String and Character constants
113 " Highlight special characters (those which have a backslash) differently
114 syn match veraSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)"
115 syn match veraFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bdiuoxXDOUfeEgGcCsSpnm]\|\[\^\=.[^]]*\]\)" contained
116 syn match veraFormat display "%%" contained
117 syn region veraString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=veraSpecial,veraFormat,@Spell
118 syn region veraConcat contained transparent oneline start='{' end='}'
120 " veraCppString: same as veraString, but ends at end of line
121 syn region veraCppString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=veraSpecial,veraFormat,@Spell
123 syn match veraCharacter "'[^\\]'"
124 syn match veraCharacter "L'[^']*'" contains=veraSpecial
125 syn match veraSpecialError "'\\[^'\"?\\abefnrtv]'"
126 syn match veraSpecialCharacter "'\\['\"?\\abefnrtv]'"
127 syn match veraSpecialCharacter display "'\\\o\{1,3}'"
128 syn match veraSpecialCharacter display "'\\x\x\{1,2}'"
129 syn match veraSpecialCharacter display "L'\\x\x\+'"
131 " highlight trailing white space
132 syn match veraSpaceError display excludenl "\s\+$"
133 syn match veraSpaceError display " \+\t"me=e-1
135 "catch errors caused by wrong parenthesis and brackets
136 syn cluster veraParenGroup contains=veraParenError,veraIncluded,veraSpecial,veraCommentSkip,veraCommentString,veraComment2String,@veraCommentGroup,veraCommentStartError,veraUserCont,veraUserLabel,veraBitField,veraCommentSkip,veraOctalZero,veraCppOut,veraCppOut2,veraCppSkip,veraFormat,veraNumber,veraFloat,veraOctal,veraOctalError,veraNumbersCom
138 syn region veraParen transparent start='(' end=')' contains=ALLBUT,@veraParenGroup,veraCppParen,veraErrInBracket,veraCppBracket,veraCppString,@Spell
139 " veraCppParen: same as veraParen but ends at end-of-line; used in veraDefine
140 syn region veraCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@veraParenGroup,veraErrInBracket,veraParen,veraBracket,veraString,@Spell
141 syn match veraParenError display "[\])]"
142 " syn match veraErrInParen display contained "[\]{}]"
143 syn match veraErrInParen display contained "[\]]"
144 syn region veraBracket transparent start='\[' end=']' contains=ALLBUT,@veraParenGroup,veraErrInParen,veraCppParen,veraCppBracket,veraCppString,@Spell
146 " veraCppBracket: same as veraParen but ends at end-of-line; used in veraDefine
147 syn region veraCppBracket transparent start='\[' skip='\\$' excludenl end=']' end='$' contained contains=ALLBUT,@veraParenGroup,veraErrInParen,veraParen,veraBracket,veraString,@Spell
148 syn match veraErrInBracket display contained "[);{}]"
150 "integer number, or floating point number without a dot and with "f".
152 syn match veraNumbers display transparent "\<\d\|\.\d" contains=veraNumber,veraFloat,veraOctalError,veraOctal
153 " Same, but without octal error (for comments)
154 syn match veraNumbersCom display contained transparent "\<\d\|\.\d" contains=veraNumber,veraFloat,veraOctal
155 " syn match veraNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
157 " syn match veraNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
158 " syn match veraNumber "\(\<[0-9]\+\|\)'[bdoh][0-9a-fxzA-FXZ_]\+\>"
159 syn match veraNumber "\<\(\<[0-9]\+\)\?\('[bdoh]\)\?[0-9a-fxz_]\+\>"
160 " syn match veraNumber "\<[+-]\=[0-9]\+\>"
161 " Flag the first zero of an octal number as something special
162 syn match veraOctal display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=veraOctalZero
163 syn match veraOctalZero display contained "\<0"
164 syn match veraFloat display contained "\d\+f"
165 "floating point number, with dot, optional exponent
166 syn match veraFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
167 "floating point number, starting with a dot, optional exponent
168 syn match veraFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
169 "floating point number, without dot, with exponent
170 syn match veraFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>"
171 "hexadecimal floating point number, optional leading digits, with dot, with exponent
172 syn match veraFloat display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>"
173 "hexadecimal floating point number, with leading digits, optional dot, with exponent
174 syn match veraFloat display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>"
176 " flag an octal number with wrong digits
177 syn match veraOctalError display contained "0\o*[89]\d*"
180 let vera_comment_strings = 1
182 if exists("vera_comment_strings")
183 " A comment can contain veraString, veraCharacter and veraNumber.
184 " But a "*/" inside a veraString in a veraComment DOES end the comment! So we
185 " need to use a special type of veraString: veraCommentString, which also ends on
186 " "*/", and sees a "*" at the start of the line as comment again.
187 " Unfortunately this doesn't work very well for // type of comments :-(
188 syntax match veraCommentSkip contained "^\s*\*\($\|\s\+\)"
189 syntax region veraCommentString contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=veraSpecial,veraCommentSkip
190 syntax region veraComment2String contained start=+\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=veraSpecial
191 syntax region veraCommentL start="//" skip="\\$" end="$" keepend contains=@veraCommentGroup,veraComment2String,veraCharacter,veraNumbersCom,veraSpaceError,@Spell
192 if exists("vera_no_comment_fold")
193 syntax region veraComment matchgroup=veraCommentStart start="/\*" end="\*/" contains=@veraCommentGroup,veraCommentStartError,veraCommentString,veraCharacter,veraNumbersCom,veraSpaceError,@Spell
195 syntax region veraComment matchgroup=veraCommentStart start="/\*" end="\*/" contains=@veraCommentGroup,veraCommentStartError,veraCommentString,veraCharacter,veraNumbersCom,veraSpaceError,@Spell fold
198 syn region veraCommentL start="//" skip="\\$" end="$" keepend contains=@veraCommentGroup,veraSpaceError,@Spell
199 if exists("vera_no_comment_fold")
200 syn region veraComment matchgroup=veraCommentStart start="/\*" end="\*/" contains=@veraCommentGroup,veraCommentStartError,veraSpaceError,@Spell
202 syn region veraComment matchgroup=veraCommentStart start="/\*" end="\*/" contains=@veraCommentGroup,veraCommentStartError,veraSpaceError,@Spell fold
205 " keep a // comment separately, it terminates a preproc. conditional
206 syntax match veraCommentError display "\*/"
207 syntax match veraCommentStartError display "/\*"me=e-1 contained
209 syntax region veraBlock start="{" end="}" transparent fold
211 " open vera pre-defined constants
212 syn keyword veraConstant ALL ANY BAD_STATE BAD_TRANS CALL CHECK CHGEDGE
213 syn keyword veraConstant CLEAR COPY_NO_WAIT COPY_WAIT CROSS CROSS_TRANS
214 syn keyword veraConstant DEBUG DELETE EC_ARRAYX EC_CODE_END EC_CONFLICT
215 syn keyword veraConstant EC_EVNTIMOUT EC_EXPECT EC_FULLEXPECT EC_MBXTMOUT
216 syn keyword veraConstant EC_NEXPECT EC_RETURN EC_RGNTMOUT EC_SCONFLICT
217 syn keyword veraConstant EC_SEMTMOUT EC_SEXPECT EC_SFULLEXPECT EC_SNEXTPECT
218 syn keyword veraConstant EC_USERSET EQ EVENT FAIL FIRST FORK GE GOAL GT
219 syn keyword veraConstant HAND_SHAKE HI HIGH HNUM LE LIC_EXIT LIC_PRERR
220 syn keyword veraConstant LIC_PRWARN LIC_WAIT LO LOAD LOW LT MAILBOX MAX_COM
221 syn keyword veraConstant NAME NE NEGEDGE NEXT NO_OVERLAP NO_OVERLAP_STATE
222 syn keyword veraConstant NO_OVERLAP_TRANS NO_VARS NO_WAIT NUM NUM_BIN
223 syn keyword veraConstant NUM_DET null OFF OK OK_LAST ON ONE_BLAST ONE_SHOT ORDER
224 syn keyword veraConstant PAST_IT PERCENT POSEDGE PROGRAM RAWIN REGION REPORT
225 syn keyword veraConstant SAMPLE SAVE SEMAPHORE SET SILENT STATE stderr
226 syn keyword veraConstant stdin stdout STR STR_ERR_OUT_OF_RANGE
227 syn keyword veraConstant STR_ERR_REGEXP_SYNTAX SUM TRANS VERBOSE void WAIT
228 syn keyword veraConstant __LINE__ __FILE__ __DATE__ __TIME__ __VERA__
229 syn keyword veraConstant __VERSION__ __VERA_VERSION__ __VERA_MINOR__
230 syn keyword veraConstant __VERA_PATCH__ __VERA_VMC__ __VERA_VMC_MINOR__
232 syn match veraUserConstant "\<[A-Z][A-Z0-9_]\+\>"
234 syn match veraClass "\zs\w\+\ze::"
235 syn match veraClass "\zs\w\+\ze\s\+\w\+\s*[=;,)\[]" contains=veraConstant,veraUserConstant
236 syn match veraClass "\zs\w\+\ze\s\+\w\+\s*$" contains=veraConstant,veraUserConstant
237 syn match veraUserMethod "\zs\w\+\ze\s*(" contains=veraConstant,veraUserConstant
238 syn match veraObject "\zs\w\+\ze\.\w"
239 syn match veraObject "\zs\w\+\ze\.\$\w"
241 " Accept ` for # (Verilog)
242 syn region veraPreCondit start="^\s*\(`\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" end="//"me=s-1 contains=veraComment,veraCppString,veraCharacter,veraCppParen,veraParenError,veraNumbers,veraCommentError,veraSpaceError
243 syn match veraPreCondit display "^\s*\(`\|#\)\s*\(else\|endif\)\>"
244 if !exists("vera_no_if0")
245 syn region veraCppOut start="^\s*\(`\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=veraCppOut2
246 syn region veraCppOut2 contained start="0" end="^\s*\(`\|#\)\s*\(endif\>\|else\>\|elif\>\)" contains=veraSpaceError,veraCppSkip
247 syn region veraCppSkip contained start="^\s*\(`\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(`\|#\)\s*endif\>" contains=veraSpaceError,veraCppSkip
249 syn region veraIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
250 syn match veraIncluded display contained "<[^>]*>"
251 syn match veraInclude display "^\s*\(`\|#\)\s*include\>\s*["<]" contains=veraIncluded
252 "syn match veraLineSkip "\\$"
253 syn cluster veraPreProcGroup contains=veraPreCondit,veraIncluded,veraInclude,veraDefine,veraErrInParen,veraErrInBracket,veraUserLabel,veraSpecial,veraOctalZero,veraCppOut,veraCppOut2,veraCppSkip,veraFormat,veraNumber,veraFloat,veraOctal,veraOctalError,veraNumbersCom,veraString,veraCommentSkip,veraCommentString,veraComment2String,@veraCommentGroup,veraCommentStartError,veraParen,veraBracket,veraMulti
254 syn region veraDefine start="^\s*\(`\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" end="//"me=s-1 contains=ALLBUT,@veraPreProcGroup,@Spell
255 syn region veraPreProc start="^\s*\(`\|#\)\s*\(pragma\>\|line\>\|warning\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@veraPreProcGroup,@Spell
257 " Highlight User Labels
258 syn cluster veraMultiGroup contains=veraIncluded,veraSpecial,veraCommentSkip,veraCommentString,veraComment2String,@veraCommentGroup,veraCommentStartError,veraUserCont,veraUserLabel,veraBitField,veraOctalZero,veraCppOut,veraCppOut2,veraCppSkip,veraFormat,veraNumber,veraFloat,veraOctal,veraOctalError,veraNumbersCom,veraCppParen,veraCppBracket,veraCppString
259 syn region veraMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@veraMultiGroup,@Spell
260 " syn region veraMulti transparent start='?' skip='::' end=':' contains=ALL
261 " The above causes veraCppOut2 to catch on:
262 " i = (isTrue) ? 0 : 1;
263 " which ends up commenting the rest of the file
265 " Avoid matching foo::bar() by requiring that the next char is not ':'
266 syn cluster veraLabelGroup contains=veraUserLabel
267 syn match veraUserCont display "^\s*\I\i*\s*:$" contains=@veraLabelGroup
268 syn match veraUserCont display ";\s*\I\i*\s*:$" contains=@veraLabelGroup
269 syn match veraUserCont display "^\s*\I\i*\s*:[^:]"me=e-1 contains=@veraLabelGroup
270 syn match veraUserCont display ";\s*\I\i*\s*:[^:]"me=e-1 contains=@veraLabelGroup
272 syn match veraUserLabel display "\I\i*" contained
274 " Avoid recognizing most bitfields as labels
275 syn match veraBitField display "^\s*\I\i*\s*:\s*[1-9]"me=e-1
276 syn match veraBitField display ";\s*\I\i*\s*:\s*[1-9]"me=e-1
278 if exists("vera_minlines")
279 let b:vera_minlines = vera_minlines
281 if !exists("vera_no_if0")
282 let b:vera_minlines = 50 " #if 0 constructs can be long
284 let b:vera_minlines = 15 " mostly for () constructs
287 exec "syn sync ccomment veraComment minlines=" . b:vera_minlines
289 " Define the default highlighting.
290 " For version 5.7 and earlier: only when not done already
291 " For version 5.8 and later: only when an item doesn't have highlighting yet
292 if version >= 508 || !exists("did_vera_syn_inits")
294 let did_vera_syn_inits = 1
295 command -nargs=+ HiLink hi link <args>
297 command -nargs=+ HiLink hi def link <args>
300 HiLink veraClass Identifier
301 HiLink veraObject Identifier
302 HiLink veraUserMethod Function
303 HiLink veraTask Keyword
304 HiLink veraModifier Tag
305 HiLink veraDeprecated veraError
306 HiLink veraMethods Statement
307 " HiLink veraInterface Label
308 HiLink veraInterface Function
310 HiLink veraFormat veraSpecial
311 HiLink veraCppString veraString
312 HiLink veraCommentL veraComment
313 HiLink veraCommentStart veraComment
314 HiLink veraLabel Label
315 HiLink veraUserLabel Label
316 HiLink veraConditional Conditional
317 HiLink veraRepeat Repeat
318 HiLink veraCharacter Character
319 HiLink veraSpecialCharacter veraSpecial
320 HiLink veraNumber Number
321 HiLink veraOctal Number
322 HiLink veraOctalZero PreProc " link this to Error if you want
323 HiLink veraFloat Float
324 HiLink veraOctalError veraError
325 HiLink veraParenError veraError
326 HiLink veraErrInParen veraError
327 HiLink veraErrInBracket veraError
328 HiLink veraCommentError veraError
329 HiLink veraCommentStartError veraError
330 HiLink veraSpaceError SpaceError
331 HiLink veraSpecialError veraError
332 HiLink veraOperator Operator
333 HiLink veraStructure Structure
334 HiLink veraInclude Include
335 HiLink veraPreProc PreProc
336 HiLink veraDefine Macro
337 HiLink veraIncluded veraString
338 HiLink veraError Error
339 HiLink veraStatement Statement
340 HiLink veraPreCondit PreCondit
342 " HiLink veraConstant Constant
343 HiLink veraConstant Keyword
344 HiLink veraUserConstant Constant
345 HiLink veraCommentString veraString
346 HiLink veraComment2String veraString
347 HiLink veraCommentSkip veraComment
348 HiLink veraString String
349 HiLink veraComment Comment
350 HiLink veraSpecial SpecialChar
352 HiLink veraCppSkip veraCppOut
353 HiLink veraCppOut2 veraCppOut
354 HiLink veraCppOut Comment
359 let b:current_syntax = "vera"