3 " Maintainer: David A. Wheeler <dwheeler@dwheeler.com>
4 " URL: http://www.dwheeler.com/vim
5 " Last Change: 2001 May 10
7 " Former Maintainer: Simon Bradley <simon.bradley@pitechnology.com>
8 " (was <sib93@aber.ac.uk>)
9 " The formal spec of Ada95 (ARM) is the "Ada95 Reference Manual";
10 " a copy is available at "http://www.adahome.com/rm95/". For more Ada95 info,
11 " see http://www.gnuada.org and http://www.adapower.com.
13 " This vim syntax file works on vim 5.6, 5.7, 5.8 and 6.x.
14 " It implements Bram Moolenaar's April 25, 2001 recommendations to make
15 " the syntax file maximally portable across different versions of vim.
16 " If vim 6.0+ is available,
17 " this syntax file takes advantage of the vim 6.0 advanced pattern-matching
18 " functions to avoid highlighting uninteresting leading spaces in
19 " some expressions containing "with" and "use".
21 " For version 5.x: Clear all syntax items
22 " For version 6.x: Quit when a syntax file was already loaded
25 elseif exists("b:current_syntax")
29 " Ada is entirely case-insensitive.
32 " We don't need to look backwards to highlight correctly;
33 " this speeds things up greatly.
34 syn sync minlines=1 maxlines=1
36 " Highlighting commands. There are 69 reserved words in total in Ada95.
37 " Some keywords are used in more than one way. For example:
38 " 1. "end" is a general keyword, but "end if" ends a Conditional.
39 " 2. "then" is a conditional, but "and then" is an operator.
42 " Standard Exceptions (including I/O).
43 " We'll highlight the standard exceptions, similar to vim's Python mode.
44 " It's possible to redefine the standard exceptions as something else,
45 " but doing so is very bad practice, so simply highlighting them makes sense.
46 syn keyword adaException Constraint_Error Program_Error Storage_Error
47 syn keyword adaException Tasking_Error
48 syn keyword adaException Status_Error Mode_Error Name_Error Use_Error
49 syn keyword adaException Device_Error End_Error Data_Error Layout_Error
50 syn keyword adaException Length_Error Pattern_Error Index_Error
51 syn keyword adaException Translation_Error
52 syn keyword adaException Time_Error Argument_Error
53 syn keyword adaException Tag_Error
54 syn keyword adaException Picture_Error
56 syn keyword adaException Terminator_Error Conversion_Error
57 syn keyword adaException Pointer_Error Dereference_Error Update_Error
58 " This isn't in the Ada spec, but a GNAT extension.
59 syn keyword adaException Assert_Failure
60 " We don't list ALL exceptions defined in particular compilers (e.g., GNAT),
61 " because it's quite reasonable to define those phrases as non-exceptions.
64 " We don't normally highlight types in package Standard
65 " (Integer, Character, Float, etc.). I don't think it looks good
66 " with the other type keywords, and many Ada programs define
67 " so many of their own types that it looks inconsistent.
68 " However, if you want this highlighting, turn on "ada_standard_types".
69 " For package Standard's definition, see ARM section A.1.
71 if exists("ada_standard_types")
72 syn keyword adaBuiltinType Boolean Integer Natural Positive Float
73 syn keyword adaBuiltinType Character Wide_Character
74 syn keyword adaBuiltinType String Wide_String
75 syn keyword adaBuiltinType Duration
76 " These aren't listed in ARM section A.1's code, but they're noted as
77 " options in ARM sections 3.5.4 and 3.5.7:
78 syn keyword adaBuiltinType Short_Integer Short_Short_Integer
79 syn keyword adaBuiltinType Long_Integer Long_Long_Integer
80 syn keyword adaBuiltinType Short_Float Short_Short_Float
81 syn keyword adaBuiltinType Long_Float Long_Long_Float
84 " There are MANY other predefined types; they've not been added, because
85 " determining when they're a type requires context in general.
86 " One potential addition would be Unbounded_String.
89 syn keyword adaLabel others
91 syn keyword adaOperator abs mod not rem xor
92 syn match adaOperator "\<and\>"
93 syn match adaOperator "\<and\s\+then\>"
94 syn match adaOperator "\<or\>"
95 syn match adaOperator "\<or\s\+else\>"
96 syn match adaOperator "[-+*/<>&]"
97 syn keyword adaOperator **
98 syn match adaOperator "[/<>]="
99 syn keyword adaOperator =>
100 syn match adaOperator "\.\."
101 syn match adaOperator "="
103 " We won't map "adaAssignment" by default, but we need to map ":=" to
104 " something or the "=" inside it will be mislabelled as an operator.
105 " Note that in Ada, assignment (:=) is not considered an operator.
106 syn match adaAssignment ":="
108 " Handle the box, <>, specially:
109 syn keyword adaSpecial <>
111 " Numbers, including floating point, exponents, and alternate bases.
112 syn match adaNumber "\<\d[0-9_]*\(\.\d[0-9_]*\)\=\([Ee][+-]\=\d[0-9_]*\)\=\>"
113 syn match adaNumber "\<\d\d\=#\x[0-9A-Fa-f_]*\(\.\x[0-9A-Fa-f_]*\)\=#\([Ee][+-]\=\d[0-9_]*\)\="
115 " Identify leading numeric signs. In "A-5" the "-" is an operator,
116 " but in "A:=-5" the "-" is a sign. This handles "A3+-5" (etc.) correctly.
117 " This assumes that if you put a don't put a space after +/- when it's used
118 " as an operator, you won't put a space before it either -- which is true
120 syn match adaSign "[[:space:]<>=(,|:;&*/+-][+-]\d"lc=1,hs=s+1,he=e-1,me=e-1
122 " Labels for the goto statement.
123 syn region adaLabel start="<<" end=">>"
126 syn keyword adaBoolean true false
128 " Warn people who try to use C/C++ notation erroneously:
129 syn match adaError "//"
130 syn match adaError "/\*"
131 syn match adaError "=="
134 if exists("ada_space_errors")
135 if !exists("ada_no_trail_space_error")
136 syn match adaSpaceError excludenl "\s\+$"
138 if !exists("ada_no_tab_space_error")
139 syn match adaSpaceError " \+\t"me=e-1
143 " Unless special ("end loop", "end if", etc.), "end" is an ordinary keyword.
144 syn match adaKeyword "\<end\>"
146 syn keyword adaPreproc pragma
148 syn keyword adaRepeat exit for loop reverse while
149 syn match adaRepeat "\<end\s\+loop\>"
151 syn keyword adaStatement accept delay goto raise requeue return
152 syn keyword adaStatement terminate
153 syn match adaStatement "\<abort\>"
155 " 'record' usually starts a structure, but "with null record;" does not.
156 syn match adaStructure "\<record\>"
157 syn match adaKeyword "\<record;"me=e-1
159 syn keyword adaStorageClass abstract access aliased array at constant delta
160 syn keyword adaStorageClass digits limited of private range tagged
161 syn keyword adaTypedef subtype type
163 " Conditionals. "abort" after "then" is a conditional of its own.
164 syn match adaConditional "\<then\>"
165 syn match adaConditional "\<then\s\+abort\>"
166 syn match adaConditional "\<else\>"
167 syn match adaConditional "\<end\s\+if\>"
168 syn match adaConditional "\<end\s\+case\>"
169 syn match adaConditional "\<end\s\+select\>"
170 syn keyword adaConditional if case select
171 syn keyword adaConditional elsif when
173 syn keyword adaKeyword all do exception in is new null out
174 syn keyword adaKeyword separate until
176 " These keywords begin various constructs, and you _might_ want to
177 " highlight them differently.
178 syn keyword adaBegin begin body declare entry function generic
179 syn keyword adaBegin package procedure protected renames task
182 if exists("ada_withuse_ordinary")
183 " Don't be fancy. Display "with" and "use" as ordinary keywords in all cases.
184 syn keyword adaKeyword with use
186 " Highlight "with" and "use" clauses like C's "#include" when they're used
187 " to reference other compilation units; otherwise they're ordinary keywords.
188 " If we have vim 6.0 or later, we'll use its advanced pattern-matching
189 " capabilities so that we won't match leading spaces.
190 syn match adaKeyword "\<with\>"
191 syn match adaKeyword "\<use\>"
193 syn match adaBeginWith "^\s*\(\(with\(\s\+type\)\=\)\|\(use\)\)\>" contains=adaInc
194 syn match adaSemiWith ";\s*\(\(with\(\s\+type\)\=\)\|\(use\)\)\>"lc=1 contains=adaInc
196 syn match adaBeginWith "^\s*\zs\(\(with\(\s\+type\)\=\)\|\(use\)\)\>" contains=adaInc
197 syn match adaSemiWith ";\s*\zs\(\(with\(\s\+type\)\=\)\|\(use\)\)\>" contains=adaInc
199 syn match adaInc "\<with\>" contained contains=NONE
200 syn match adaInc "\<with\s\+type\>" contained contains=NONE
201 syn match adaInc "\<use\>" contained contains=NONE
202 " Recognize "with null record" as a keyword (even the "record").
203 syn match adaKeyword "\<with\s\+null\s\+record\>"
204 " Consider generic formal parameters of subprograms and packages as keywords.
206 syn match adaKeyword ";\s*with\s\+\(function\|procedure\|package\)\>"
207 syn match adaKeyword "^\s*with\s\+\(function\|procedure\|package\)\>"
209 syn match adaKeyword ";\s*\zswith\s\+\(function\|procedure\|package\)\>"
210 syn match adaKeyword "^\s*\zswith\s\+\(function\|procedure\|package\)\>"
215 " String and character constants.
216 syn region adaString start=+"+ skip=+""+ end=+"+
217 syn match adaCharacter "'.'"
219 " Todo (only highlighted in comments)
220 syn keyword adaTodo contained TODO FIXME XXX
223 syn region adaComment oneline contains=adaTodo start="--" end="$"
227 " Define the default highlighting.
228 " For version 5.7 and earlier: only when not done already
229 " For version 5.8 and later: only when an item doesn't have highlighting yet
230 if version >= 508 || !exists("did_ada_syn_inits")
232 let did_ada_syn_inits = 1
233 command -nargs=+ HiLink hi link <args>
235 command -nargs=+ HiLink hi def link <args>
238 " The default methods for highlighting. Can be overridden later.
239 HiLink adaCharacter Character
240 HiLink adaComment Comment
241 HiLink adaConditional Conditional
242 HiLink adaKeyword Keyword
243 HiLink adaLabel Label
244 HiLink adaNumber Number
245 HiLink adaSign Number
246 HiLink adaOperator Operator
247 HiLink adaPreproc PreProc
248 HiLink adaRepeat Repeat
249 HiLink adaSpecial Special
250 HiLink adaStatement Statement
251 HiLink adaString String
252 HiLink adaStructure Structure
255 HiLink adaTypedef Typedef
256 HiLink adaStorageClass StorageClass
257 HiLink adaBoolean Boolean
258 HiLink adaException Exception
259 HiLink adaInc Include
260 HiLink adaError Error
261 HiLink adaSpaceError Error
262 HiLink adaBuiltinType Type
263 if exists("ada_begin_preproc")
264 HiLink adaBegin PreProc
266 HiLink adaBegin Keyword
272 let b:current_syntax = "ada"