home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 February / OpenLinux 2.3 CD.iso / live / usr / share / vim / syntax / pike.vim < prev    next >
Encoding:
Text File  |  1999-08-10  |  6.2 KB  |  141 lines

  1. " Vim syntax file
  2. " Language:    Pike
  3. " Maintainer:    Francesco Chemolli <kinkie@kame.usr.dsi.unimi.it>
  4. " Last change:    1998 Feb 16
  5.  
  6. " Remove any old syntax stuff hanging around
  7. syn clear
  8.  
  9. " A bunch of useful C keywords
  10. syn keyword pikeStatement    goto break return continue
  11. syn keyword pikeLabel        case default
  12. syn keyword pikeConditional    if else switch
  13. syn keyword pikeRepeat        while for foreach do
  14. syn keyword pikeStatement    gauge destruct lambda inherit import typeof
  15. syn keyword pikeException    catch
  16. syn keyword pikeType        inline nomask private protected public static
  17.  
  18.  
  19. syn keyword pikeTodo contained    TODO FIXME XXX
  20.  
  21. " String and Character constants
  22. " Highlight special characters (those which have a backslash) differently
  23. syn match pikeSpecial contained    "\\[0-7][0-7][0-7]\=\|\\."
  24. syn region pikeString        start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=pikeSpecial
  25. syn match pikeCharacter        "'[^\\]'"
  26. syn match pikeSpecialCharacter    "'\\.'"
  27. syn match pikeSpecialCharacter    "'\\[0-7][0-7]'"
  28. syn match pikeSpecialCharacter    "'\\[0-7][0-7][0-7]'"
  29.  
  30. " Compound data types
  31. syn region pikeCompoundType start='({' contains=pikeString,pikeCompoundType,pikeNumber,pikeFloat end='})'
  32. syn region pikeCompoundType start='(\[' contains=pikeString,pikeCompoundType,pikeNumber,pikeFloat end='\])'
  33. syn region pikeCompoundType start='(<' contains=pikeString,pikeCompoundType,pikeNumber,pikeFloat end='>)'
  34.  
  35. "catch errors caused by wrong parenthesis
  36. syn region pikeParen        transparent start='([^{[<(]' end=')' contains=ALLBUT,pikeParenError,pikeIncluded,pikeSpecial,pikeTodo,pikeUserLabel,pikeBitField
  37. syn match pikeParenError        ")"
  38. syn match pikeInParen contained    "[^(][{}][^)]"
  39.  
  40. "integer number, or floating point number without a dot and with "f".
  41. syn case ignore
  42. syn match pikeNumber        "\<\d\+\(u\=l\=\|lu\|f\)\>"
  43. "floating point number, with dot, optional exponent
  44. syn match pikeFloat        "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"
  45. "floating point number, starting with a dot, optional exponent
  46. syn match pikeFloat        "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
  47. "floating point number, without dot, with exponent
  48. syn match pikeFloat        "\<\d\+e[-+]\=\d\+[fl]\=\>"
  49. "hex number
  50. syn match pikeNumber        "\<0x[0-9a-f]\+\(u\=l\=\|lu\)\>"
  51. "syn match pikeIdentifier    "\<[a-z_][a-z0-9_]*\>"
  52. syn case match
  53. " flag an octal number with wrong digits
  54. syn match pikeOctalError        "\<0[0-7]*[89]"
  55.  
  56. if exists("c_comment_strings")
  57.   " A comment can contain pikeString, pikeCharacter and pikeNumber.
  58.   " But a "*/" inside a pikeString in a pikeComment DOES end the comment!  So we
  59.   " need to use a special type of pikeString: pikeCommentString, which also ends on
  60.   " "*/", and sees a "*" at the start of the line as comment again.
  61.   " Unfortunately this doesn't very well work for // type of comments :-(
  62.   syntax match pikeCommentSkip    contained "^\s*\*\($\|\s\+\)"
  63.   syntax region pikeCommentString    contained start=+"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=pikeSpecial,pikeCommentSkip
  64.   syntax region pikeComment2String    contained start=+"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=pikeSpecial
  65.   syntax region pikeComment    start="/\*" end="\*/" contains=pikeTodo,pikeCommentString,pikeCharacter,pikeNumber,pikeFloat
  66.   syntax match  pikeComment    "//.*" contains=pikeTodo,pikeComment2String,pikeCharacter,pikeNumber
  67.   syntax match  pikeComment    "#\!.*" contains=pikeTodo,pikeComment2String,pikeCharacter,pikeNumber
  68. else
  69.   syn region pikeComment        start="/\*" end="\*/" contains=pikeTodo
  70.   syn match pikeComment        "//.*" contains=pikeTodo
  71.   syn match pikeComment        "#!.*" contains=pikeTodo
  72. endif
  73. syntax match pikeCommentError    "\*/"
  74.  
  75. syn keyword pikeOperator    sizeof
  76. syn keyword pikeType        int string void float mapping array multiset mixed
  77. syn keyword pikeType        program object function
  78.  
  79. syn region pikePreCondit    start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=pikeComment,pikeString,pikeCharacter,pikeNumber,pikeCommentError
  80. syn region pikeIncluded contained start=+"+ skip=+\\\\\|\\"+ end=+"+
  81. syn match pikeIncluded contained "<[^>]*>"
  82. syn match pikeInclude        "^\s*#\s*include\>\s*["<]" contains=pikeIncluded
  83. "syn match pikeLineSkip    "\\$"
  84. syn region pikeDefine        start="^\s*#\s*\(define\>\|undef\>\)" skip="\\$" end="$" contains=ALLBUT,pikePreCondit,pikeIncluded,pikeInclude,pikeDefine,pikeInParen
  85. syn region pikePreProc        start="^\s*#\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" contains=ALLBUT,pikePreCondit,pikeIncluded,pikeInclude,pikeDefine,pikeInParen
  86.  
  87. " Highlight User Labels
  88. syn region    pikeMulti        transparent start='?' end=':' contains=ALLBUT,pikeIncluded,pikeSpecial,pikeTodo,pikeUserLabel,pikeBitField
  89. " Avoid matching foo::bar() in C++ by requiring that the next char is not ':'
  90. syn match    pikeUserLabel    "^\s*\I\i*\s*:$"
  91. syn match    pikeUserLabel    ";\s*\I\i*\s*:$"ms=s+1
  92. syn match    pikeUserLabel    "^\s*\I\i*\s*:[^:]"me=e-1
  93. syn match    pikeUserLabel    ";\s*\I\i*\s*:[^:]"ms=s+1,me=e-1
  94.  
  95. " Avoid recognizing most bitfields as labels
  96. syn match    pikeBitField    "^\s*\I\i*\s*:\s*[1-9]"me=e-1
  97. syn match    pikeBitField    ";\s*\I\i*\s*:\s*[1-9]"me=e-1
  98.  
  99. syn sync ccomment pikeComment minlines=10
  100.  
  101. if !exists("did_pike_syntax_inits")
  102.   let did_pike_syntax_inits = 1
  103.   " The default methods for highlighting.  Can be overridden later
  104.   hi link pikeLabel    Label
  105.   hi link pikeUserLabel    Label
  106.   hi link pikeConditional    Conditional
  107.   hi link pikeRepeat    Repeat
  108.   hi link pikeCharacter    Character
  109.   hi link pikeSpecialCharacter pikeSpecial
  110.   hi link pikeNumber    Number
  111.   hi link pikeFloat    Float
  112.   hi link pikeOctalError    pikeError
  113.   hi link pikeParenError    pikeError
  114.   hi link pikeInParen    pikeError
  115.   hi link pikeCommentError    pikeError
  116.   hi link pikeOperator    Operator
  117.   hi link pikeInclude    Include
  118.   hi link pikePreProc    PreProc
  119.   hi link pikeDefine    Macro
  120.   hi link pikeIncluded    pikeString
  121.   hi link pikeError    Error
  122.   hi link pikeStatement    Statement
  123.   hi link pikePreCondit    PreCondit
  124.   hi link pikeType        Type
  125.   hi link pikeCommentError    pikeError
  126.   hi link pikeCommentString pikeString
  127.   hi link pikeComment2String pikeString
  128.   hi link pikeCommentSkip    pikeComment
  129.   hi link pikeString    String
  130.   hi link pikeComment    Comment
  131.   hi link pikeSpecial    SpecialChar
  132.   hi link pikeTodo        Todo
  133.   hi link pikeException    pikeStatement
  134.   hi link pikeCompoundType    Constant
  135.   "hi link pikeIdentifier    Identifier
  136. endif
  137.  
  138. let b:current_syntax = "pike"
  139.  
  140. " vim: ts=8
  141.