Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Renderman shader language |
| 3 | " Maintainer: Dan Piponi <dan@tanelorn.demon.co.uk> |
| 4 | " Last Change: 2001 May 09 |
| 5 | |
| 6 | " For version 5.x: Clear all syntax items |
| 7 | " For version 6.x: Quit when a syntax file was already loaded |
| 8 | if version < 600 |
| 9 | syntax clear |
| 10 | elseif exists("b:current_syntax") |
| 11 | finish |
| 12 | endif |
| 13 | |
| 14 | " A bunch of useful Renderman keywords including special |
| 15 | " RenderMan control structures |
| 16 | syn keyword slStatement break return continue |
| 17 | syn keyword slConditional if else |
| 18 | syn keyword slRepeat while for |
| 19 | syn keyword slRepeat illuminance illuminate solar |
| 20 | |
| 21 | syn keyword slTodo contained TODO FIXME XXX |
| 22 | |
| 23 | " String and Character constants |
| 24 | " Highlight special characters (those which have a backslash) differently |
| 25 | syn match slSpecial contained "\\[0-9][0-9][0-9]\|\\." |
| 26 | syn region slString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=slSpecial |
| 27 | syn match slCharacter "'[^\\]'" |
| 28 | syn match slSpecialCharacter "'\\.'" |
| 29 | syn match slSpecialCharacter "'\\[0-9][0-9]'" |
| 30 | syn match slSpecialCharacter "'\\[0-9][0-9][0-9]'" |
| 31 | |
| 32 | "catch errors caused by wrong parenthesis |
| 33 | syn region slParen transparent start='(' end=')' contains=ALLBUT,slParenError,slIncluded,slSpecial,slTodo,slUserLabel |
| 34 | syn match slParenError ")" |
| 35 | syn match slInParen contained "[{}]" |
| 36 | |
| 37 | "integer number, or floating point number without a dot and with "f". |
| 38 | syn case ignore |
| 39 | syn match slNumber "\<[0-9]\+\(u\=l\=\|lu\|f\)\>" |
| 40 | "floating point number, with dot, optional exponent |
| 41 | syn match slFloat "\<[0-9]\+\.[0-9]*\(e[-+]\=[0-9]\+\)\=[fl]\=\>" |
| 42 | "floating point number, starting with a dot, optional exponent |
| 43 | syn match slFloat "\.[0-9]\+\(e[-+]\=[0-9]\+\)\=[fl]\=\>" |
| 44 | "floating point number, without dot, with exponent |
| 45 | syn match slFloat "\<[0-9]\+e[-+]\=[0-9]\+[fl]\=\>" |
| 46 | "hex number |
| 47 | syn match slNumber "\<0x[0-9a-f]\+\(u\=l\=\|lu\)\>" |
| 48 | "syn match slIdentifier "\<[a-z_][a-z0-9_]*\>" |
| 49 | syn case match |
| 50 | |
| 51 | if exists("sl_comment_strings") |
| 52 | " A comment can contain slString, slCharacter and slNumber. |
| 53 | " But a "*/" inside a slString in a slComment DOES end the comment! So we |
| 54 | " need to use a special type of slString: slCommentString, which also ends on |
| 55 | " "*/", and sees a "*" at the start of the line as comment again. |
| 56 | " Unfortunately this doesn't very well work for // type of comments :-( |
| 57 | syntax match slCommentSkip contained "^\s*\*\($\|\s\+\)" |
| 58 | syntax region slCommentString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=slSpecial,slCommentSkip |
| 59 | syntax region slComment2String contained start=+"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=slSpecial |
| 60 | syntax region slComment start="/\*" end="\*/" contains=slTodo,slCommentString,slCharacter,slNumber |
| 61 | else |
| 62 | syn region slComment start="/\*" end="\*/" contains=slTodo |
| 63 | endif |
| 64 | syntax match slCommentError "\*/" |
| 65 | |
| 66 | syn keyword slOperator sizeof |
| 67 | syn keyword slType float point color string vector normal matrix void |
| 68 | syn keyword slStorageClass varying uniform extern |
| 69 | syn keyword slStorageClass light surface volume displacement transformation imager |
| 70 | syn keyword slVariable Cs Os P dPdu dPdv N Ng u v du dv s t |
| 71 | syn keyword slVariable L Cl Ol E I ncomps time Ci Oi |
| 72 | syn keyword slVariable Ps alpha |
| 73 | syn keyword slVariable dtime dPdtime |
| 74 | |
| 75 | syn sync ccomment slComment minlines=10 |
| 76 | |
| 77 | " Define the default highlighting. |
| 78 | " For version 5.7 and earlier: only when not done already |
| 79 | " For version 5.8 and later: only when an item doesn't have highlighting yet |
| 80 | if version >= 508 || !exists("did_sl_syntax_inits") |
| 81 | if version < 508 |
| 82 | let did_sl_syntax_inits = 1 |
| 83 | command -nargs=+ HiLink hi link <args> |
| 84 | else |
| 85 | command -nargs=+ HiLink hi def link <args> |
| 86 | endif |
| 87 | |
| 88 | HiLink slLabel Label |
| 89 | HiLink slUserLabel Label |
| 90 | HiLink slConditional Conditional |
| 91 | HiLink slRepeat Repeat |
| 92 | HiLink slCharacter Character |
| 93 | HiLink slSpecialCharacter slSpecial |
| 94 | HiLink slNumber Number |
| 95 | HiLink slFloat Float |
| 96 | HiLink slParenError slError |
| 97 | HiLink slInParen slError |
| 98 | HiLink slCommentError slError |
| 99 | HiLink slOperator Operator |
| 100 | HiLink slStorageClass StorageClass |
| 101 | HiLink slError Error |
| 102 | HiLink slStatement Statement |
| 103 | HiLink slType Type |
| 104 | HiLink slCommentError slError |
| 105 | HiLink slCommentString slString |
| 106 | HiLink slComment2String slString |
| 107 | HiLink slCommentSkip slComment |
| 108 | HiLink slString String |
| 109 | HiLink slComment Comment |
| 110 | HiLink slSpecial SpecialChar |
| 111 | HiLink slTodo Todo |
| 112 | HiLink slVariable Identifier |
| 113 | "HiLink slIdentifier Identifier |
| 114 | |
| 115 | delcommand HiLink |
| 116 | endif |
| 117 | |
| 118 | let b:current_syntax = "sl" |
| 119 | |
| 120 | " vim: ts=8 |