Guest User

std_c.vim

a guest
Nov 17th, 2011
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 56.06 KB | None | 0 0
  1. " Vim syntax file
  2. " Language:     Standard C (C89, C94, and C99)
  3. " Maintainer:   Mike Williams <[email protected]>
  4. " Filenames:    *.c,*.h
  5. " Last Change:  24th June 2006
  6. " URL:          http://www.eandem.co.uk/~mrw/vim/syntax
  7. "
  8. " Notes:
  9. " See supplied help file on configuring and using this syntax highlight file.
  10. "
  11. " THIS FILE CANNOT BE INCLUDED BY OTHER SYNTAX FILES SUPPLIED WITH VIM!
  12. "
  13. " History:
  14. " 1.1 Better handling of conditional operator, plus choice of highlighting for it.
  15. " 1.2 Allow multibyte character and string constants (i.e. start with L) apart from #include.
  16. " 1.3 Rework character constants to allow for character sequences.
  17. " 1.4 Add functions - catches macros, including defines like #define myconst (0).
  18. " 1.5 Add macro functions and correct #define to use Define, not Macro.
  19. " 1.6 Add missing hi link for cComment2String.
  20. " 1.7 Add cComment[2]String to exclude cluster for parens.
  21. "
  22. " 2.1 Remove cPPOperator(defined) from parens exclusion, but does add it to normal code.
  23. " 2.2 Start adding patterns for pointer dereference '*', and address of '&'.
  24. " 2.3 Tidy up character constant handling.
  25. " 2.4 Add cCommentSkip to exclusion list for paren group.
  26. "
  27. " 3.1 Removed code to pull in extensions, can now be done with au Syntax ...
  28. " 3.2 Add cCharacterNoError to exclusion list for paren group.
  29. " 3.3 Allow trailing dots on fp number to be part of fp number.
  30. " 3.4 Allow u and/or l suffixes for octal numbers.
  31. " 3.5 Move erroneous octal numbers to highlight only if allowed octals.
  32. " 3.6 Add printf and scanf format string highlighting.
  33. " 3.7 Add Notes and Acknowledgements.
  34. " 3.8 Macros starting with SIG followed by upper or _ claimed by implementation.
  35. " 3.9 ... as are all macros starting with and _ and followed by _ or upper case.
  36. " 3.10 Moved Standard typedefs and constants to end to override all else.
  37. " 3.11 Rework option flags to be closer to current distribution.
  38. " 3.12 Fix cCharacter to use smallest string upto next '.
  39. " 3.13 Improve working of cConditionalOperator.
  40. " 3.14 Replaced ALLBUTs with explicit groups - fewer surprises in store.
  41. " 3.15 Split types of space error as trailing ws in pp lines already handled.
  42. " 3.16 Add common C extensions a la c.vim (asm, #warn(ing)).
  43. " 3.17 Add flag to allow switching to c.vim level of highlighting.
  44. " 3.18 Add bracket content error highlighting a la c.vim
  45. "
  46. " 4.1 Highlight arg to goto as label, not identifier.
  47. " 4.2 Add support to optionally flag trigraphs as errors.
  48. " 4.3 Additions for C94 - types, constants, macros, and format specifiers.
  49. " 4.4 Allow highlighting of character constants as integers.
  50. " 4.5 Fix #define highlighting when line start with whitespace.
  51. "
  52. " 5.1 Highlight integer literal constant 0 as octal, since it is.
  53. " 5.2 Simplify string and comment highlighting a bit.
  54. " 5.3 Fix two or more cCharacter's on a line, where '\\' is not the last one
  55. "
  56. " 6.1 Fix octal zeroes with more than one 0!
  57. " 6.2 Hex numbers ending with 'e' and followed by [-+] is invalid!
  58. " 6.3 Correct C99 hex float constants - were horribly wrong.
  59. " 6.4 Add C99 reserved namespaces.
  60. " 6.5 Rework C99 integer types and constants.
  61. " 6.6 Add C94 feature warning.
  62. " 6.7 Rework handling of C94 and C99 warnings.
  63. " 6.8 Update to ViM 6 standard.
  64. " 6.9 Change trigraph pattern for ?? following change to regexp syntax.
  65. " 6.10 Remove digraph warnings from comments and strings.
  66. "
  67. " 7.1 Highlight floats of the form 10f as errors - invalid Standard C!
  68. " 7.2 Sort out C99 reserved function name warnings.
  69. " 7.3 Add C99 printf/scanf intger format specifiers.
  70. " 7.4 Change references from ANSI to Standard.
  71. " 7.5 Fix C94 & C99 error highlighting.
  72. " 7.6 Add support for c_gnu in VIM compatible mode, else warnings!
  73. " 7.7 Correct highlighting of contained C94, C99, and GNU language features.
  74. " 7.8 Use cCommentGroup as per distribution.
  75. " 7.9 Fix highlighting of Octal numbers.
  76. " 7.10 Add Posix and Maths constants from distribution as options.
  77. " 7.11 Flag hex/octal char constants in strings as non-portable.
  78. " 7.12 Missed __STDC_HOSTED__ from list of C99 constants.
  79. " 7.13 Add C99 #pragma STDC commands.
  80. " 7.14 Add handling for ... in function arg lists.
  81. " 7.15 Make numbers and types in comments switchable.
  82. " 7.16 Optionally highlight C++ keywords as errors.
  83. " 7.17 Highlight common date/time formats in comments.
  84. "
  85. " 8.1 Fix matching of months in date patterns - just alphabetics!
  86. " 8.2 Correct matching exact width C99 integer typedefs.
  87. " 8.3 Correct highlighting of C99 min/max width constant macros.
  88. " 8.4 Add more C99 library types and macro constants I missed.
  89. " 8.5 Oops, I is a constant in C99, not a type.
  90. " 8.6 Allow {} within paren with GCC macros - controlled by c_gnu.
  91. " 8.7 Correct handling of C99 universal characters.
  92. " 8.8 Optionally warn multi char integer constants.
  93. " 8.9 Add C99 specific printf/scanf highlighting.
  94. " 8.10 Rework scanlist highlighting including if '-' appears in wrong place.
  95. " 8.11 Warn on chars not in basic source char set.
  96. " 8.12 WS warnings were not working - shows I don't normally use them.
  97. " 8.13 Start using display to speed up highlighting.
  98. " 8.14 C99 8 digit universal character introduced by U not u.
  99. " 8.15 Allow use of %: digraph in PP statements with c_C94 defined.
  100. " 8.16 Implement support for c_no_utf in VIM c.vim compatible mode.
  101. " 8.17 Correct logic for when to display spacing errors.
  102. " 8.18 Correct logic for when to display ANSI constants.
  103. " 8.19 Correct logic handling mixes of C94/99 highlighting and warning.
  104. " 8.20 Use Boolean highlight group for C99 true and false.
  105. "
  106. " 9.0 Added supporting help file.
  107. " 9.1 Many clarifications to the documentation.
  108. " 9.2 Simplify effect of setting VIM C compatible mode.
  109. " 9.3 Warn on nesting of start of /* comments.
  110. " 9.4 Fix flagging reserved C99 library function names, use me not he.
  111. " 9.5 Redo space error highlighting as per VIM.
  112. " 9.6 When syntax is other than C, use standard c.vim.
  113. " 9.7 Use unlet! instead of unlet.
  114. " 9.8 Add fortran keyword for K&R code when c_c_vim_compatible is defined.
  115. "
  116. " 10.0 Can't use display with cCharacter since could contain '"'
  117. " 10.1 Add support for $ in VMS C identifiers controlled by c_vms.
  118. " 10.2 Zero followed by a type suffix is still an octal value.
  119. " 10.3 Highlight digraphs in syntax based on C94 and warning settings.
  120. " 10.4 Allow \ to continue C++ style one line comments!
  121. " 10.4a Fix bug in highlighting [...[...]...]
  122. " 10.5 Oops. no such token as ~= - now an error to help the unsuspecting.
  123. " 10.6 Scanlist can have a terminating '-'.
  124. " 10.7 Fix bugs in 10.6 changes for C94 scanlists (wide char strings)
  125. " 10.8 Fix highlighting of pre-C99 #pragma statements.
  126. "
  127. " 11.0 Allow #include to specify PP names as well as "" and <> strings.
  128. " 11.1 Fix highlighting nested C comments.
  129. " 11.2 Fix highlighting of system include file names.
  130. " 11.3 Argh! - fix highlighting of comments et al in #include statements
  131. " 11.4 Error highlight character constants in hex/octal with top bit set.
  132. "
  133. " 12.0 Add missing C99 F printf float format specifier.
  134. " 12.1 Add VIM 7 spelling group to comments and strings.
  135. " 12.2 Allow braces for C99 compound literals within parens.
  136. " 12.3 Add comment folding controllable by c_no_comment_fold.
  137. " 12.4 Make highlighting of braces in parens as errors controllable.
  138. " 12.5 Add syntax based folding of statement blocks as per Bram's.
  139.  
  140. " TODO
  141. " 1. Add #if 0/1 comment highlighting
  142. " 2. Fix macro continuation \ highlighting within parens
  143. "
  144.  
  145. " Catch sourcing of c.vim by other syntax files and redirect to default file.
  146. if &syntax != 'c'
  147.   source $VIMRUNTIME/syntax/c.vim
  148.   finish
  149. endif
  150.  
  151. " Quit when a (custom) syntax file was already loaded
  152. if exists("b:current_syntax")
  153.   finish
  154. endif
  155.  
  156. " VIM compatible mode takes precedence over some settings.
  157. if exists("c_c_vim_compatible")
  158.   " VIM C highlight C99 (sort of) unless c_no_c99 set.
  159.   let c_C94 = 1
  160.   unlet! c_C94_warn
  161.   unlet! c_C99_warn
  162.   if !exists("c_no_c99")
  163.     let c_C99 = 1
  164.   else
  165.     unlet! c_C99
  166.     let c_cpp_comments = 1
  167.   endif
  168.   let c_posix = 1
  169.   let c_math = 1
  170.   let c_no_names = 1
  171.   " Clear items not in default C syntax file
  172.   unlet! c_vms
  173.   unlet! c_char_is_integer
  174.   unlet! c_no_octal
  175.   unlet! c_impl_defined
  176.   unlet! c_comment_numbers
  177.   unlet! c_comment_types
  178.   unlet! c_comment_date_time
  179.   unlet! c_warn_nested_comment
  180.   unlet! c_warn_trigraph
  181.   unlet! c_warn_digraph
  182.   unlet! c_warn_8bitchars
  183.   unlet! c_warn_multichar
  184.   unlet! c_cpp_warn
  185. endif
  186.  
  187. " C94 must be on for warnings.
  188. if exists("c_C94_warn")
  189.   let c_C94 = 1
  190.   let c_warn_digraph = 1
  191. endif
  192.  
  193. if exists("c_C99_warn")
  194.   " C99 must be on for warnings.
  195.   let c_C99 = 1
  196.  
  197. elseif exists("c_C99") && exists("c_C94_warn")
  198.   " Should not warn for C94 if allowing C99!
  199.   unlet! c_C94_warn
  200. endif
  201.  
  202.  
  203. " C is case sensitive
  204. syn case match
  205.  
  206. " Use default keyword chars
  207. set isk&
  208.  
  209. " An empty pattern that can be used to initialise a cluster that may not have
  210. " anything else added to it.
  211. syn match         cEmpty            "^$"
  212.  
  213. " C basic source character set
  214. syn match         cCharsetError     display "[^a-zA-Z0-9!"#%&'()*+,-./:;<=>?[\]^_{|}~[:space:]]"
  215.  
  216. " C language keywords.
  217. syn keyword       c89Statement      goto break return continue
  218. syn cluster       cStatement        contains=c89Statement
  219. " For compilers with asm keyword - error if not c_c_vim_compatible.
  220. syn keyword       cKRStatement      asm
  221. syn cluster       cStatement        add=cKRStatement
  222. if !exists("c_c_vim_compatible") || exists("c_gnu")
  223.  syn keyword     cGNUStatement     __asm__
  224.  syn cluster     cStatement        add=cGNUStatement
  225. endif
  226. syn keyword       cLabel            case default
  227. syn keyword       cConditional      if else switch
  228. syn keyword       cRepeat           while for do
  229. syn cluster       cStatement        add=cLabel,cConditional,cRepeat
  230.  
  231.  
  232. " C data types
  233. syn keyword       c89Type           int long short char void signed unsigned float double
  234. syn cluster       cType             contains=c89Type
  235. if exists("c_C99")
  236.  syn keyword     c99Type           _Complex _Imaginary _Bool
  237.  " These are actually macros that expand to the above.
  238.  syn keyword     c99Type           bool complex imaginary
  239.  syn cluster     cType             add=c99Type
  240. endif
  241. if !exists("c_c_vim_compatible") || exists("c_gnu")
  242.  syn keyword     cGnuType          __label__ __complex__ __volatile__
  243.  syn cluster     cType             add=cGNUType
  244. endif
  245.  
  246.  
  247. " C language structures
  248. syn keyword       cStructureType    typedef
  249. syn keyword       cStructure        struct union enum
  250.  
  251.  
  252. " C storage modifiers
  253. syn keyword       c89StorageClass   static register auto volatile extern const
  254. syn cluster       cStorageClass     contains=c89StorageClass
  255. syn keyword       cKRStorageClass   fortran
  256. syn cluster       cStorageClass     add=cKRStorageClass
  257. if exists("c_C99")
  258.  syn keyword     c99StorageClass   restrict inline
  259.  syn cluster     cStorageClass     add=c99StorageClass
  260. else
  261.  syn keyword     cGNUStorageClass  inline
  262.  syn cluster     cStorageClass     add=cGNUStorageClass
  263. endif
  264. if !exists("c_c_vim_compatible") || exists("c_gnu")
  265.  syn keyword     cGNUStorageClass  __attribute__
  266.  syn cluster     cStorageClass     add=cGNUStorageClass
  267. endif
  268.  
  269.  
  270. " C operators
  271. syn keyword       cSizeofOperator   sizeof
  272. syn cluster       cOperator         contains=cSizeofOperator
  273. if !exists("c_c_vim_compatible")
  274.  " C math operators
  275.  syn match       cMathOperator     display "[-+\*/%=]"
  276.  " C pointer operators - address of and dereference are context sensitive
  277.  syn match       cPointerOperator  display "->\|\."
  278.  " C logical   operators - boolean results
  279.  syn match       cLogicalOperator  display "[!<>]=\="
  280.  syn match       cLogicalOperator  display "=="
  281.  " C bit operators
  282.  syn match       cBinaryOperator   display "\(&\||\|\^\|<<\|>>\)=\="
  283.  syn match       cBinaryOperator   display "\~"
  284.  syn match       cBinaryOperatorError display "\~="
  285.  " More C logical operators - highlight in preference to binary
  286.  syn match       cLogicalOperator  display "&&\|||"
  287.  syn match       cLogicalOperatorError display "\(&&\|||\)="
  288.  
  289.  syn cluster     cOperator         add=cMathOperator,cPointerOperator,cLogicalOperator,cBinaryOperator,cLogicalOperatorError,cBinaryOperatorError
  290. endif
  291. if !exists("c_c_vim_compatible") || exists("c_gnu")
  292.  syn keyword     cGNUOperator      typeof __real__ __imag__
  293.  syn cluster     cOperator         add=cGNUOperator
  294. endif
  295.  
  296.  
  297. " Digraph handling - highlight differently if warning, C94, or not recognised.
  298. if exists("c_C94") && !exists("c_warn_digraph")
  299.  syn match       cDigraph          transparent display "%:\|<[:%]\|[:%]>"
  300. else
  301.  syn match       cDigraph          display "%:\|<[:%]\|[:%]>"
  302. endif
  303.  
  304. " C identifiers - variables and functions
  305. syn cluster       cIdentifier       contains=cEmpty
  306. syn cluster       cFunction         contains=cEmpty
  307. if !exists("c_no_names")
  308.  syn match       c89Identifier     display "\<\h\w*\>"
  309.  syn cluster     cIdentifier       add=c89Identifier
  310.  syn match       c89Function       display "\<\h\w*\>\s*("me=e-1
  311.  syn cluster     cFunction         add=c89Function
  312.  if exists("c_vms")
  313.    syn match     cVMSIdentifier    display "\<\h\(\w*\$\)\+\w*\>"
  314.    syn cluster   cIdentifier       add=cVMSIdentifier
  315.    syn match     cVMSFunction      display "\<\h\(\w*\$\)\+\w*\>\s*("me=e-1
  316.    syn cluster   cFunction         add=cVMSFunction
  317.  endif
  318.  " Ellipses can only occur appear within function argument lists!
  319.  syn match       cEllipses         display contained ",\s*\.\.\.\s*)"ms=s+1,me=e-1
  320.  syn match       cEllipses         display contained "^\s*\.\.\.\s*)"me=e-1
  321.  syn match       cEllipsesError    display "\.\{2,}"
  322. endif
  323.  
  324.  
  325. " C Integer character constants
  326. " Escaped characters
  327. syn match         cEscapeCharError  display contained "\\[^'\"?\\abfnrtv]"
  328. syn match         cEscapeChar       display contained "\\['\"?\\abfnrtv]"
  329. if exists("c_c_vim_compatible") && exists("c_gnu")
  330.   syn match       cEscapeChar       display contained "\\e"
  331. endif
  332. " Octal characters
  333. syn match         cOctalChar        display contained "\\\o\{1,3}"
  334. syn cluster       cOCtalCharContents contains=cOctalChar
  335. syn match         cOctalCharError   display contained "\\\(2\|3\)\o\{1,2}"
  336. " Hex characters
  337. syn match         cHexChar          display contained "\\x\x\+"
  338. syn cluster       cHexCharContents  contains=cHexChar
  339. syn match         cHexCharError     display contained "\\x[89a-f]\x\+"
  340. if exists("c_warn_8bitchars")
  341.   " Octal and hex chars in integer character contents not portable if top bit set.
  342.   syn cluster     cHexCharContents  add=cHexCharError
  343.   syn cluster     cOctalCharContents add=cOctalCharError
  344. endif
  345. " Useful groupings of character types
  346. syn cluster       cSpecialChar      contains=cEscapeCharError,cEscapeChar,@cOctalCharContents,@cHexCharContents
  347. syn cluster       cSpecialCharNoError contains=cEscapeChar,cOctalChar,cHexChar
  348. if (exists("c_c_vim_compatible") || exists("c_C99")) && !exists("c_no_utf")
  349.   " C99 universal chars - hmm, can appear anywhere!
  350.   syn match       cUniversalChar    display contained "\\u\x\{4}"
  351.   syn match       cUniversalChar    display contained "\\U\x\{8}"
  352.   syn cluster     cSpecialChar      add=cUniversalChar
  353.   syn cluster     cSpecialCharNoError add=cUniversalChar
  354. endif
  355. if !exists("c_warn_multichar")
  356.   syn match       cMultiCharacter   "L\='\(\\.\|.\)\{-2,}'" contains=@cSpecialChar
  357. else
  358.   syn match       cCharacterError   "L\='\(\\.\|.\)\{-2,}'"
  359. endif
  360. syn match         cCharacter        "L\='\(\\.\|[^\']\)'" contains=cEscapeCharError,cEscapeChar
  361. syn match         cCharacter        display "L\='\\x\x\x\='" contains=@cHexCharContents
  362. syn match         cCharacter        display "L\='\\\o\{1,3}'" contains=@cOctalCharContents
  363. syn match         cCharacterError   display "L\='\([^']*$\|'\)"
  364. syn match         cCharacterNoError display contained "L\='\(\\.\|.\)\{-}'" contains=@cSpecialCharNoError
  365.  
  366.  
  367. " C String constants
  368. syn cluster       cStringContents   contains=@cSpecialChar,cPPLineJoin,@Spell
  369. if exists("c_warn_8bitchars")
  370.   " Octal and hex chars in strings not portable if top bit set.
  371.   syn cluster     cStringContents   add=cHexCharError,cOctalCharError
  372. endif
  373. syn cluster       cFormat           contains=cEmpty
  374. if !exists("c_no_cformat")
  375.   " Where behaviour is undefined in a format string it will not be highlighted!
  376.   " This explains why the 0 flag is omitted for string print format etc.
  377.  
  378.   " Anything other than the following patterns are undefined format strings
  379.   syn match       cFormatError      display contained "%[^"]"
  380.   syn match       cFormatError      display contained "%\""me=e-1
  381.   " Catch implementation defined scanlists
  382.   syn match       cFormatError      display contained "%\*\=\(0*[1-9]\d*\)\=\[\(\^.\|[^^]\)[^]-]*-[^]]*-\=\]"
  383.  
  384.   " octal and hex print formats (can have precision and h or l size specifier)
  385.   syn match       cPrintFormat      display contained "%[-+0 #]*\(\*\|\d\+\)\=\(\.\(\*\|\d*\)\)\=[hl]\=[oxX]"
  386.   " intger print formats (can have precision and h or l size specifier, but no # flag)
  387.   syn match       cPrintFormat      display contained "%[-+0 ]*\(\*\|\d\+\)\=\(\.\(\*\|\d*\)\)\=[hl]\=[diu]"
  388.   " fp print formats (can have precision but only L size specfier)
  389.   syn match       cPrintFormat      display contained "%[-+0 #]*\(\*\|\d\+\)\=\(\.\(\*\|\d*\)\)\=L\=[eEfgG]"
  390.   " string print formats (can have precision but no 0 or # flags)
  391.   syn match       cPrintFormat      display contained "%[-]*\(\*\|[1-9]\d*\)\=\(\.\(\*\|\d*\)\)\=s"
  392.   " number chars so far print formats (h or l size specifiers but no precision 0, or # flags, should allow optional parts?)
  393.   syn match       cPrintFormat      display contained "%[-]*\(\*\|[1-9]\d*\)\=[hl]\=n"
  394.   " character and pointer print formats (no size specifiers, precision, 0, or # flags)
  395.   syn match       cPrintFormat      display contained "%[-]*\(\*\|[1-9]\d*\)\=[cp]"
  396.   syn match       cPrintFormat      display contained "%%"
  397.  
  398.   " scanf formats may not have zero integer field width!
  399.   " integer, octal and hex scan formats
  400.   syn match       cScanFormat       display contained "%\*\=\(0*[1-9]\d*\)\=[hl]\=[oxXdinu]"
  401.   " fp scan formats
  402.   syn match       cScanFormat       display contained "%\*\=\(0*[1-9]\d*\)\=[lL]\=[eEfgG]"
  403.   " char string scan format
  404.   syn match       cScanFormat       display contained "%\*\=\(0*[1-9]\d*\)\=\[\(\^.\|[^^]\)[^]-]*-\=\]"
  405.   " character, string and pointer scan formats
  406.   syn match       cScanFormat       display contained "%\*\=\(0*[1-9]\d*\)\=[csp]"
  407.  
  408.   syn cluster     cFormat           add=cPrintFormat,cScanFormat,cFormatError
  409.  
  410.   if exists("c_C94")
  411.     " C94 has new format codes for wide chars and strings (no 0 or # flags)
  412.     syn match     c94PrintFormat    display contained "%[-]*\(\*\|[1-9]\d*\)\=\(\.\(\*\|\d*\)\)\=ls"
  413.     syn match     c94PrintFormat    display contained "%[-]*\(\*\|[1-9]\d*\)\=lc"
  414.     syn match     cFormatError      display contained "%\*\=\(0*[1-9]\d*\)\=l\[\(\^.\|[^^]\)[^]-]*-[^]]*-\=\]"
  415.     syn match     c94ScanFormat     display contained "%\*\=\(0*[1-9]\d*\)\=l\[\(\^.\|[^^]\)[^]-]*-\=\]"
  416.     syn match     c94ScanFormat     display contained "%\*\=\(0*[1-9]\d*\)\=l[cs]"
  417.     syn cluster   cFormat           add=c94PrintFormat,c94ScanFormat
  418.   endif
  419.   if exists("c_C99")
  420.     " integer conversions have new length modifiers
  421.     syn match     c99PrintFormat    display contained "%[-+0 #]*\(\*\|\d\+\)\=\(\.\(\*\|\d*\)\)\=\(hh\|ll\|j\|z\|t\)[oxX]"
  422.     syn match     c99PrintFormat    display contained "%[-+0 ]*\(\*\|\d\+\)\=\(\.\(\*\|\d*\)\)\=\(hh\|ll\|j\|z\|t\)[diu]"
  423.     " fp conversion has new format specifier, and allows l length modifier for C89 ones
  424.     syn match     c99PrintFormat    display contained "%[-+0 #]*\(\*\|\d\+\)\=\(\.\(\*\|\d*\)\)\=l[eEfgG]"
  425.     syn match     c99PrintFormat    display contained "%[-+0 #]*\(\*\|\d\+\)\=\(\.\(\*\|\d*\)\)\=[lL]\=[aAF]"
  426.     " number chars so has new length modifiers
  427.     syn match     c99PrintFormat    display contained "%[-]*\(\*\|[1-9]\d*\)\=\(hh\|j\|z\|t\)n"
  428.  
  429.     " new length modifiers for integers
  430.     syn match     c99ScanFormat     display contained "%\*\=\(0*[1-9]\d*\)\=\(hh\|ll|\j\|z\|t\)[oxXdinu]"
  431.     " new fp conversion specifier
  432.     syn match     c99ScanFormat     display contained "%\*\=\(0*[1-9]\d*\)\=[lL]\=[aAF]"
  433.     syn cluster   cFormat           add=c99PrintFormat,c99ScanFormat
  434.   endif
  435.  
  436.   syn cluster     cStringContents   add=@cFormat
  437. endif
  438. syn region        cString           start=+L\="+ skip=+\\"+ end=+"+ contains=@cStringContents
  439.  
  440. " C numeric constants.
  441. syn case ignore
  442. " Integer
  443. syn match         cDecimal          display "\<\d\+\(u\=l\=\|lu\)\>"
  444. " Hex integer
  445. syn match         cHex              display "\<0x\x\+\(u\=l\=\|lu\)\>"
  446. " But there is one illegal form of hex ...
  447. syn match         cHexError         display "\<0x\x*e[-+]"
  448. " Octal integers
  449. syn match         cOctalZero        display contained "0"
  450. syn match         cOctal            display "\<0\+\(u\=l\=\|lu\)\>" contains=cOctalZero
  451. if exists("c_no_octal")
  452.   syn match       cOctalError       display "\<0\+[1-9]\d*\(u\=l\=\|lu\)\>"
  453. else
  454.   syn match       cOctal            display "\<0\o*\(u\=l\=\|lu\)\>" contains=cOctalZero
  455.   syn match       cOctalError       display "\<0\o*[89]\d*\(u\=l\=\|lu\)\>"
  456. endif
  457. syn cluster       cInteger          contains=cDecimal,cHex,cHexError,cOctal,cOctalError
  458. syn cluster       cIntegerNoOctalErr contains=cDecimal,cHex,cHexError,cOctal
  459. " Fp with dot, optional exponent
  460. syn match         c89Float          display "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
  461. " FP starting with a dot, optional exponent
  462. syn match         c89Float          display "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
  463. " FP without dot, with exponent
  464. syn match         c89Float          display "\<\d\+e[-+]\=\d\+[fl]\=\>"
  465. syn cluster       cFloat            contains=c89Float
  466. " Fp with no dp or exponent is invalid
  467. syn match         cFloatError       display "\<\d\+f\>"
  468. " Initialise boolean cluster to be empty.
  469. syn cluster       cBoolean          contains=cEmpty
  470.  
  471. if exists("c_C99")
  472.   " Integers have new length qualifiers.
  473.   syn match       c99Decimal        display "\<\d\+\(u\=ll\|llu\)\>"
  474.   syn match       c99Hex            display "\<0x\x\+\(u\=ll\|llu\)\>"
  475.   syn cluster     cInteger          add=c99Decimal,c99Hex
  476.   if exists("c_no_octal")
  477.     syn match     c99OctalError     display "\<0\+[1-9]\d*\(u\=ll\=\|llu\)\>"
  478.   else
  479.     syn match     c99Octal          display "\<0\o*\(u\=ll\=\|llu\)\>" contains=cOctalZero
  480.     syn match     c99OctalError     display "\<0\o*[89]\d*\(u\=ll\=\|llu\)\>"
  481.     syn cluster   cInteger          add=c99Octal
  482.     syn cluster   cIntegerNoOctalErr contains=c99Octal
  483.   endif
  484.   syn cluster     cInteger          add=c99OctalError
  485.   " Fp now has a hexadecimal format
  486.   " Fp with dot, optional fractional part
  487.   syn match       c99Float          display "\<0x\x\+\(\.\x*\)\=p[-+]\=\d\+[fl]\="
  488.   " FP starting with a dot
  489.   syn match       c99Float          display "0x\.\x\+p[-+]\=\d\+[fl]\=\>"
  490.   syn cluster     cFloat            add=c99Float
  491. endif
  492.  
  493. " Turn case matching back on
  494. syn case match
  495.  
  496.  
  497. " Highlight trailing and/or mixed space errors
  498. if exists("c_space_errors")
  499.   if !exists("c_no_trail_space_error")
  500.     syn match     cTrailSpaceError  "\s\+$"
  501.   endif
  502.   if !exists("c_no_tab_space_error")
  503.     syn match     cMixedSpaceError  display " \+\t"me=e-1
  504.   endif
  505. endif
  506. syn cluster       cSpaceError       contains=cTrailSpaceError,cMixedSpaceError
  507.  
  508.  
  509. " C comments
  510. syn keyword       cTodo             contained TODO FIXME XXX
  511. syn cluster       cCommentGroup     contains=cTodo,@cSpaceError
  512. if exists("c_comment_strings")
  513.   " A comment can contain cString, but a "*/" inside a cString in a cComment
  514.   " DOES end the comment!  So we need to use a special type of cString:
  515.   " cCommentString, which also ends on "*/", and sees a "*" at the start of
  516.   " the line as comment again.
  517.   syn match       cCommentSkip      contained "^\s*\*\($\|\s\+\)"
  518.   syn cluster     cCommentStringContents contains=cCharacterNoError,@cSpecialCharNoError,cCommentSkip
  519.   syn region      cCommentString    contained start=+L\="+ skip=+\\"+ end=+"+ end=+\*\(\\\s*\n\s*\)*\/+me=s-1 contains=@cCommentStringContents
  520.   if exists("c_comment_numbers")
  521.     syn cluster   cCommentGroup     add=@cIntegerNoOctalErr,@cFloat,cFloatError,@cBoolean,@cConstant
  522.   endif
  523.   if exists("c_comment_types")
  524.     syn cluster   cCommentGroup     add=cType,@cTypedef
  525.   endif
  526.   if exists("c_comment_date_time")
  527.     " Time formats: hh:mm[:ss]
  528.     syn match     cTime             contained "\d\{2}\(:\d\{2}\)\{1,2}"
  529.     " Date formats: dd mmm yy[yy], dd/mmm/yy[yy], dd-mmm-yy[yy]
  530.     syn match     cDate             contained "\d\{1,2}[ -/]\a\{3}[ -/]\(\d\{2}\)\{1,2}"
  531.     " Date formats: dd/mm/yy[yy], dd-mm-yy[yy]
  532.     syn match     cDate             contained "\d\{1,2}[-/]\d\{1,2}[-/]\(\d\{2}\)\{1,2}"
  533.     " Date formats: mmm dd yyyy
  534.     syn match     cDate             contained "\a\{3} \d\{2} \d\{4}"
  535.     " Date formats: ISO yyyy/mm/dd
  536.     syn match     cDate             contained "\d\{4}/\d\{2}/\d\{2}"
  537.     syn cluster   cCommentGroup     add=cTime,cDate
  538.   endif
  539. endif
  540. if exists("c_warn_nested_comments")
  541.   " Catch start of C comments within C comments.
  542.   syn match       cCommentStartError contained "/\*"
  543. endif
  544. syn match         cCommentDelim     contained "/\*\|\*/"
  545. if exists("c_no_comment_fold")
  546.   syn region      cComment          keepend matchgroup=cCommentDelim start="/\*" end="\*/" contains=cCommentString,cCharacterNoError,@cCommentGroup,cCommentStartError,@Spell
  547. else
  548.   syn region      cComment          keepend matchgroup=cCommentDelim start="/\*" end="\*/" contains=cCommentString,cCharacterNoError,@cCommentGroup,cCommentStartError,@Spell fold
  549. endif
  550. syn match         cCommentError     "\*/"
  551. if exists("c_cpp_comments") || (exists("c_C99") && !exists("c_C99_warn"))
  552.   if exists("c_comment_strings")
  553.     " Unfortunately this doesn't very well work for // type of comments :-(
  554.     syn region    cComment2String   contained start=+L\="+ skip=+\\"+ end=+"+ end="$" contains=@cCommentStringContents
  555.   endif
  556.   if exists("c_no_comment_fold")
  557.     syn region    cComment          start="//" skip="\\$" end="$" contains=cComment2String,cCharacterNoError,@cCommentGroup,cPPLineJoin,cPPLineJoinError,@Spell
  558.   else
  559.     syn region    cComment          start="//" skip="\\$" end="$" contains=cComment2String,cCharacterNoError,@cCommentGroup,cPPLineJoin,cPPLineJoinError,@Spell fold
  560.   endif
  561. else
  562.   syn region      cCommentError     start="//" skip="\\$" end="$"
  563. endif
  564. syn sync ccomment cComment
  565.  
  566. " C Conditional operatior - ?:
  567. syn cluster       cConditionalContents contains=cEmpty
  568. if !exists("c_c_vim_compatible")
  569.   syn cluster     cConditionalContents add=cCharsetError,@cInteger,cOctalError,@cFloat,cFloatError,@cBoolean
  570.   syn cluster     cConditionalContents add=cString,cCharacter,cMultiCharacter,cCharacterError,@cConstant
  571.   syn cluster     cConditionalContents add=@cIdentifier,@cFunction,@cMacro
  572.   syn cluster     cConditionalContents add=@cType,@cTypedef,cStructure,cConditionalOperator,@cOperator,cOperatorError
  573.   syn cluster     cConditionalContents add=cComment,cCommentError,@cSpaceError,cParen,cBracket
  574.   syn cluster     cConditionalContents add=@cPPCommands,cDigraph
  575.   syn region      cConditionalOperator start="?" end=":" contains=@cConditionalContents
  576. endif
  577.  
  578.  
  579. " C pre-processor commands
  580. syn cluster       cPPCommands       contains=cPPEmptyLine,cInclude,cPreCondit,cDefine,cUndef,cLine,cPragma,cPreProc
  581.  
  582. " Pre-processor commands only allowed spaces and tabs as whitespace
  583. syn match         cPPWhiteSpace     display contained "\s*"
  584. syn match         cPPSpaceError     display contained "\(\e\|\r\|\b\)\+"
  585.  
  586. " Highlight cpp joined lines and those done incorrectly
  587. syn match         cPPLineJoin       contained "\\$"
  588. syn match         cPPLineJoinError  contained "\\\s\+$"
  589.  
  590. " Token operator
  591. syn match         cPPTokenOperator  contained "\(%:\|#\)\{1,2}" contains=cDigraph
  592.  
  593. " Empty cpp lines which are not join or paste operations
  594. syn match         cPPLineStart      transparent contained "^\s*\(%:\|#\)" contains=cDigraph
  595. syn match         cPPEmptyLine      "^\s*\(%:\|#\).*$" contains=cComment,cPPWhiteSpace,cPPSpaceError,cPPLineStart
  596.  
  597. " Almost all pre-processor lines (not include) contain the following
  598. syn cluster       cPPCommon         contains=cComment,cCommentError,cPPSpaceError,cPPEmptyLine,cPPLineJoin,cPPLineJoinError
  599.  
  600. " File inclusion
  601. syn match         cPPInclude        transparent contained "^\s*\(%:\|#\)\s*include\>" contains=cDigraph
  602. syn region        cPPIncludeFile    contained start=+"+ skip=+\\"+ end=+"+ contains=cPPLineJoin,cPPLineJoinError
  603. syn match         cPPIncludeFile    contained "<[^>]*>"
  604. syn match         cInclude          display "^\s*\(%:\|#\)\s*include\>\s*.*$" contains=cPPSpaceError,cPPInclude,cPPIncludeFile,@cPPCommon
  605.  
  606. " Conditional code
  607. syn match         cPPIf             transparent contained "^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\|else\|endif\)\>" contains=cDigraph
  608. syn region        cPPIfParen        transparent start='(' end=')' contains=@cPPIfInteger,cPPIfParen
  609. syn keyword       cPPOperator       contained defined
  610. syn cluster       cPPIfInteger      contains=@cInteger,cOctalError,cCharacter,cMultiCharacter,cCharacterError,@cConstant,@cMacro,@cIdentifier
  611. syn cluster       cPPIfInteger      add=cMathOperator,cLogicalOperator,cBinaryOperator,cPPOperator
  612. syn region        cPreCondit        start="^\s*\(%:\|#\)\s*\(if\|elif\)\>" skip="\\$" end="$" contains=cPPIf,@cPPIfInteger,cPPIfParen,@cPPCommon
  613. syn cluster       cPPIfIdentifer    contains=@cIdentifier,@cMacro
  614. syn region        cPreCondit        start="^\s*\(%:\|#\)\s*\(ifdef\|ifndef\)\>" skip="\\$" end="$" contains=cPPIf,@cPPIfIdentifier,@cPPCommon
  615. syn region        cPreCondit        start="^\s*\(%:\|#\)\s*\(else\|endif\)\>" skip="\\$" end="$" contains=cPPIf,@cPPCommon
  616.  
  617. " Macros
  618. syn cluster       cDefineContents   contains=cCharsetError,@cInteger,cOctalError,@cFloat,cFloatError,@cBoolean
  619. syn cluster       cDefineContents   add=cString,cCharacter,cMultiCharacter,cCharacterError,@cConstant
  620. syn cluster       cDefineContents   add=@cIdentifier,@cFunction,@cMacro,cUserCont,@cStatement
  621. syn cluster       cDefineContents   add=@cType,@cTypedef,cStructure,cStructureType,@cStorageClass,cStorageClassError
  622. syn cluster       cDefineContents   add=cConditionalOperator,@cOperator,cOperatorError,cPPTokenOperator
  623. syn cluster       cDefineContents   add=@cSpaceError,cDefineParen,cBracket,cDigraph
  624. syn match         cPPDefine         transparent contained "^\s*\(%:\|#\)\s*define\>" contains=cDigraph
  625. syn region        cDefine           start="^\s*\(%:\|#\)\s*define\>" skip="\\$" end="$" contains=cPPDefine,cPPSpaceError,@cDefineContents,@cPPCommon
  626.  
  627. syn match         cPPUndef          transparent contained "^\s*\(%:\|#\)\s*undef\>" contains=cDigraph
  628. syn region        cUndef            start="^\s*\(%:\|#\)\s*undef\>" skip="\\$" end="$" contains=cPPUndef,cIdentifer,@cMacro,@cPPCommon
  629.  
  630. syn cluster       cMacro            contains=cEmpty
  631. if !exists("c_no_names")
  632.   syn match       cCMacro           display "\<\u[[:upper:][:digit:]_]*\s*("me=e-1
  633.   syn cluster     cMacro            add=cCMacro
  634.   if exists("c_vms")
  635.     syn match     cVMSMacro         display "\<\u\([[:upper:][:digit:]_]*\$\)\+[[:upper:][:digit:]_]*\s*("me=e-1
  636.     syn cluster   cMacro            add=cVMSMacro
  637.   endif
  638. endif
  639.  
  640. " Line control
  641. syn match         cPPLineNumber     display contained "\<\d\+\>"
  642. syn match         cPPLineNumberError display contained "\<0\+\>"
  643. syn match         cPPLine           transparent contained "^\s*\(%:\|#\)\s*line\>" contains=cDigraph
  644. syn region        cLine             start="^\s*\(%:\|#\)\s*line\>" skip="\\$" end="$" contains=cPPLine,cPPLineNumber,cPPLineNumberError,cString,@cMacro,@cIdentifier,@cPPCommon
  645.  
  646. " Error
  647. syn match         cPPMisc           transparent contained "^\s*\(%:\|#\)\s*error\>" contains=cDigraph
  648. syn cluster       cPPTokens         contains=@cIdentifier,cString,@cInteger
  649. syn region        cPreProc          start="^\s*\(%:\|#\)\s*error\>" skip="\\$" end="$" contains=cPPMisc,@cPPTokens,@cPPCommon
  650.  
  651. " Pragma
  652. syn match         cPPPragma         transparent contained "^\s*\(%:\|#\)\s*pragma\>" contains=cDigraph
  653. syn region        cPragma           start="^\s*\(%:\|#\)\s*pragma\>" skip="\\$" end="$" contains=cPPPragma,@cPPTokens,@cPPCommon
  654. if exists("c_C99")
  655.   " C99 has a fixed form of #pragma also.
  656.   syn match       c99PPPragmaError  contained "[^[:space:]]\+"
  657.   syn match       c99PPPragmaSTDC   contained "^\s*\(%:\|#\)\s*pragma STDC\>" contains=cDigraph
  658.   syn keyword     c99PPPragmaOperator contained FP_CONTRACT FENV_ACCESS CX_LIMITED_RANGE ON OFF DEFAULT
  659.   syn region      c99Pragma         start="^\s*\(%:\|#\)\s*pragma STDC\>" skip="\\$" end="$" contains=c99PPPragmaSTDC,c99PPPragmaOperator,c99PPPragmaError
  660.   syn keyword     c99Pragma         _Pragma
  661.   syn cluster     cPPCommands       add=c99Pragma
  662. endif
  663.  
  664. if exists("c_c_vim_compatible")
  665.   " Some compilers may support these pp commands
  666.   syn match       cPPWarn           transparent contained "^\s*\(%:\|#\)\s*\(warn\|warning\)\>" contains=cDigraph
  667.   syn region      cPreProc          start="^\s*\(%:\|#\)\s*\(warn\|warning\)\>" skip="\\$" end="$" contains=cPPWarn,@cPPTokens,@cPPCommon
  668. endif
  669.  
  670.  
  671. " C statement labels
  672. syn match         cUserLabel        display contained "\h\w*"
  673. syn match         cUserCont         display "^\s*\h\w*\s*:\s*" contains=cUserLabel
  674. syn match         cUserCont         display ";\s*\h\w*\s*:\s*" contains=cUserLabel
  675. syn match         cUserCont         display "goto\s\+\h\w*"lc=4 contains=cUserLabel
  676. if exists("c_vms")
  677.   syn match       cUserLabel        display contained "\h\(\w*\$\)\+\w*"
  678.   syn match       cUserCont         display "^\s*\h\(\w*\$\)\+\w*\s*:\s*" contains=cUserLabel
  679.   syn match       cUserCont         display ";\s*\h\(\w*\$\)\+\w*\s*:\s*" contains=cUserLabel
  680.   syn match       cUserCont         display "goto\s\+\h\(\w*\$\)\+\w*"lc=4 contains=cUserLabel
  681. endif
  682.  
  683.  
  684. " C bitfield definitions - used to prevent highlighting as a statement label
  685. syn match         cBitField         display "^\s*\h\w*\s*:\s*[1-9]"me=e-1 contains=@cIdentifier
  686. syn match         cBitField         display ";\s*\h\w*\s*:\s*[1-9]"me=e-1 contains=@cIdentifier
  687. if exists("c_vms")
  688.   syn match       cBitField         display "^\s*\h\(\w*\$\)\+\w*\s*:\s*[1-9]"me=e-1 contains=@cIdentifier
  689.   syn match       cBitField         display ";\s*\h\(\w*\$\)\+\w*\s*:\s*[1-9]"me=e-1 contains=@cIdentifier
  690. endif
  691.  
  692.  
  693. " Catch errors caused by wrong parenthesis and bracketing
  694. syn cluster       cParenContents    contains=cCharsetError,@cInteger,cOctalError,@cFloat,cFloatError,@cBoolean
  695. syn cluster       cParenContents    add=cString,cCharacter,cMultiCharacter,cCharacterError,@cConstant
  696. syn cluster       cParenContents    add=@cIdentifier,@cFunction,cEllipses,cEllipsesError,@cMacro,@cType,@cTypedef,cStructure,@cStorageClass,cStorageClassError
  697. syn cluster       cParenContents    add=@cOperator,cOperatorError,cConditionalOperator
  698. syn cluster       cParenContents    add=cComment,cCommentError,@cSpaceError
  699. syn cluster       cParenContents    add=@cPPCommands,cDigraph
  700. if !exists("c_no_bracket_error")
  701.   syn match       cErrBracketInParen contained "]\|:>" contains=cDigraph
  702.   syn match       cErrInBracket     contained "[);{}]\|<%\|%>" contains=cDigraph
  703.   if !exists("c_C94")
  704.     syn region    cBracket          transparent start="\[" end="]" contains=@cParenContents,cBracket,cParen,cErrInBracket
  705.   else
  706.     syn region    cBracket          transparent start="\[\|<%" end="]\|%>" contains=@cParenContents,cBracket,cParen,cErrInBracket
  707.   endif
  708.   syn match       cBracketError     "]\|%>" contains=cDigraph
  709. endif
  710. if (!exists("c_C99") || exists("c_C99_warn")) && !exists("c_no_curly_error")
  711.   " Braces not allowed in parenthesise pre C99
  712.   syn match       cErrBraceInParen  contained "{\|}\|<%\|%>" contains=cDigraph
  713. endif
  714. syn region        cParen            transparent start='(' end=')' contains=@cParenContents,cParen,cBracket,cErrBraceInParen,cErrBracketInParen
  715. syn cluster       cDefineParenContents contains=@cParenContents,cDefineParen,cBracket,cErrBracketInParen
  716. if !exists("c_c_vim_compatible") || !exists("c_gnu")
  717.   syn cluster     cDefineParenContents add=cErrBraceInParen
  718. endif
  719. syn region        cDefineParen      contained transparent start='(' end=')' contains=@cDefineParenContents
  720. syn match         cParenError       ")"
  721.  
  722. " Syntax folding of statement blocks
  723. syn region        cBlock            start="{" end="}" transparent fold
  724.  
  725. " C typedefs
  726. syn cluster       cTypedef          contains=cEmpty
  727. if !exists("c_no_ansi") || exists("c_ansi_typedefs")
  728.   syn keyword     c89Typedef        size_t wchar_t ptrdiff_t sig_atomic_t fpos_t div_t ldiv_t
  729.   syn keyword     c89Typedef        clock_t time_t va_list jmp_buf FILE
  730.   syn cluster     cTypedef          add=c89Typedef
  731.  
  732.   if exists("c_c_vim_compatible")
  733.     " VIM includes following typedefs
  734.     syn keyword   cVIMTypedef       DIR
  735.     syn cluster   cTypedef          add=cVIMTypedef
  736.   endif
  737.  
  738.   if exists("c_C94")
  739.     " C94 new typedefs
  740.     syn keyword   c94Typedef        wint_t wctrans_t wctype_t mbstate_t
  741.     syn cluster   cTypedef          add=c94Typedef
  742.   endif
  743.  
  744.   if exists("c_C99")
  745.     " C99 new typedefs
  746.     syn keyword   c99Typedef        fenv_t fexcept_t float_t double_t
  747.     syn match     c99Typedef        display "\<u\=int\(_least\|_fast\)\=\d\+_t\>"
  748.     syn keyword   c99Typedef        intptr_t uintptr_t intmax_t uintmax_t
  749.     syn keyword   c99Typedef        lldiv_t imaxdiv_t
  750.     syn cluster   cTypedef          add=c99Typedef
  751.   endif
  752. endif
  753.  
  754.  
  755. " C constants
  756. syn cluster       cConstant         contains=cEmpty
  757. if !exists("c_no_ansi") || exists("c_ansi_constants")
  758.   syn keyword     c89Constant       __LINE__ __FILE__ __DATE__ __TIME__ __STDC__
  759.   syn keyword     c89Constant       CHAR_BIT MB_LEN_MAX MB_CUR_MAX
  760.   syn keyword     c89Constant       UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX
  761.   syn keyword     c89Constant       INT_MIN LONG_MIN SHRT_MIN
  762.   syn keyword     c89Constant       CHAR_MAX INT_MAX LONG_MAX SHRT_MAX
  763.   syn keyword     c89Constant       SCHAR_MIN SINT_MIN SLONG_MIN SSHRT_MIN
  764.   syn keyword     c89Constant       SCHAR_MAX SINT_MAX SLONG_MAX SSHRT_MAX
  765.   syn keyword     c89Constant       FLT_RADIX FLT_ROUNDS FLT_DIG FLT_MANT_DIG FLT_EPSILON
  766.   syn keyword     c89Constant       FLT_MIN FLT_MAX FLT_MIN_EXP FLT_MAX_EXP FLT_MIN_10_EXP FLT_MAX_10_EXP
  767.   syn keyword     c89Constant       DBL_MIN DBL_MAX DBL_MIN_EXP DBL_MAX_EXP DBL_MIN_10_EXP DBL_MAX_10_EXP
  768.   syn keyword     c89Constant       DBL_DIG DBL_MANT_DIG DBL_EPSILON
  769.   syn keyword     c89Constant       LDBL_MIN LDBL_MAX LDBL_MIN_EXP LDBL_MAX_EXP LDBL_MIN_10_EXP LDBL_MAX_10_EXP
  770.   syn keyword     c89Constant       LDBL_DIG LDBL_MANT_DIG LDBL_EPSILON
  771.   syn keyword     c89Constant       HUGE_VAL EDOM ERANGE CLOCKS_PER_SEC NULL
  772.   syn keyword     c89Constant       LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME
  773.   syn keyword     c89Constant       SIG_DFL SIG_ERR SIG_IGN SIGABRT SIGFPE SIGILL SIGINT SIGSEGV SIGTERM
  774.   syn keyword     c89Constant       _IOFBF _IOLBF _IONBF BUFSIZ EOF FOPEN_MAX FILENAME_MAX L_tmpnam
  775.   syn keyword     c89Constant       SEEK_CUR SEEK_END SEEK_SET TMP_MAX stderr stdin stdout
  776.   syn keyword     c89Constant       EXIT_FAILURE EXIT_SUCCESS RAND_MAX
  777.   syn cluster     cConstant         add=c89Constant
  778.  
  779.   " C94 additional constants
  780.   if exists("c_C94")
  781.     syn keyword   c94Constant       EILSEQ WEOF WCHAR_MAX WCHAR_MIN __STDC_VERSION__
  782.     syn cluster   cConstant         add=c94Constant
  783.   endif
  784.  
  785.   " C99 additional constants
  786.   if exists("c_C99")
  787.     syn keyword   c99Boolean        true false
  788.     syn cluster   cBoolean          add=c99Boolean
  789.     syn keyword   c99Constant       __STDC_HOSTED__ __STDC_IEC_559__ __STDC_IEC_559_COMPLEX__ __STDC_ISO_10646__
  790.     syn keyword   c99Constant       __VA_ARGS__
  791.     syn keyword   c99Constant       __func__ __bool_true_false_are_defined
  792.     syn keyword   c99Constant       FE_DIVBYZERO FE_INEXACT FE_INVALID FE_OVERFLOW FE_UNDERFLOW FE_ALL_EXCEPT
  793.     syn keyword   c99Constant       FE_DOWNWARD FE_TONEAREST FE_TOWARDZERO FE_UPWARD FE_DFL_ENV
  794.     syn keyword   c99Constant       HUGE_VALF HUGE_VALL INFINITY NAN
  795.     syn keyword   c99Constant       FP_INFINITE FP_NAN FP_NORMAL FP_SUBNORMAL FP_ZERO
  796.     syn keyword   c99Constant       FP_FAST_FMA FP_FAST_FMAF FP_FAST_FMAL FP_ILOGB0 FP_ILOGBNAN
  797.     syn keyword   c99Constant       MATH_ERRNO MATH_ERREXCEPT math_errhandling
  798.     syn match     c99Constant       display "\<INT\(_LEAST\|_FAST\)\=\d\+_\(MIN\|MAX\)\>"
  799.     syn match     c99Constant       display "\<UINT\(_LEAST\|_FAST\)\=\d\+_MAX\>"
  800.     syn keyword   c99Constant       INTPTR_MIN INTPTR_MAX UINTPTR_MAX INTMAX_MIN INTMAX_MAX UINTMAX_MAX
  801.     syn keyword   c99Constant       PTRDIFF_MIN PTRDIFF_MAX SIG_ATOMIC_MIN SIG_ATOMIC_MAX SIZE_MAX
  802.     syn keyword   c99Constant       WINT_MIN WINT_MAX LLONG_MIN LLONG_MAX ULLONG_MAX
  803.     syn keyword   c99Constant       _Complex_I _Imaginary_I I
  804.     syn cluster   cConstant         add=c99Constant
  805.   endif
  806.  
  807.   if !exists("c_c_vim_compatible") || exists("c_gnu")
  808.     " GNU constants
  809.     syn keyword   cGNUConstant      __GNUC__ __FUNCTION__ __PRETTY_FUNCTION__
  810.     syn cluster   cConstant         add=cGNUConstant
  811.   endif
  812.   if exists("c_posix")
  813.     " POSIX signals and errors
  814.     syn keyword cPosixConstant      SIGALRM SIGCHLD SIGCONT SIGHUP SIGKILL SIGPIPE SIGQUIT
  815.     syn keyword cPosixConstant      SIGSTOP SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2
  816.     syn keyword cPosixConstant      E2BIG EACCES EAGAIN EBADF EBADMSG EBUSY
  817.     syn keyword cPosixConstant      ECANCELED ECHILD EDEADLK EEXIST EFAULT
  818.     syn keyword cPosixConstant      EFBIG EINPROGRESS EINTR EINVAL EIO EISDIR
  819.     syn keyword cPosixConstant      EMFILE EMLINK EMSGSIZE ENAMETOOLONG ENFILE ENODEV
  820.     syn keyword cPosixConstant      ENOENT ENOEXEC ENOLCK ENOMEM ENOSPC ENOSYS
  821.     syn keyword cPosixConstant      ENOTDIR ENOTEMPTY ENOTSUP ENOTTY ENXIO EPERM
  822.     syn keyword cPosixConstant      EPIPE EROFS ESPIPE ESRCH ETIMEDOUT EXDEV
  823.     syn cluster cConstant           add=cPosixConstant
  824.   endif
  825.   if exists("c_math")
  826.     " Math.h constants
  827.     syn keyword cMathConstant       M_E M_LOG2E M_LOG10E M_LN2 M_LN10 M_PI M_PI_2 M_PI_4
  828.     syn keyword cMathConstant       M_1_PI M_2_PI M_2_SQRTPI M_SQRT2 M_SQRT1_2
  829.     syn cluster cConstant           add=cMathConstant
  830.   endif
  831. endif
  832.  
  833. if (!exists("c_no_ansi") && exists("c_impl_defined")) || !exists("c_no_names")
  834.   " Highlight compiler implemented reserved macros
  835.   syn match       c89Macro          display "\<_[[:upper:]_]\w*\>"
  836.   syn match       c89Macro          display "\<\(LC_\|SIG_\)\u\w*\>"
  837.   syn cluster     cMacro            add=c89Macro
  838.   if exists("c_vms")
  839.     syn match     cVMSMacro         display "\<_[[:upper:]_]\(\w*\$\)\+\w*\>"
  840.     syn match     cVMSMacro         display "\<\(LC_\|SIG_\)\u\(\w*\$\)\+\w*\>"
  841.     syn cluster   cMacro            add=cVMSMacro
  842.   endif
  843.   if exists("c_C99")
  844.     syn match     c99Macro          display "\<U\=INT\d\+_C\>"
  845.     syn keyword   c99Macro          INTMAX_C UINTMAX_C
  846.     syn match     c99Macro          display "\<E@\(\u\|\d\)\w*\>"
  847.     " printf/scanf format conversion macros
  848.     syn match     c99Macro          display "\(PRI\|SCN\)[diouxX]\(LEAST\|FAST\)\d\+"
  849.     syn match     c99Macro          display "\(PRI\|SCN\)[diouxX]\(MAX\|PTR\)"
  850.     syn cluster   cMacro            add=c99Macro
  851.     syn match     c99MacroError     display "\(PRI\|SCN\)[^diouxX]\(LEAST\|FAST\)\d\+"
  852.     syn match     c99MacroError     display "\(PRI\|SCN\)[^diouxX]\(MAX\|PTR\)"
  853.   endif
  854.   if exists("c_C99_warn")
  855.     " C99 reserved function identifiers!
  856.     syn keyword   c99Function       strcpy strncpy strcat strncat strcmp strcoll strncmp strxfrm
  857.     syn keyword   c99Function       strchr strcspn strpbrk strrchr strspn strstr strtok strerror strlen
  858.     syn keyword   c99Function       strtoimax strtoumax
  859.     syn keyword   c99Function       strtod strtof strtold strtol strtoll strtoul strtoull
  860.     syn keyword   c99Function       memcpy memmove memcmp memchr memset
  861.     syn keyword   c99Function       wcstod wcstof wcstold wcstol wcstoll wcstoull
  862.     syn keyword   c99Function       wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm
  863.     syn keyword   c99Function       wcschr wcscspn wcspbrk wcsrchr wcsspn wcsstr wcstok wcserror wcslen
  864.     syn keyword   c99Function       wcstoimax wcstoumax
  865.     syn keyword   c99Function       tolower toupper
  866.     syn keyword   c99Function       towlower towupper towctrans
  867.     syn keyword   c99Function       isalnum isalpha isblank iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit
  868.     syn keyword   c99Function       isfinite isinf isnan isnormal
  869.     syn keyword   c99Function       isgreater isgreaterequal isless islessequal islessgreater isunordered
  870.     syn keyword   c99Function       iswalnum iswalpha iswblank iswcntrl iswdigit iswgraph iswlower iswprint iswpunct iswspace iswupper iswxdigit
  871.     syn keyword   c99Function       iswctype
  872.     syn cluster   cFunction         add=c99Function
  873.     " Try and catch future Standard library function names.
  874.     syn match     cC99Error         "\<\(str\|mem\|wcs\|to\|is\)\l\w*\>\s*("me=e-1
  875.     syn keyword   cC99Error         cerf cerfc cexp2 cexpm1 clog10 clog1p clog2 clgamme ctgamma
  876.     syn keyword   cC99Error         cerff cerfcf cexp2f cexpm1f clog10f clog1pf clog2f clgammef ctgammaf
  877.     syn keyword   cC99Error         cerfl cerfcl cexp2l cexpm1l clog10l clog1pl clog2l clgammel ctgammal
  878.   endif
  879. endif
  880.  
  881. if exists("c_warn_trigraph")
  882.   " Highlight trigraphs as errors
  883.   "syn match       cTrigraphError    "\?\?[=(/)'<!>-]"
  884.  syn match     cTrigraphError      display "??[=(/)'<!>-]"
  885.   syn cluster   cParenContents      add=cTrigraphError
  886.   syn cluster   cDefineContents     add=cTrigraphError
  887.   syn cluster   cConditionalContents add=cTrigraphError
  888.   syn cluster   cCommentGroup       add=cTrigraphError
  889.   syn cluster   cCommentStringContents add=cTrigraphError
  890.   syn cluster   cStringContents     add=cTrigraphError
  891. endif
  892.  
  893. if exists("c_C94")
  894.   " C94 iso646 macros
  895.   syn keyword   c94Macro            and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq
  896.  
  897.   " Add iso646 errors to appropriate highlight clusters
  898.   syn cluster   cParenContents      add=c94Macro
  899.   syn cluster   cDefineContents     add=c94Macro
  900.   syn cluster   cConditionalContents add=c94Macro
  901. endif
  902.  
  903.  
  904. if exists("c_cpp_warn")
  905.   " C++ reserved words that must not be used if compiling with a C++ compiler
  906.   syn keyword   cCPPError           new delete this throw try catch namespace using public protected private friend
  907.   syn keyword   cCPPError           mutable class template typename virtual explicit operator typeid
  908.   syn match     cCPPError           display "\<\(const\|static\|dynamic\|reinterpret\)_cast\>"
  909.  
  910.   " Add to contained groups
  911.   syn cluster   cParenContents      add=cCPPError
  912.   syn cluster   cDefineContents     add=cCPPError
  913.   syn cluster   cConditionalContents add=cCPPError
  914. endif
  915.  
  916.  
  917. " Highlight re-syncing distance.
  918. if exists("c_minlines")
  919.   let b:c_minlines = c_minlines
  920. else
  921.   let b:c_minlines = 15
  922. endif
  923. exec "syn sync ccomment cComment minlines=" . b:c_minlines
  924.  
  925.  
  926. " Define the default highlighting.
  927. " Only used when an item doesn't have highlighting yet
  928.  
  929. hi def link cEmpty                 Normal
  930. hi def link cTodo                  Todo
  931.  
  932. hi def link cStatement             Statement
  933. hi def link c89Statement           cStatement
  934. if exists("c_c_vim_compatible")
  935.   hi def link cKRStatement         cStatement
  936.   hi def link cKRStorageClass      cStorageClass
  937. else
  938.   hi def link cKRStatement         cError
  939.   hi def link cKRStorageClass      cError
  940. endif
  941. hi def link cLabel                 Label
  942. hi def link cUserLabel             cLabel
  943. hi def link cConditional           Conditional
  944. hi def link cRepeat                Repeat
  945.  
  946. hi def link cOperator              Operator
  947. hi def link cSizeofOperator        cOperator
  948. hi def link cMathOperator          cOperator
  949. hi def link cPointerOperator       cOperator
  950. hi def link cLogicalOperator       cOperator
  951. hi def link cBinaryOperator        cOperator
  952. if exists("c_conditional_is_operator")
  953.   hi def link cConditionalOperator cOperator
  954. else
  955.   hi def link cConditionalOperator cConditional
  956. endif
  957.  
  958. hi def link cType                  Type
  959. hi def link c89Type                cType
  960. hi def link cTypedef               Typedef
  961. hi def link c89Typedef             cTypedef
  962. if exists("c_c_vim_compatible")
  963.   hi def link cVIMTypedef          cTypedef
  964. endif
  965. hi def link cStructure             Structure
  966. hi def link cStructureType         cStructure
  967. hi def link cStorageClass          StorageClass
  968. hi def link c89StorageClass        cStorageClass
  969. hi def link cIdentifier            Identifier
  970. hi def link c89Identifier          cIdentifier
  971. hi def link cEllipses              c89Identifier
  972. hi def link cFunction              Function
  973. hi def link c89Function            cFunction
  974.  
  975. if exists("c_char_is_integer")
  976.   hi def link cCharacter           cInteger
  977. else
  978.   hi def link cCharacter           Character
  979. endif
  980. hi def link cMultiCharacter        cCharacter
  981. hi def link cCharacterNoError      cCharacter
  982. hi def link cSpecialChar           SpecialChar
  983. hi def link cEscapeChar            cSpecialChar
  984. hi def link cOctalChar             cSpecialChar
  985. hi def link cHexChar               cSpecialChar
  986. hi def link cString                String
  987. hi def link cSpecial               cSpecialChar
  988. hi def link cFormat                cSpecial
  989. hi def link cPrintFormat           cFormat
  990. hi def link cScanFormat            cFormat
  991.  
  992. hi def link cNumber                Number
  993. hi def link cInteger               cNumber
  994. hi def link cDecimal               cInteger
  995. hi def link cOctal                 cInteger
  996. hi def link cOctalZero             PreProc
  997. hi def link cHex                   cInteger
  998. hi def link cBoolean               Boolean
  999. hi def link cFloat                 Float
  1000. hi def link c89Float               cFloat
  1001.  
  1002. hi def link cConstant              Constant
  1003. hi def link c89Constant            cConstant
  1004.  
  1005. hi def link cComment               Comment
  1006. hi def link cCommentDelim          cComment
  1007. hi def link cCommentString         cString
  1008. hi def link cComment2String        cString
  1009. hi def link cCommentSkip           cComment
  1010. hi def link cTime                  cNumber
  1011. hi def link cDate                  cString
  1012.  
  1013. hi def link cError                 Error
  1014. hi def link cCharsetError          cError
  1015. hi def link cStatementError        cError
  1016. hi def link cStorageClassError     cError
  1017. hi def link cOperatorError         cError
  1018. hi def link cOctalError            cError
  1019. hi def link cFloatError            cError
  1020. hi def link cParenError            cError
  1021. hi def link cBracketError          cError
  1022. if !exists("c_C99") || exists("c_C99_warn")
  1023.   hi def link cErrBraceInParen     cError
  1024. endif
  1025. hi def link cErrBracketInParen     cError
  1026. hi def link cErrInBracket          cError
  1027. hi def link cCommentStartError     cError
  1028. hi def link cCommentError          cError
  1029. hi def link cTrailSpaceError       cError
  1030. hi def link cMixedSpaceError       cError
  1031. hi def link cCharacterError        cError
  1032. hi def link cEscapeCharError       cError
  1033. hi def link cOctalCharError        cError
  1034. hi def link cHexCharError          cError
  1035. hi def link cLogicalOperatorError  cError
  1036. hi def link cBinaryOperatorError   cError
  1037. hi def link cTrigraphError         cError
  1038. hi def link cFormatError           cError
  1039. hi def link cHexError              cError
  1040. hi def link cEllipsesError         cError
  1041.  
  1042. hi def link cPreProc               PreProc
  1043. hi def link cPPEmptyLine           cPreProc
  1044. hi def link cPPLineJoin            cPreProc
  1045. hi def link cInclude               Include
  1046. hi def link cPPIncludeFile         cString
  1047. hi def link cDefine                Define
  1048. hi def link cUndef                 cDefine
  1049. hi def link cPragma                cPreProc
  1050. hi def link cMacro                 Macro
  1051. hi def link cCMacro                cMacro
  1052. hi def link c89Macro               cMacro
  1053. hi def link cPreCondit             PreCondit
  1054. hi def link cLine                  PreProc
  1055. hi def link cPPLineNumber          cInteger
  1056. hi def link cPPOperator            cOperator
  1057. hi def link cPPTokenOperator       cPPOperator
  1058. hi def link cPPPragmaOperator      cPPOperator
  1059. hi def link cPPOut                 cComment
  1060. hi def link cPPOut2                cPPOut
  1061. hi def link cPPSkip                cPPOut
  1062.  
  1063. hi def link cPPError               cError
  1064. hi def link cPreProcError          cPPError
  1065. hi def link cPPLineNumberError     cPPError
  1066. hi def link cPPSpaceError          cPPError
  1067. hi def link cPPLineJoinError       cPPError
  1068. hi def link cPPWarnError           cPPError
  1069. hi def link cPPPragmaError         cPPError
  1070.  
  1071. if exists("c_vms")
  1072.   hi def link cVMSIdentifier       cIdentifier
  1073.   hi def link cVMSFunction         cFunction
  1074.   hi def link cVMSMacro            cMacro
  1075. endif
  1076.  
  1077. if exists("c_cpp_warn")
  1078.   hi def link cCPPError            cError
  1079. endif
  1080.  
  1081. if exists("c_warn_digraph")
  1082.   hi def link cDigraph             cError
  1083. endif
  1084.  
  1085. if exists("c_C94")
  1086.   if !exists("c_C94_warn")
  1087.     hi def link c94Macro           cMacro
  1088.     hi def link c94Constant        cConstant
  1089.     hi def link c94PrintFormat     cPrintFormat
  1090.     hi def link c94ScanFormat      cScanFormat
  1091.     hi def link c94Typedef         cTypedef
  1092.     hi def link c94PPTokenOperator cPPOperator
  1093.     hi def link c94PPInclude       cInclude
  1094.  
  1095.   else
  1096.     hi def link cC94Error          cError
  1097.     hi def link c94Macro           cC94Error
  1098.     hi def link c94Constant        cC94Error
  1099.     hi def link c94PrintFormat     cC94Error
  1100.     hi def link c94ScanFormat      cC94Error
  1101.     hi def link c94Typedef         cC94Error
  1102.     hi def link c94PPTokenOperator cC94Error
  1103.     hi def link c94PPInclude       cC94Error
  1104.   endif
  1105. endif
  1106.  
  1107. if exists("c_C99")
  1108.   hi def link c99Function          cFunction
  1109.   if !exists("c_C99_warn")
  1110.     hi def link c99Type            cType
  1111.     hi def link c99Typedef         cTypedef
  1112.     hi def link c99StorageClass    cStorageClass
  1113.     hi def link c99Macro           cMacro
  1114.     hi def link c99MacroError      cError
  1115.     hi def link cUniversalChar     cSpecialChar
  1116.     hi def link c99Decimal         cDecimal
  1117.     hi def link c99Hex             cHex
  1118.     hi def link c99OctalError      cOctalError
  1119.     hi def link c99Octal           cOctal
  1120.     hi def link c99Boolean         cBoolean
  1121.     hi def link c99Float           cFloat
  1122.     hi def link c99Constant        cConstant
  1123.     hi def link c99PrintFormat     cPrintFormat
  1124.     hi def link c99ScanFormat      cScanFormat
  1125.     hi def link c99Pragma          cPreProc
  1126.     hi def link c99PPPragmaSTDC    cPreProc
  1127.     hi def link c99PPPragmaOperator cPPOperator
  1128.     hi def link c99PPPragmaError   cPPError
  1129.  
  1130.   else
  1131.     hi def link cC99Error          cError
  1132.     hi def link c99Type            cC99Error
  1133.     hi def link c99Typedef         cC99Error
  1134.     hi def link c99StorageClass    cC99Error
  1135.     hi def link c99Macro           cC99Error
  1136.     hi def link c99MacroError      cC99Error
  1137.     hi def link cUniversalChar     cC99Error
  1138.     hi def link c99Decimal         cC99Error
  1139.     hi def link c99Hex             cC99Error
  1140.     hi def link c99OctalError      cC99Error
  1141.     hi def link c99Octal           cC99Error
  1142.     hi def link c99Boolean         cC99Error
  1143.     hi def link c99Float           cC99Error
  1144.     hi def link c99Constant        cC99Error
  1145.     hi def link c99PrintFormat     cC99Error
  1146.     hi def link c99ScanFormat      cC99Error
  1147.     hi def link c99Pragma          cC99Error
  1148.     hi def link c99PPPragmaSTDC    cC99Error
  1149.     hi def link c99PPPragmaOperator cC99Error
  1150.     hi def link c99PPPragmaError   cC99Error
  1151.   endif
  1152. endif
  1153.  
  1154. if exists("c_c_vim_compatible")
  1155.   if exists("c_gnu")
  1156.     hi def link cGNUType           cType
  1157.     hi def link cGNUStatement      c89Statement
  1158.     hi def link cGNUOperator       cOperator
  1159.     hi def link cGNUStorageClass   cStorageClass
  1160.     hi def link cGNUConstant       cConstant
  1161.   endif
  1162.   if !exists("c_no_utf")
  1163.     hi def link cUniversalChar     cSpecialChar
  1164.   endif
  1165.   hi def link cPosixConstant       cConstant
  1166.   hi def link cMathConstant        cConstant
  1167.  
  1168. else
  1169.   hi def link cGNUError            cError
  1170.   hi def link cGNUStatement        cGNUError
  1171.   hi def link cGNUOperator         cGNUError
  1172.   hi def link cGNUType             cGNUError
  1173.   hi def link cGNUStorageClass     cGNUError
  1174.   hi def link cGNUConstant         cGNUError
  1175. endif
  1176.  
  1177. let b:current_syntax = "c"
  1178.  
  1179. " vim:et:ff=unix:
  1180. " EOF c.vim
  1181.  
  1182.  
Advertisement
Add Comment
Please, Sign In to add comment