home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / unix / vim-6.2.tar.bz2 / vim-6.2.tar / vim62 / runtime / syntax / ada.vim < prev    next >
Encoding:
Text File  |  2002-02-24  |  10.5 KB  |  288 lines

  1. " Vim syntax file
  2. " Language:    Ada (95)
  3. " Maintainer:    David A. Wheeler <dwheeler@dwheeler.com>
  4. " URL: http://www.dwheeler.com/vim
  5. " Last Change:    2001-11-02
  6.  
  7. " Former Maintainer:    Simon Bradley <simon.bradley@pitechnology.com>
  8. "            (was <sib93@aber.ac.uk>)
  9. " Other contributors: Preben Randhol.
  10. " The formal spec of Ada95 (ARM) is the "Ada95 Reference Manual".
  11. " For more Ada95 info, see http://www.gnuada.org and http://www.adapower.com.
  12.  
  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".
  20.  
  21. " For version 5.x: Clear all syntax items
  22. " For version 6.x: Quit when a syntax file was already loaded
  23. if version < 600
  24.  syntax clear
  25. elseif exists("b:current_syntax")
  26.  finish
  27. endif
  28.  
  29. " Ada is entirely case-insensitive.
  30. syn case ignore
  31.  
  32. " We don't need to look backwards to highlight correctly;
  33. " this speeds things up greatly.
  34. syn sync minlines=1 maxlines=1
  35.  
  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.
  40.  
  41.  
  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
  55. " Interfaces
  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.
  62.  
  63.  
  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.
  70.  
  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
  82. endif
  83.  
  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.
  87.  
  88.  
  89. syn keyword adaLabel        others
  90.  
  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        "="
  102.  
  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        ":="
  107.  
  108. " Handle the box, <>, specially:
  109. syn keyword adaSpecial    <>
  110.  
  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_]*\)\="
  114.  
  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
  119. " in code I've seen.
  120. syn match adaSign "[[:space:]<>=(,|:;&*/+-][+-]\d"lc=1,hs=s+1,he=e-1,me=e-1
  121.  
  122. " Labels for the goto statement.
  123. syn region  adaLabel        start="<<"  end=">>"
  124.  
  125. " Boolean Constants.
  126. syn keyword adaBoolean    true false
  127.  
  128. " Warn people who try to use C/C++ notation erroneously:
  129. syn match adaError "//"
  130. syn match adaError "/\*"
  131. syn match adaError "=="
  132.  
  133.  
  134. if exists("ada_space_errors")
  135.   if !exists("ada_no_trail_space_error")
  136.     syn match   adaSpaceError     excludenl "\s\+$"
  137.   endif
  138.   if !exists("ada_no_tab_space_error")
  139.     syn match   adaSpaceError     " \+\t"me=e-1
  140.   endif
  141. endif
  142.  
  143. " Unless special ("end loop", "end if", etc.), "end" marks the end of a
  144. " begin, package, task etc. Assiging it to adaEnd.
  145. syn match adaEnd        "\<end\>"
  146.  
  147. syn keyword adaPreproc        pragma
  148.  
  149. syn keyword adaRepeat        exit for loop reverse while
  150. syn match adaRepeat        "\<end\s\+loop\>"
  151.  
  152. syn keyword adaStatement    accept delay goto raise requeue return
  153. syn keyword adaStatement    terminate
  154. syn match adaStatement    "\<abort\>"
  155.  
  156. " Handle Ada's record keywords.
  157. " 'record' usually starts a structure, but "with null record;" does not,
  158. " and 'end record;' ends a structure.  The ordering here is critical -
  159. " 'record;' matches a "with null record", so make it a keyword (this can
  160. " match when the 'with' or 'null' is on a previous line).
  161. " We see the "end" in "end record" before the word record, so we match that
  162. " pattern as adaStructure (and it won't match the "record;" pattern).
  163. syn match adaStructure    "\<record\>"
  164. syn match adaStructure    "\<end\s\+record\>"
  165. syn match adaKeyword    "\<record;"me=e-1
  166.  
  167. syn keyword adaStorageClass    abstract access aliased array at constant delta
  168. syn keyword adaStorageClass    digits limited of private range tagged
  169. syn keyword adaTypedef        subtype type
  170.  
  171. " Conditionals. "abort" after "then" is a conditional of its own.
  172. syn match adaConditional    "\<then\>"
  173. syn match adaConditional    "\<then\s\+abort\>"
  174. syn match adaConditional    "\<else\>"
  175. syn match adaConditional    "\<end\s\+if\>"
  176. syn match adaConditional    "\<end\s\+case\>"
  177. syn match adaConditional    "\<end\s\+select\>"
  178. syn keyword adaConditional    if case select
  179. syn keyword adaConditional    elsif when
  180.  
  181. syn keyword adaKeyword        all do exception in is new null out
  182. syn keyword adaKeyword        separate until
  183.  
  184. " These keywords begin various constructs, and you _might_ want to
  185. " highlight them differently.
  186. syn keyword adaBegin        begin body declare entry function generic
  187. syn keyword adaBegin        package procedure protected renames task
  188.  
  189.  
  190. if exists("ada_withuse_ordinary")
  191. " Don't be fancy. Display "with" and "use" as ordinary keywords in all cases.
  192.  syn keyword adaKeyword        with use
  193. else
  194.  " Highlight "with" and "use" clauses like C's "#include" when they're used
  195.  " to reference other compilation units; otherwise they're ordinary keywords.
  196.  " If we have vim 6.0 or later, we'll use its advanced pattern-matching
  197.  " capabilities so that we won't match leading spaces.
  198.  syn match adaKeyword    "\<with\>"
  199.  syn match adaKeyword    "\<use\>"
  200.  if version < 600
  201.   syn match adaBeginWith "^\s*\(\(with\(\s\+type\)\=\)\|\(use\)\)\>" contains=adaInc
  202.   syn match adaSemiWith    ";\s*\(\(with\(\s\+type\)\=\)\|\(use\)\)\>"lc=1 contains=adaInc
  203.  else
  204.   syn match adaBeginWith "^\s*\zs\(\(with\(\s\+type\)\=\)\|\(use\)\)\>" contains=adaInc
  205.   syn match adaSemiWith    ";\s*\zs\(\(with\(\s\+type\)\=\)\|\(use\)\)\>" contains=adaInc
  206.  endif
  207.  syn match adaInc    "\<with\>" contained contains=NONE
  208.  syn match adaInc    "\<with\s\+type\>" contained contains=NONE
  209.  syn match adaInc    "\<use\>" contained contains=NONE
  210.  " Recognize "with null record" as a keyword (even the "record").
  211.  syn match adaKeyword    "\<with\s\+null\s\+record\>"
  212.  " Consider generic formal parameters of subprograms and packages as keywords.
  213.  if version < 600
  214.   syn match adaKeyword    ";\s*with\s\+\(function\|procedure\|package\)\>"
  215.   syn match adaKeyword    "^\s*with\s\+\(function\|procedure\|package\)\>"
  216.  else
  217.   syn match adaKeyword    ";\s*\zswith\s\+\(function\|procedure\|package\)\>"
  218.   syn match adaKeyword    "^\s*\zswith\s\+\(function\|procedure\|package\)\>"
  219.  endif
  220. endif
  221.  
  222.  
  223. " String and character constants.
  224. syn region  adaString        start=+"+  skip=+""+  end=+"+
  225. syn match   adaCharacter    "'.'"
  226.  
  227. " Todo (only highlighted in comments)
  228. syn keyword adaTodo contained    TODO FIXME XXX
  229.  
  230. " Comments.
  231. syn region  adaComment    oneline contains=adaTodo start="--"  end="$"
  232.  
  233.  
  234.  
  235. " Define the default highlighting.
  236. " For version 5.7 and earlier: only when not done already
  237. " For version 5.8 and later: only when an item doesn't have highlighting yet
  238. if version >= 508 || !exists("did_ada_syn_inits")
  239.   if version < 508
  240.     let did_ada_syn_inits = 1
  241.     command -nargs=+ HiLink hi link <args>
  242.   else
  243.     command -nargs=+ HiLink hi def link <args>
  244.   endif
  245.  
  246.   " The default methods for highlighting. Can be overridden later.
  247.   HiLink adaCharacter    Character
  248.   HiLink adaComment    Comment
  249.   HiLink adaConditional    Conditional
  250.   HiLink adaKeyword    Keyword
  251.   HiLink adaLabel    Label
  252.   HiLink adaNumber    Number
  253.   HiLink adaSign    Number
  254.   HiLink adaOperator    Operator
  255.   HiLink adaPreproc    PreProc
  256.   HiLink adaRepeat    Repeat
  257.   HiLink adaSpecial    Special
  258.   HiLink adaStatement    Statement
  259.   HiLink adaString    String
  260.   HiLink adaStructure    Structure
  261.   HiLink adaTodo    Todo
  262.   HiLink adaType    Type
  263.   HiLink adaTypedef    Typedef
  264.   HiLink adaStorageClass    StorageClass
  265.   HiLink adaBoolean    Boolean
  266.   HiLink adaException    Exception
  267.   HiLink adaInc    Include
  268.   HiLink adaError    Error
  269.   HiLink adaSpaceError    Error
  270.   HiLink adaBuiltinType Type
  271.  
  272.   if exists("ada_begin_preproc")
  273.    " This is the old default display:
  274.    HiLink adaBegin    PreProc
  275.    HiLink adaEnd    PreProc
  276.   else
  277.    " This is the new default display:
  278.    HiLink adaBegin    Keyword
  279.    HiLink adaEnd    Keyword
  280.   endif
  281.  
  282.   delcommand HiLink
  283. endif
  284.  
  285. let b:current_syntax = "ada"
  286.  
  287. " vim: ts=8
  288.