" Java syntax file
" Language:	Java
" Maintainer:	Claudio Fleiner <fleiner@acm.org> (orig: Jim Mitchell)
" Last change:	1997 May 27

" Remove any old syntax stuff hanging around
syntax clear

" keyword definitions
syntax keyword javaExternal       import native
syntax keyword javaError          cast const future generic goto inner outer rest
syntax keyword javaError          var byvalue operator
syntax keyword javaBranch         break continue
syntax keyword javaLabel          case default
syntax keyword javaConditional    if else switch
syntax keyword javaRepeat         while for do finally
syntax keyword javaBoolValue      true false
syntax keyword javaType           null this super
"syntax keyword javaOperator       ++ -- + - ~ ! * / % << >> >>> > < >= <=
syntax keyword javaOperator       new instanceof "== != & ^ | && || 
"syntax keyword javaOperator       = *= /= %= += -= <<= >>= >>>= &= ^= |=
syntax keyword javaType           boolean char byte short int long float double
syntax keyword javaType           void
syntax keyword javaStatement      return
syntax keyword javaStorageClass   static synchronized transient volatile final
syntax keyword javaExceptions     throw try catch
syntax keyword javaMethodDecl     synchronized throws
syntax keyword javaClassDecl      abstract extends class implements interface
syntax keyword javaScopeDecl      public protected private package

"catch errors caused by wrong parenthesis
syntax region	javaParen		transparent start='(' end=')' contains ALLBUT javaParenError 
syntax match	javaParenError		")"
syntax match 	javaInParen		contained "[{}]"
highlight link  javaParenError javaError
highlight link  javaInParen javaError

" Strings and constants
syntax match   javaSpecial           contained "\\[0-9][0-9][0-9]\|\\."
syntax region  javaString            start=+"+  skip=+\\\\\|\\"+  end=+"+  contains javaSpecial
syntax match   javaCharacter         "'[^\\]'"
syntax match   javaSpecialCharacter  "'\\.'"
syntax match   javaNumber          "-\=\<[0-9]\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
syntax match   javaCommentSkip     contained "^[ 	]*\*\($\|[ 	]\+\)"
syntax region  javaCommentString   contained start=+"+  skip=+\\\\\|\\"+  end=+"+ end=+\*/+S-1s-1 contains javaSpecial javaCommentSkip
syntax region  javaComment2String  contained start=+"+  skip=+\\\\\|\\"+  end=+$\|"+  contains javaSpecial
syntax region  javaComment         start="/\*"  end="\*/" contains javaCommentString javaCharacter javaNumber
syntax match   javaLineComment     "//.*" contains javaComment2String javaCharacter javaNumber 

syntax sync ccomment javaComment

" WARNING: the folloing definitions work only if you use one tab or two spaces
" to indent function. If you use something different, change the leading
" white space in all definitions.
syntax match javaFuncDef "^\t[a-zA-Z][a-zA-Z0-9_. \[\]]*([^-+*/()]*)"
syntax region javaFuncDef start=+^\t[a-zA-Z][a-zA-Z0-9_. \[\]]*([^-+*/()]*,[ 	]*+ end=+)+
syntax match javaFuncDef "^  [a-zA-Z][a-zA-Z0-9_. \[\]]*([^-+*/()]*)"
syntax region javaFuncDef start=+^  [a-zA-Z][a-zA-Z0-9_. \[\]]*([^-+*/()]*,[ 	]*+ end=+)+
syntax match javaBraces  "[{}]"

if !exists("did_java_syntax_inits")
  let did_java_syntax_inits = 1
  " The default methods for highlighting.  Can be overridden later
  highlight link javaFuncDef Function
  highlight link javaBraces Function
  highlight link javaBranch	javaStatement
  highlight link javaLabel	Label
  highlight link javaConditional	Conditional
  highlight link javaRepeat 	Repeat
  highlight link javaStructure 	Structure
  highlight link javaExceptions Keyword
  highlight link javaStorageClass	StorageClass
  highlight link javaMethodDecl javaDeclarative
  highlight link javaClassDecl 	javaDeclarative
  highlight link javaScopeDecl 	javaDeclarative
  highlight link javaBoolValue 	Boolean
  highlight link javaSpecial 	Special
  highlight link javaString 	String
  highlight link javaCharacter	Character
  highlight link javaSpecialCharacter	javaSpecial
  highlight link javaNumber 	javaValue
  highlight link javaError	Error
  highlight link javaStatement	Statement
  highlight link javaOperator	Statement
  highlight link javaComment	Comment
  highlight link javaLineComment	Comment
  highlight link javaType	Type
  highlight link javaValue	Number
  highlight link javaExternal	Include
  highlight link javaDeclarative	Typedef
endif
