" Vim syntax file
" Language:	C
" Maintainer:	Bram Moolenaar <mool@oce.nl>
" Last change:	1997 April 20

" Remove any old syntax stuff hanging around
syntax clear

" A bunch of useful C keywords
syntax keyword cStatement	goto break return continue entry asm
syntax keyword cLabel		case default
syntax keyword cConditional	if else switch
syntax keyword cRepeat		while for do

syntax keyword cTodo contained	TODO

" String and Character contstants
" Highlight special characters (those which have a backslash) differently
syntax match   cSpecial contained "\\[0-9][0-9][0-9]\|\\."
syntax region  cString		  start=+"+  skip=+\\\\\|\\"+  end=+"+  contains cSpecial
syntax match   cCharacter	  "'[^\\]'"
syntax match   cSpecialCharacter  "'\\.'"

"catch errors caused by wrong parenthesis
syntax region	cParen		transparent start='(' end=')' contains ALLBUT cParenError cIncluded cSpecial cTodo
syntax match	cParenError	")"
syntax match 	cInParen	contained "[{}]"
highlight link cParenError cError
highlight link cInParen cError

"integer number, or floating point number without a dot and with "f".
syntax case ignore
syntax match  cNumber		"\<[0-9]\+\(u\=l\=\|lu\|f\)\>"
"floating point number, with dot, optional exponent
syntax match  cFloat		"\<[0-9]\+\.[0-9]*\(e[-+]\=[0-9]\+\)\=[fl]\=\>"
"floating point number, starting with a dot, optional exponent
syntax match  cFloat		"\.[0-9]\+\(e[-+]\=[0-9]\+\)\=[fl]\=\>"
"floating point number, without dot, with exponent
syntax match  cFloat		"\<[0-9]\+e[-+]\=[0-9]\+[fl]\=\>"
"hex number
syntax match  cNumber		"0x[0-9a-f]\+\(u\=l\=\|lu\)\>"
"syntax match  cIdentifier	"\<[a-z_][a-z0-9_]*\>"
syntax case match

syntax region cComment		start="/\*"  end="\*/" contains cTodo
syntax match  cComment		"//.*" contains cTodo
syntax match  cCommentError	"\*/"

syntax keyword cOperator	sizeof
syntax keyword cType		int long short char void size_t
syntax keyword cType		signed unsigned float double
syntax keyword cStructure	struct union enum typedef
syntax keyword cStorageClass	static register auto volatile extern const

syntax region cPreCondit	start="^#[ \t]*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)"  skip="\\$"  end="$" contains cComment cString cCharacter cNumber cCommentError
syntax region cIncluded contained start=+"+  skip=+\\\\\|\\"+  end=+"+
syntax match  cIncluded contained "<[^>]*>"
syntax match  cInclude		"^#[ \t]*include\>[ \t]*["<]" contains cIncluded
"syntax match  cLineSkip	"\\$"
syntax region cDefine		start="^#[ \t]*\(define\>\|undef\>\)" skip="\\$" end="$" contains ALLBUT cPreCondit cIncluded cInclude cDefine cInParen
syntax region cPreProc		start="^#[ \t]*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" contains ALLBUT cPreCondit cIncluded cInclude cDefine cInParen

syntax sync ccomment cComment minlines=10

if !exists("did_c_syntax_inits")
  let did_c_syntax_inits = 1
  " The default methods for highlighting.  Can be overridden later
  highlight link cLabel		Label
  highlight link cConditional	Conditional
  highlight link cRepeat	Repeat
  highlight link cCharacter	Character
  highlight link cSpecialCharacter cSpecial
  highlight link cNumber	Number
  highlight link cFloat		Float
  highlight link cCommentError	cError
  highlight link cOperator	Operator
  highlight link cStructure	Structure
  highlight link cStorageClass	StorageClass
  highlight link cInclude	Include
  highlight link cPreProc	PreProc
  highlight link cDefine	Macro
  highlight link cIncluded	cString
  highlight link cError		Error
  highlight link cStatement	Statement
  highlight link cPreCondit	PreCondit
  highlight link cType		Type
  highlight link cString	String
  highlight link cComment	Comment
  highlight link cSpecial	Special
  highlight link cTodo		Todo
  "highlight link cIdentifier	Identifier
endif
