Mercurial > vim
comparison runtime/syntax/c.vim @ 2965:f2de38a019a2
Updated runtime files.
Add missing test82 files.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Mon, 18 Jul 2011 19:40:27 +0200 |
parents | c08f91142c41 |
children | 3502a7f991fc |
comparison
equal
deleted
inserted
replaced
2964:39cb812cf477 | 2965:f2de38a019a2 |
---|---|
1 " Vim syntax file | 1 " Vim syntax file |
2 " Language: C | 2 " Language: C |
3 " Maintainer: Bram Moolenaar <Bram@vim.org> | 3 " Maintainer: Bram Moolenaar <Bram@vim.org> |
4 " Last Change: 2009 Nov 17 | 4 " Last Change: 2011 May 2 |
5 | 5 |
6 " Quit when a (custom) syntax file was already loaded | 6 " Quit when a (custom) syntax file was already loaded |
7 if exists("b:current_syntax") | 7 if exists("b:current_syntax") |
8 finish | 8 finish |
9 endif | 9 endif |
70 endif | 70 endif |
71 | 71 |
72 " This should be before cErrInParen to avoid problems with #define ({ xxx }) | 72 " This should be before cErrInParen to avoid problems with #define ({ xxx }) |
73 if exists("c_curly_error") | 73 if exists("c_curly_error") |
74 syntax match cCurlyError "}" | 74 syntax match cCurlyError "}" |
75 syntax region cBlock start="{" end="}" contains=ALLBUT,cCurlyError,@cParenGroup,cErrInParen,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell fold | 75 syntax region cBlock start="{" end="}" contains=ALLBUT,cBadBlock,cCurlyError,@cParenGroup,cErrInParen,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell fold |
76 else | 76 else |
77 syntax region cBlock start="{" end="}" transparent fold | 77 syntax region cBlock start="{" end="}" transparent fold |
78 endif | 78 endif |
79 | 79 |
80 "catch errors caused by wrong parenthesis and brackets | 80 "catch errors caused by wrong parenthesis and brackets |
81 " also accept <% for {, %> for }, <: for [ and :> for ] (C99) | 81 " also accept <% for {, %> for }, <: for [ and :> for ] (C99) |
82 " But avoid matching <::. | 82 " But avoid matching <::. |
83 syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom | 83 syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom |
84 if exists("c_no_curly_error") | 84 if exists("c_no_curly_error") |
85 syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell | 85 syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cCppString,@Spell |
86 " cCppParen: same as cParen but ends at end-of-line; used in cDefine | 86 " cCppParen: same as cParen but ends at end-of-line; used in cDefine |
87 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell | 87 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell |
88 syn match cParenError display ")" | 88 syn match cParenError display ")" |
89 syn match cErrInParen display contained "^[{}]\|^<%\|^%>" | 89 syn match cErrInParen display contained "^[{}]\|^<%\|^%>" |
90 elseif exists("c_no_bracket_error") | 90 elseif exists("c_no_bracket_error") |
91 syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell | 91 syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cCppString,@Spell |
92 " cCppParen: same as cParen but ends at end-of-line; used in cDefine | 92 " cCppParen: same as cParen but ends at end-of-line; used in cDefine |
93 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell | 93 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell |
94 syn match cParenError display ")" | 94 syn match cParenError display ")" |
95 syn match cErrInParen display contained "[{}]\|<%\|%>" | 95 syn match cErrInParen display contained "[{}]\|<%\|%>" |
96 else | 96 else |
97 syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell | 97 syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell |
98 " cCppParen: same as cParen but ends at end-of-line; used in cDefine | 98 " cCppParen: same as cParen but ends at end-of-line; used in cDefine |
99 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell | 99 syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell |
100 syn match cParenError display "[\])]" | 100 syn match cParenError display "[\])]" |
101 syn match cErrInParen display contained "[\]{}]\|<%\|%>" | 101 syn match cErrInParen display contained "[\]{}]\|<%\|%>" |
102 syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' contains=ALLBUT,@cParenGroup,cErrInParen,cCppParen,cCppBracket,cCppString,@Spell | 102 syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cErrInParen,cCppParen,cCppBracket,cCppString,@Spell |
103 " cCppBracket: same as cParen but ends at end-of-line; used in cDefine | 103 " cCppBracket: same as cParen but ends at end-of-line; used in cDefine |
104 syn region cCppBracket transparent start='\[\|<::\@!' skip='\\$' excludenl end=']\|:>' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString,@Spell | 104 syn region cCppBracket transparent start='\[\|<::\@!' skip='\\$' excludenl end=']\|:>' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString,@Spell |
105 syn match cErrInBracket display contained "[);{}]\|<%\|%>" | 105 syn match cErrInBracket display contained "[);{}]\|<%\|%>" |
106 endif | 106 endif |
107 | |
108 syntax region cBadBlock keepend extend start="{" end="}" contained containedin=cParen,cBracket,cBadBlock transparent fold | |
107 | 109 |
108 "integer number, or floating point number without a dot and with "f". | 110 "integer number, or floating point number without a dot and with "f". |
109 syn case ignore | 111 syn case ignore |
110 syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctalError,cOctal | 112 syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctalError,cOctal |
111 " Same, but without octal error (for comments) | 113 " Same, but without octal error (for comments) |
268 if !exists("c_no_c99") " ISO C99 | 270 if !exists("c_no_c99") " ISO C99 |
269 syn keyword cConstant true false | 271 syn keyword cConstant true false |
270 endif | 272 endif |
271 | 273 |
272 " Accept %: for # (C99) | 274 " Accept %: for # (C99) |
273 syn region cPreCondit start="^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError | 275 syn region cPreCondit start="^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError |
274 syn match cPreCondit display "^\s*\(%:\|#\)\s*\(else\|endif\)\>" | 276 syn match cPreConditMatch display "^\s*\(%:\|#\)\s*\(else\|endif\|elif\)\>" |
275 if !exists("c_no_if0") | 277 if !exists("c_no_if0") |
278 syn cluster cCppOutInGroup contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip | |
279 syn region cCppOutWrapper start="^\s*\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse | |
280 syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse | |
276 if !exists("c_no_if0_fold") | 281 if !exists("c_no_if0_fold") |
277 syn region cCppOut start="^\s*\(%:\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=cCppOut2 fold | 282 syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip |
278 else | 283 else |
279 syn region cCppOut start="^\s*\(%:\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=cCppOut2 | 284 syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip fold |
280 endif | 285 endif |
281 syn region cCppOut2 contained start="0" end="^\s*\(%:\|#\)\s*\(endif\>\|else\>\|elif\>\)" contains=cSpaceError,cCppSkip | 286 syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit |
282 syn region cCppSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppSkip | 287 syn region cCppInWrapper start="^\s*\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse |
288 syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit | |
289 if !exists("c_no_if0_fold") | |
290 syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold | |
291 else | |
292 syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 | |
293 endif | |
294 syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip | |
295 syn region cCppOutSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip | |
296 syn region cCppInSkip contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(if\s\+\(\d\+\s*\($\|//\|/\*\||\|&\)\)\@!\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" containedin=cCppOutElse,cCppInIf,cCppInSkip contains=TOP,cPreProc | |
283 endif | 297 endif |
284 syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ | 298 syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ |
285 syn match cIncluded display contained "<[^>]*>" | 299 syn match cIncluded display contained "<[^>]*>" |
286 syn match cInclude display "^\s*\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded | 300 syn match cInclude display "^\s*\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded |
287 "syn match cLineSkip "\\$" | 301 "syn match cLineSkip "\\$" |
288 syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti | 302 syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti |
289 syn region cDefine start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell | 303 syn region cDefine start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell |
290 syn region cPreProc start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell | 304 syn region cPreProc start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell |
291 | 305 |
292 " Highlight User Labels | 306 " Highlight User Labels |
293 syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString | 307 syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString |
294 syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell | 308 syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell |
295 " Avoid matching foo::bar() in C++ by requiring that the next char is not ':' | 309 " Avoid matching foo::bar() in C++ by requiring that the next char is not ':' |
296 syn cluster cLabelGroup contains=cUserLabel | 310 syn cluster cLabelGroup contains=cUserLabel |
297 syn match cUserCont display "^\s*\I\i*\s*:$" contains=@cLabelGroup | 311 syn match cUserCont display "^\s*\I\i*\s*:$" contains=@cLabelGroup |
298 syn match cUserCont display ";\s*\I\i*\s*:$" contains=@cLabelGroup | 312 syn match cUserCont display ";\s*\I\i*\s*:$" contains=@cLabelGroup |
352 hi def link cPreProc PreProc | 366 hi def link cPreProc PreProc |
353 hi def link cDefine Macro | 367 hi def link cDefine Macro |
354 hi def link cIncluded cString | 368 hi def link cIncluded cString |
355 hi def link cError Error | 369 hi def link cError Error |
356 hi def link cStatement Statement | 370 hi def link cStatement Statement |
371 hi def link cCppInWrapper cCppOutWrapper | |
372 hi def link cCppOutWrapper cPreCondit | |
373 hi def link cPreConditMatch cPreCondit | |
357 hi def link cPreCondit PreCondit | 374 hi def link cPreCondit PreCondit |
358 hi def link cType Type | 375 hi def link cType Type |
359 hi def link cConstant Constant | 376 hi def link cConstant Constant |
360 hi def link cCommentString cString | 377 hi def link cCommentString cString |
361 hi def link cComment2String cString | 378 hi def link cComment2String cString |
363 hi def link cString String | 380 hi def link cString String |
364 hi def link cComment Comment | 381 hi def link cComment Comment |
365 hi def link cSpecial SpecialChar | 382 hi def link cSpecial SpecialChar |
366 hi def link cTodo Todo | 383 hi def link cTodo Todo |
367 hi def link cBadContinuation Error | 384 hi def link cBadContinuation Error |
368 hi def link cCppSkip cCppOut | 385 hi def link cCppOutSkip cCppOutIf2 |
369 hi def link cCppOut2 cCppOut | 386 hi def link cCppInElse2 cCppOutIf2 |
387 hi def link cCppOutIf2 cCppOut2 " Old syntax group for #if 0 body | |
388 hi def link cCppOut2 cCppOut " Old syntax group for #if of #if 0 | |
370 hi def link cCppOut Comment | 389 hi def link cCppOut Comment |
371 | 390 |
372 let b:current_syntax = "c" | 391 let b:current_syntax = "c" |
373 | 392 |
374 " vim: ts=8 | 393 " vim: ts=8 |