codekingpro/portable-devtools
114k
1"----------------------------------------------------------------------------2" Description: Vim Ada syntax file3" Language: Ada (2005)4" $Id: ada.vim 887 2008-07-08 14:29:01Z krischik $5" Copyright: Copyright (C) 2006 Martin Krischik6" Maintainer: Martin Krischik7" David A. Wheeler <dwheeler@dwheeler.com>8" Simon Bradley <simon.bradley@pitechnology.com>9" Contributors: Preben Randhol.10" $Author: krischik $11" $Date: 2008-07-08 16:29:01 +0200 (Di, 08 Jul 2008) $12" Version: 4.613" $Revision: 887 $14" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/syntax/ada.vim $15" http://www.dwheeler.com/vim16" History: 24.05.2006 MK Unified Headers17" 26.05.2006 MK ' should not be in iskeyword.18" 16.07.2006 MK Ada-Mode as vim-ball19" 02.10.2006 MK Better folding.20" 15.10.2006 MK Bram's suggestion for runtime integration21" 05.11.2006 MK Spell check for comments and strings only22" 05.11.2006 MK Bram suggested to save on spaces23" Help Page: help ft-ada-syntax24"------------------------------------------------------------------------------25" The formal spec of Ada 2005 (ARM) is the "Ada 2005 Reference Manual".26" For more Ada 2005 info, see http://www.gnuada.org and http://www.adapower.com.27"28" This vim syntax file works on vim 7.0 only and makes use of most of Voim 7.0 29" advanced features.30"------------------------------------------------------------------------------31 32if exists("b:current_syntax") || version < 70033 finish34endif35let s:keepcpo= &cpo36set cpo&vim37 38let b:current_syntax = "ada"39 40" Section: Ada is entirely case-insensitive. {{{141"42syntax case ignore43 44" Section: Highlighting commands {{{145"46" There are 72 reserved words in total in Ada2005. Some keywords are47" used in more than one way. For example:48" 1. "end" is a general keyword, but "end if" ends a Conditional.49" 2. "then" is a conditional, but "and then" is an operator.50"51for b:Item in g:ada#Keywords52 " Standard Exceptions (including I/O).53 " We'll highlight the standard exceptions, similar to vim's Python mode.54 " It's possible to redefine the standard exceptions as something else,55 " but doing so is very bad practice, so simply highlighting them makes sense.56 if b:Item['kind'] == "x"57 execute "syntax keyword adaException " . b:Item['word']58 endif59 if b:Item['kind'] == "a"60 execute 'syntax match adaAttribute "\V' . b:Item['word'] . '"'61 endif62 " We don't normally highlight types in package Standard63 " (Integer, Character, Float, etc.). I don't think it looks good64 " with the other type keywords, and many Ada programs define65 " so many of their own types that it looks inconsistent.66 " However, if you want this highlighting, turn on "ada_standard_types".67 " For package Standard's definition, see ARM section A.1.68 if b:Item['kind'] == "t" && exists ("g:ada_standard_types")69 execute "syntax keyword adaBuiltinType " . b:Item['word']70 endif71endfor72 73" Section: others {{{174"75syntax keyword adaLabel others76 77" Section: Operatoren {{{178"79syntax keyword adaOperator abs mod not rem xor80syntax match adaOperator "\<and\>"81syntax match adaOperator "\<and\s\+then\>"82syntax match adaOperator "\<or\>"83syntax match adaOperator "\<or\s\+else\>"84syntax match adaOperator "[-+*/<>&]"85syntax keyword adaOperator **86syntax match adaOperator "[/<>]="87syntax keyword adaOperator =>88syntax match adaOperator "\.\."89syntax match adaOperator "="90 91" Section: <> {{{192"93" Handle the box, <>, specially:94"95syntax keyword adaSpecial <>96 97" Section: rainbow color {{{198"99if exists("g:ada_rainbow_color")100 syntax match adaSpecial "[:;.,]"101 call rainbow_parenthsis#LoadRound ()102 call rainbow_parenthsis#Activate ()103else104 syntax match adaSpecial "[:;().,]"105endif106 107" Section: := {{{1108"109" We won't map "adaAssignment" by default, but we need to map ":=" to110" something or the "=" inside it will be mislabelled as an operator.111" Note that in Ada, assignment (:=) is not considered an operator.112"113syntax match adaAssignment ":="114 115" Section: Numbers, including floating point, exponents, and alternate bases. {{{1116"117syntax match adaNumber "\<\d[0-9_]*\(\.\d[0-9_]*\)\=\([Ee][+-]\=\d[0-9_]*\)\=\>"118syntax match adaNumber "\<\d\d\=#\x[0-9A-Fa-f_]*\(\.\x[0-9A-Fa-f_]*\)\=#\([Ee][+-]\=\d[0-9_]*\)\="119 120" Section: Identify leading numeric signs {{{1121"122" In "A-5" the "-" is an operator, " but in "A:=-5" the "-" is a sign. This123" handles "A3+-5" (etc.) correctly. " This assumes that if you put a124" don't put a space after +/- when it's used " as an operator, you won't125" put a space before it either -- which is true " in code I've seen.126"127syntax match adaSign "[[:space:]<>=(,|:;&*/+-][+-]\d"lc=1,hs=s+1,he=e-1,me=e-1128 129" Section: Labels for the goto statement. {{{1130"131syntax region adaLabel start="<<" end=">>"132 133" Section: Boolean Constants {{{1134" Boolean Constants.135syntax keyword adaBoolean true false136 137" Section: Warn C/C++ {{{1138"139" Warn people who try to use C/C++ notation erroneously:140"141syntax match adaError "//"142syntax match adaError "/\*"143syntax match adaError "=="144 145 146" Section: Space Errors {{{1147"148if exists("g:ada_space_errors")149 if !exists("g:ada_no_trail_space_error")150 syntax match adaSpaceError excludenl "\s\+$"151 endif152 if !exists("g:ada_no_tab_space_error")153 syntax match adaSpaceError " \+\t"me=e-1154 endif155 if !exists("g:ada_all_tab_usage")156 syntax match adaSpecial "\t"157 endif158endif159 160" Section: end {{{1161" Unless special ("end loop", "end if", etc.), "end" marks the end of a162" begin, package, task etc. Assigning it to adaEnd.163syntax match adaEnd /\<end\>/164 165syntax keyword adaPreproc pragma166 167syntax keyword adaRepeat exit for loop reverse while168syntax match adaRepeat "\<end\s\+loop\>"169 170syntax keyword adaStatement accept delay goto raise requeue return171syntax keyword adaStatement terminate172syntax match adaStatement "\<abort\>"173 174" Section: Handle Ada's record keywords. {{{1175"176" 'record' usually starts a structure, but "with null record;" does not,177" and 'end record;' ends a structure. The ordering here is critical -178" 'record;' matches a "with null record", so make it a keyword (this can179" match when the 'with' or 'null' is on a previous line).180" We see the "end" in "end record" before the word record, so we match that181" pattern as adaStructure (and it won't match the "record;" pattern).182"183syntax match adaStructure "\<record\>" contains=adaRecord184syntax match adaStructure "\<end\s\+record\>" contains=adaRecord185syntax match adaKeyword "\<record;"me=e-1186 187" Section: type classes {{{1188"189syntax keyword adaStorageClass abstract access aliased array at constant delta190syntax keyword adaStorageClass digits limited of private range tagged191syntax keyword adaStorageClass interface synchronized192syntax keyword adaTypedef subtype type193 194" Section: Conditionals {{{1195"196" "abort" after "then" is a conditional of its own.197"198syntax match adaConditional "\<then\>"199syntax match adaConditional "\<then\s\+abort\>"200syntax match adaConditional "\<else\>"201syntax match adaConditional "\<end\s\+if\>"202syntax match adaConditional "\<end\s\+case\>"203syntax match adaConditional "\<end\s\+select\>"204syntax keyword adaConditional if case select205syntax keyword adaConditional elsif when206 207" Section: other keywords {{{1208syntax match adaKeyword "\<is\>" contains=adaRecord209syntax keyword adaKeyword all do exception in new null out210syntax keyword adaKeyword separate until overriding211 212" Section: begin keywords {{{1213"214" These keywords begin various constructs, and you _might_ want to215" highlight them differently.216"217syntax keyword adaBegin begin body declare entry generic218syntax keyword adaBegin protected renames task219 220syntax match adaBegin "\<function\>" contains=adaFunction221syntax match adaBegin "\<procedure\>" contains=adaProcedure222syntax match adaBegin "\<package\>" contains=adaPackage223 224if exists("ada_with_gnat_project_files")225 syntax keyword adaBegin project226endif227 228" Section: with, use {{{1229"230if exists("ada_withuse_ordinary")231 " Don't be fancy. Display "with" and "use" as ordinary keywords in all cases.232 syntax keyword adaKeyword with use233else234 " Highlight "with" and "use" clauses like C's "#include" when they're used235 " to reference other compilation units; otherwise they're ordinary keywords.236 " If we have vim 6.0 or later, we'll use its advanced pattern-matching237 " capabilities so that we won't match leading spaces.238 syntax match adaKeyword "\<with\>"239 syntax match adaKeyword "\<use\>"240 syntax match adaBeginWith "^\s*\zs\(\(with\(\s\+type\)\=\)\|\(use\)\)\>" contains=adaInc241 syntax match adaSemiWith ";\s*\zs\(\(with\(\s\+type\)\=\)\|\(use\)\)\>" contains=adaInc242 syntax match adaInc "\<with\>" contained contains=NONE243 syntax match adaInc "\<with\s\+type\>" contained contains=NONE244 syntax match adaInc "\<use\>" contained contains=NONE245 " Recognize "with null record" as a keyword (even the "record").246 syntax match adaKeyword "\<with\s\+null\s\+record\>"247 " Consider generic formal parameters of subprograms and packages as keywords.248 syntax match adaKeyword ";\s*\zswith\s\+\(function\|procedure\|package\)\>"249 syntax match adaKeyword "^\s*\zswith\s\+\(function\|procedure\|package\)\>"250endif251 252" Section: String and character constants. {{{1253"254syntax region adaString contains=@Spell start=+"+ skip=+""+ end=+"+ 255syntax match adaCharacter "'.'"256 257" Section: Todo (only highlighted in comments) {{{1258"259syntax keyword adaTodo contained TODO FIXME XXX NOTE260 261" Section: Comments. {{{1262"263syntax region adaComment 264 \ oneline 265 \ contains=adaTodo,adaLineError,@Spell266 \ start="--" 267 \ end="$"268 269" Section: line errors {{{1270"271" Note: Line errors have become quite slow with Vim 7.0272"273if exists("g:ada_line_errors")274 syntax match adaLineError "\(^.\{79}\)\@<=." contains=ALL containedin=ALL275endif276 277" Section: syntax folding {{{1278"279" Syntax folding is very tricky - for now I still suggest to use280" indent folding281"282if exists("g:ada_folding") && g:ada_folding[0] == 's'283 if stridx (g:ada_folding, 'p') >= 0284 syntax region adaPackage285 \ start="\(\<package\s\+body\>\|\<package\>\)\s*\z(\k*\)"286 \ end="end\s\+\z1\s*;"287 \ keepend extend transparent fold contains=ALL288 endif289 if stridx (g:ada_folding, 'f') >= 0290 syntax region adaProcedure291 \ start="\<procedure\>\s*\z(\k*\)"292 \ end="\<end\>\s\+\z1\s*;"293 \ keepend extend transparent fold contains=ALL294 syntax region adaFunction295 \ start="\<procedure\>\s*\z(\k*\)"296 \ end="end\s\+\z1\s*;"297 \ keepend extend transparent fold contains=ALL298 endif299 if stridx (g:ada_folding, 'f') >= 0300 syntax region adaRecord301 \ start="\<is\s\+record\>"302 \ end="\<end\s\+record\>"303 \ keepend extend transparent fold contains=ALL304 endif305endif306 307" Section: The default methods for highlighting. Can be overridden later. {{{1308"309highlight def link adaCharacter Character310highlight def link adaComment Comment311highlight def link adaConditional Conditional312highlight def link adaKeyword Keyword313highlight def link adaLabel Label314highlight def link adaNumber Number315highlight def link adaSign Number316highlight def link adaOperator Operator317highlight def link adaPreproc PreProc318highlight def link adaRepeat Repeat319highlight def link adaSpecial Special320highlight def link adaStatement Statement321highlight def link adaString String322highlight def link adaStructure Structure323highlight def link adaTodo Todo324highlight def link adaType Type325highlight def link adaTypedef Typedef326highlight def link adaStorageClass StorageClass327highlight def link adaBoolean Boolean328highlight def link adaException Exception329highlight def link adaAttribute Tag330highlight def link adaInc Include331highlight def link adaError Error332highlight def link adaSpaceError Error333highlight def link adaLineError Error334highlight def link adaBuiltinType Type335highlight def link adaAssignment Special336 337" Subsection: Begin, End {{{2338"339if exists ("ada_begin_preproc")340 " This is the old default display:341 highlight def link adaBegin PreProc342 highlight def link adaEnd PreProc343else344 " This is the new default display:345 highlight def link adaBegin Keyword346 highlight def link adaEnd Keyword347endif348 349 350 351" Section: sync {{{1352"353" We don't need to look backwards to highlight correctly;354" this speeds things up greatly.355syntax sync minlines=1 maxlines=1356 357let &cpo = s:keepcpo358unlet s:keepcpo359 360finish " 1}}}361 362"------------------------------------------------------------------------------363" Copyright (C) 2006 Martin Krischik364"365" Vim is Charityware - see ":help license" or uganda.txt for licence details.366"------------------------------------------------------------------------------367"vim: textwidth=78 nowrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab368"vim: foldmethod=marker369 