1" Vim syntax file
2" Language:	HASTE - a language for VLSI IC programming
3" Maintainer:	M. Tranchero - maurizio.tranchero?gmail.com
4" Credits:	some parts have been taken from vhdl, verilog, and C syntax
5"		files
6" Version:	0.9
7" Last Change:	0.9 improvement of haste numbers detection
8" Change:	0.8 error matching for wrong hierarchical connections
9" Change:	0.7 added more rules to highlight pre-processor directives
10
11" HASTE
12if exists("b:current_syntax")
13    finish
14endif
15" quit when a syntax file was already loaded
16if exists("b:current_syntax")
17  finish
18endif
19
20" case is significant
21syn case match
22
23" HASTE keywords
24syn keyword hasteStatement act alias arb array begin bitvec
25syn keyword hasteStatement bitwidth boolvec broad case
26syn keyword hasteStatement cast chan const dataprobe do edge
27syn keyword hasteStatement else end export false ff fi file
28syn keyword hasteStatement fit for forever func if import
29syn keyword hasteStatement inprobe is les main narb narrow
30syn keyword hasteStatement negedge od of or outprobe pas
31syn keyword hasteStatement posedge probe proc ram ramreg
32syn keyword hasteStatement repeat rom romreg sample sel si
33syn keyword hasteStatement sign sizeof skip stop then true
34syn keyword hasteStatement type until var wait wire
35syn keyword hasteFutureExt Z ffe partial
36syn keyword hasteVerilog   buf reg while
37
38" Special match for "if", "or", and "else" since "else if"
39" and other "else+if" combination shouldn't be highlighted.
40" The right keyword is "or"
41syn match   hasteStatement	"\<\(if\|then\|else\|fi\)\>"
42syn match   hasteNone		"\<else\s\+if\>$"
43syn match   hasteNone		"\<else\s\+if\>\s"
44syn match   hasteNone		"\<elseif\>\s"
45syn match   hasteNone		"\<elsif\>\s"
46syn match   hasteStatement	"\<\(case\|is\|si\)\>"
47syn match   hasteStatement	"\<\(repeat\|until\)\>"
48syn match   hasteStatement	"\<\(forever\|do\|od\)\>"
49syn match   hasteStatement	"\<\(for\|do\|od\)\>"
50syn match   hasteStatement	"\<\(do\|or\|od\)\>"
51syn match   hasteStatement	"\<\(sel\|les\)\>"
52syn match   hasteError		"\<\d\+[_a-zA-Z]\+\>"
53syn match   hasteError		"\(\([[:alnum:]]\+\s*(\s\+\|)\s*,\)\)\s*\([[:alnum:]]\+\s*(\)"
54
55" Predifined Haste types
56syn keyword hasteType bool
57
58" Values for standard Haste types
59" syn match hasteVector "\'[0L1HXWZU\-\?]\'"
60
61syn match  hasteVector "0b\"[01_]\+\""
62syn match  hasteVector "0x\"[0-9a-f_]\+\""
63syn match  hasteCharacter "'.'"
64" syn region hasteString start=+"+  end=+"+
65syn match  hasteIncluded	display contained "<[^>]*>"
66syn match  hasteIncluded	display contained "<[^"]*>"
67syn region hasteInclude	start="^\s*#include\>\s*" end="$" contains=hasteIncluded,hasteString
68
69" integer numbers
70syn match hasteNumber "\d\+\^[[:alnum:]]*[-+]\{0,1\}[[:alnum:]]*"
71syn match hasteNumber "-\=\<\d\+\(\^[+\-]\=\d\+\)\>"
72syn match hasteNumber "-\=\<\d\+\>"
73" syn match hasteNumber "0*2#[01_]\+#\(\^[+\-]\=\d\+\)\="
74" syn match hasteNumber "0*16#[0-9a-f_]\+#\(\^[+\-]\=\d\+\)\="
75" operators
76syn keyword hasteSeparators	& , . \|
77syn keyword hasteExecution	\|\| ; @
78syn keyword hasteOperator	:= ? ! :
79syn keyword hasteTypeConstr	"[" << >> .. "]" ~
80syn keyword hasteExprOp		< <= >= > = # <> + - * == ##
81syn keyword hasteMisc		( ) 0x 0b
82"
83syn match   hasteSeparators	"[&:\|,.]"
84syn match   hasteOperator	":="
85syn match   hasteOperator	":"
86syn match   hasteOperator	"?"
87syn match   hasteOperator	"!"
88syn match   hasteExecution	"||"
89syn match   hasteExecution	";"
90syn match   hasteExecution	"@"
91syn match   hasteType		"\[\["
92syn match   hasteType		"\]\]"
93syn match   hasteType		"<<"
94syn match   hasteType		">>"
95syn match   hasteExprOp		"<"
96syn match   hasteExprOp		"<="
97syn match   hasteExprOp		">="
98syn match   hasteExprOp		">"
99syn match   hasteExprOp		"<>"
100syn match   hasteExprOp		"="
101syn match   hasteExprOp		"=="
102syn match   hasteExprOp		"##"
103" syn match   hasteExprOp		"#"
104syn match   hasteExprOp		"*"
105syn match   hasteExprOp		"+"
106
107syn region  hasteComment start="/\*" end="\*/" contains=@Spell
108syn region  hasteComment start="{" end="}" contains=@Spell
109syn match   hasteComment "//.*" contains=@Spell
110
111" Define the default highlighting.
112" Only when an item doesn't have highlighting yet
113hi def link hasteSpecial	Special
114hi def link hasteStatement	Statement
115hi def link hasteCharacter	String
116hi def link hasteString		String
117hi def link hasteVector		String
118hi def link hasteBoolean	String
119hi def link hasteComment	Comment
120hi def link hasteNumber		String
121hi def link hasteTime		String
122hi def link hasteType		Type
123hi def link hasteGlobal		Error
124hi def link hasteError		Error
125hi def link hasteAttribute	Type
126"
127hi def link hasteSeparators	Special
128hi def link hasteExecution	Special
129hi def link hasteTypeConstr	Special
130hi def link hasteOperator	Type
131hi def link hasteExprOp		Type
132hi def link hasteMisc		String
133hi def link hasteFutureExt 	Error
134hi def link hasteVerilog	Error
135hi def link hasteDefine		Macro
136hi def link hasteInclude	Include
137" hi def link hastePreProc	Preproc
138" hi def link hastePreProcVar	Special
139
140let b:current_syntax = "haste"
141
142" vim: ts=8
143