summaryrefslogtreecommitdiff
path: root/runtime/syntax/haste.vim
blob: cf943f10856ea18149fe0bd4ae6da957dc8a3be2 (plain)
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:	HASTE
" Maintainer:	M. Tranchero - maurizio.tranchero?gmail.com
" Credits:	some parts have been taken from vhdl, verilog, and C syntax
"		files
" version: 0.5

" HASTE
if exists("b:current_syntax")
    finish
endif
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

" case is significant
syn case match

" HASTE keywords
syn keyword hasteStatement act alias arb array begin bitvec 
syn keyword hasteStatement bitwidth boolvec broad case
syn keyword hasteStatement cast chan const dataprobe do edge
syn keyword hasteStatement else end export false ff fi file
syn keyword hasteStatement fit for forever func if import
syn keyword hasteStatement inprobe is les main narb narrow
syn keyword hasteStatement negedge od of or outprobe pas
syn keyword hasteStatement posedge probe proc ram ramreg
syn keyword hasteStatement repeat rom romreg sample sel si
syn keyword hasteStatement sign sizeof skip stop then true
syn keyword hasteStatement type until var wait wire
syn keyword hasteFutureExt Z ffe partial 
syn keyword hasteVerilog   buf reg while 

" Special match for "if", "or", and "else" since "else if"
" and other "else+if" combination shouldn't be highlighted.
" The right keyword is "or" 
syn match   hasteStatement	"\<\(if\|then\|else\|fi\)\>"
syn match   hasteNone		"\<else\s\+if\>$"
syn match   hasteNone		"\<else\s\+if\>\s"
syn match   hasteNone		"\<elseif\>\s"
syn match   hasteNone		"\<elsif\>\s"
syn match   hasteStatement	"\<\(case\|is\|si\)\>"
syn match   hasteStatement	"\<\(repeat\|until\)\>"
syn match   hasteStatement	"\<\(forever\|do\|od\)\>"
syn match   hasteStatement	"\<\(for\|do\|od\)\>"
syn match   hasteStatement	"\<\(do\|or\|od\)\>"
syn match   hasteStatement	"\<\(sel\|les\)\>"
syn match   hasteError		"\<\d\+[_a-zA-Z]\+\>"

" Predifined Haste types
syn keyword hasteType bool

" Values for standard Haste types
" syn match hasteVector "\'[0L1HXWZU\-\?]\'"

syn match  hasteVector "0b\"[01_]\+\""
syn match  hasteVector "0x\"[0-9a-f_]\+\""
syn match  hasteCharacter "'.'"
syn region hasteString start=+"+  end=+"+
" C pre-processor directives
"syn region hasteIncluded	display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
syn match  hasteIncluded	display contained "<[^>]*>"
syn match  hasteIncluded	display contained "<[^"]*>"
syn match  hasteInclude		display "^\s*#include\>\s*["<]" contains=hasteIncluded
syn region hasteDefine	start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" end="//"me=s-1 contains=ALLBUT,@hastePreProcGroup,@Spell
syn region hasteDefine	start="^\s*\(%:\|#\)\s*\(ifndef\|ifdef\|endif\)\>" skip="\\$" end="$" end="//"me=s-1 contains=@Spell
syn region hastePreCondit	start="^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" end="//"me=s-1 contains=hasteComment,hasteCppString,hasteCharacter,hasteCppParen,hasteParenError,hasteNumbers,hasteCommentError,hasteSpaceError
syn region hastePreProc	start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@hastePreProcGroup,@Spell
syn cluster hastePreProcGroup	contains=hasteIncluded,hasteInclude,hasteDefine
syn region hasteCppSkip	contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=hasteSpaceError,hasteCppSkip

" floating numbers
syn match hasteNumber "-\=\<\d\+\.\d\+\(E[+\-]\=\d\+\)\>"
syn match hasteNumber "-\=\<\d\+\.\d\+\>"
syn match hasteNumber "0*2#[01_]\+\.[01_]\+#\(E[+\-]\=\d\+\)\="
syn match hasteNumber "0*16#[0-9a-f_]\+\.[0-9a-f_]\+#\(E[+\-]\=\d\+\)\="
" integer numbers
syn match hasteNumber "-\=\<\d\+\(E[+\-]\=\d\+\)\>"
syn match hasteNumber "-\=\<\d\+\>"
syn match hasteNumber "0*2#[01_]\+#\(E[+\-]\=\d\+\)\="
syn match hasteNumber "0*16#[0-9a-f_]\+#\(E[+\-]\=\d\+\)\="
" operators
syn keyword hasteSeparators	& , . \| : 
syn keyword hasteExecution	\|\| ; @
syn keyword hasteOperator	:= ? !
syn keyword hasteTypeConstr	"[" << >> .. "]" ~
syn keyword hasteExprOp		< <= >= > = # <> + - * == ##
syn keyword hasteMisc		( ) 0x 0b
"
syn match   hasteSeparators	"[&:\|,.]"
syn match   hasteOperator	":="
syn match   hasteOperator	"?"
syn match   hasteOperator	"!"
syn match   hasteExecution	"||"
syn match   hasteExecution	";"
syn match   hasteExecution	"@"
syn match   hasteType		"\[\["
syn match   hasteType		"\]\]"
syn match   hasteType		"<<"
syn match   hasteType		">>"
syn match   hasteExprOp		"<"
syn match   hasteExprOp		"<="
syn match   hasteExprOp		">="
syn match   hasteExprOp		">"
syn match   hasteExprOp		"<>"
syn match   hasteExprOp		"="
syn match   hasteExprOp		"=="
syn match   hasteExprOp		"##"
syn match   hasteExprOp		"#"
syn match   hasteExprOp		"*"
syn match   hasteExprOp		"+"

syn region  hasteComment start="/\*" end="\*/" contains=@Spell
syn region  hasteComment start="{" end="}" contains=@Spell
syn match   hasteComment "//.*" contains=@Spell

" Define the default highlighting.
" Only when an item doesn't have highlighting yet
hi def link hasteSpecial	Special
hi def link hasteStatement	Statement
hi def link hasteCharacter	String
hi def link hasteString		String
hi def link hasteVector		String
hi def link hasteBoolean	String
hi def link hasteComment	Comment
hi def link hasteNumber		String
hi def link hasteTime		String
hi def link hasteType		Type
hi def link hasteGlobal		Error
hi def link hasteError		Error
hi def link hasteAttribute	Type
hi def link hasteSeparators	Special
hi def link hasteExecution	Special
hi def link hasteTypeConstr	Special
hi def link hasteOperator	Type
hi def link hasteExprOp		Type
hi def link hasteMisc		String
hi def link hasteFutureExt 	Error
hi def link hasteVerilog	Error
hi def link hasteDefine		Macro
hi def link hasteInclude	Include
hi def link hastePreProc	PreProc

let b:current_syntax = "haste"

" vim: ts=8