1" Vim syntax file 2" Language: MOO 3" Maintainer: Timo Frenay <timo@frenay.net> 4" Last Change: 2020 Oct 19 5" Note: Requires Vim 6.0 or above 6 7" quit when a syntax file was already loaded 8if exists("b:current_syntax") 9 finish 10endif 11 12" Initializations 13syn case ignore 14 15" C-style comments 16syn match mooUncommentedError display ~\*/~ 17syn match mooCStyleCommentError display ~/\ze\*~ contained 18syn region mooCStyleComment matchgroup=mooComment start=~/\*~ end=~\*/~ contains=mooCStyleCommentError 19 20" Statements 21if exists("moo_extended_cstyle_comments") 22 syn match mooIdentifier display ~\%(\%(/\*.\{-}\*/\s*\)*\)\@>\<\h\w*\>~ contained transparent contains=mooCStyleComment,@mooKeyword,mooType,mooVariable 23else 24 syn match mooIdentifier display ~\<\h\w*\>~ contained transparent contains=@mooKeyword,mooType,mooVariable 25endif 26syn keyword mooStatement break continue else elseif endfor endfork endif endtry endwhile finally for if try 27syn keyword mooStatement except fork while nextgroup=mooIdentifier skipwhite 28syn keyword mooStatement return nextgroup=mooString skipwhite 29 30" Operators 31syn keyword mooOperatorIn in 32 33" Error constants 34syn keyword mooAny ANY 35syn keyword mooErrorConstant E_ARGS E_INVARG E_DIV E_FLOAT E_INVIND E_MAXREC E_NACC E_NONE E_PERM E_PROPNF E_QUOTA E_RANGE E_RECMOVE E_TYPE E_VARNF E_VERBNF 36 37" Builtin variables 38syn match mooType display ~\<\%(ERR\|FLOAT\|INT\|LIST\|NUM\|OBJ\|STR\)\>~ 39syn match mooVariable display ~\<\%(args\%(tr\)\=\|caller\|dobj\%(str\)\=\|iobj\%(str\)\=\|player\|prepstr\|this\|verb\)\>~ 40 41" Strings 42syn match mooStringError display ~[^\t -[\]-~]~ contained 43syn match mooStringSpecialChar display ~\\["\\]~ contained 44if !exists("moo_no_regexp") 45 " Regular expressions 46 syn match mooRegexp display ~%%~ contained containedin=mooString,mooRegexpParentheses transparent contains=NONE 47 syn region mooRegexpParentheses display matchgroup=mooRegexpOr start=~%(~ skip=~%%~ end=~%)~ contained containedin=mooString,mooRegexpParentheses transparent oneline 48 syn match mooRegexpOr display ~%|~ contained containedin=mooString,mooRegexpParentheses 49endif 50if !exists("moo_no_pronoun_sub") 51 " Pronoun substitutions 52 syn match mooPronounSub display ~%%~ contained containedin=mooString transparent contains=NONE 53 syn match mooPronounSub display ~%[#dilnopqrst]~ contained containedin=mooString 54 syn match mooPronounSub display ~%\[#[dilnt]\]~ contained containedin=mooString 55 syn match mooPronounSub display ~%(\h\w*)~ contained containedin=mooString 56 syn match mooPronounSub display ~%\[[dilnt]\h\w*\]~ contained containedin=mooString 57 syn match mooPronounSub display ~%<\%([dilnt]:\)\=\a\+>~ contained containedin=mooString 58endif 59if exists("moo_unmatched_quotes") 60 syn region mooString matchgroup=mooStringError start=~"~ end=~$~ contains=@mooStringContents keepend 61 syn region mooString start=~"~ skip=~\\.~ end=~"~ contains=@mooStringContents oneline keepend 62else 63 syn region mooString start=~"~ skip=~\\.~ end=~"\|$~ contains=@mooStringContents keepend 64endif 65 66" Numbers and object numbers 67syn match mooNumber display ~\%(\%(\<\d\+\)\=\.\d\+\|\<\d\+\)\%(e[+\-]\=\d\+\)\=\>~ 68syn match mooObject display ~#-\=\d\+\>~ 69 70" Properties and verbs 71if exists("moo_builtin_properties") 72 "Builtin properties 73 syn keyword mooBuiltinProperty contents f location name owner programmer r w wizard contained containedin=mooPropRef 74endif 75if exists("moo_extended_cstyle_comments") 76 syn match mooPropRef display ~\.\s*\%(\%(/\*.\{-}\*/\s*\)*\)\@>\h\w*\>~ transparent contains=mooCStyleComment,@mooKeyword 77 syn match mooVerbRef display ~:\s*\%(\%(/\*.\{-}\*/\s*\)*\)\@>\h\w*\>~ transparent contains=mooCStyleComment,@mooKeyword 78else 79 syn match mooPropRef display ~\.\s*\h\w*\>~ transparent contains=@mooKeyword 80 syn match mooVerbRef display ~:\s*\h\w*\>~ transparent contains=@mooKeyword 81endif 82 83" Builtin functions, core properties and core verbs 84if exists("moo_extended_cstyle_comments") 85 syn match mooBuiltinFunction display ~\<\h\w*\s*\%(\%(/\*.\{-}\*/\s*\)*\)\@>\ze(~ contains=mooCStyleComment 86 syn match mooCorePropOrVerb display ~\$\s*\%(\%(/\*.\{-}\*/\s*\)*\)\@>\%(in\>\)\@!\h\w*\>~ contains=mooCStyleComment,@mooKeyword 87else 88 syn match mooBuiltinFunction display ~\<\h\w*\s*\ze(~ contains=NONE 89 syn match mooCorePropOrVerb display ~\$\s*\%(in\>\)\@!\h\w*\>~ contains=@mooKeyword 90endif 91if exists("moo_unknown_builtin_functions") 92 syn match mooUnknownBuiltinFunction ~\<\h\w*\>~ contained containedin=mooBuiltinFunction contains=mooKnownBuiltinFunction 93 " Known builtin functions as of version 1.8.1 of the server 94 " Add your own extensions to this group if you like 95 syn keyword mooKnownBuiltinFunction abs acos add_property add_verb asin atan binary_hash boot_player buffered_output_length callers caller_perms call_function ceil children chparent clear_property connected_players connected_seconds connection_name connection_option connection_options cos cosh create crypt ctime db_disk_size decode_binary delete_property delete_verb disassemble dump_database encode_binary equal eval exp floatstr floor flush_input force_input function_info idle_seconds index is_clear_property is_member is_player kill_task length listappend listdelete listen listeners listinsert listset log log10 match max max_object memory_usage min move notify object_bytes open_network_connection output_delimiters parent pass players properties property_info queued_tasks queue_info raise random read recycle renumber reset_max_object resume rindex rmatch seconds_left server_log server_version setadd setremove set_connection_option set_player_flag set_property_info set_task_perms set_verb_args set_verb_code set_verb_info shutdown sin sinh sqrt strcmp string_hash strsub substitute suspend tan tanh task_id task_stack ticks_left time tofloat toint toliteral tonum toobj tostr trunc typeof unlisten valid value_bytes value_hash verbs verb_args verb_code verb_info contained 96endif 97 98" Enclosed expressions 99syn match mooUnenclosedError display ~[')\]|}]~ 100syn match mooParenthesesError display ~[';\]|}]~ contained 101syn region mooParentheses start=~(~ end=~)~ transparent contains=@mooEnclosedContents,mooParenthesesError 102syn match mooBracketsError display ~[');|}]~ contained 103syn region mooBrackets start=~\[~ end=~\]~ transparent contains=@mooEnclosedContents,mooBracketsError 104syn match mooBracesError display ~[');\]|]~ contained 105syn region mooBraces start=~{~ end=~}~ transparent contains=@mooEnclosedContents,mooBracesError 106syn match mooQuestionError display ~[');\]}]~ contained 107syn region mooQuestion start=~?~ end=~|~ transparent contains=@mooEnclosedContents,mooQuestionError 108syn match mooCatchError display ~[);\]|}]~ contained 109syn region mooCatch matchgroup=mooExclamation start=~`~ end=~'~ transparent contains=@mooEnclosedContents,mooCatchError,mooExclamation 110if exists("moo_extended_cstyle_comments") 111 syn match mooExclamation display ~[\t !%&(*+,\-/<=>?@[^`{|]\@<!\s*\%(\%(/\*.\{-}\*/\s*\)*\)\@>!=\@!~ contained contains=mooCStyleComment 112else 113 syn match mooExclamation display ~[\t !%&(*+,\-/<=>?@[^`{|]\@<!\s*!=\@!~ contained 114endif 115 116" Comments 117syn match mooCommentSpecialChar display ~\\["\\]~ contained transparent contains=NONE 118syn match mooComment ~[\t !%&*+,\-/<=>?@^|]\@<!\s*"\([^\"]\|\\.\)*"\s*;~ contains=mooStringError,mooCommentSpecialChar 119 120" Non-code 121syn region mooNonCode start=~^\s*@\<~ end=~$~ 122syn match mooNonCode display ~^\.$~ 123syn match mooNonCode display ~^\s*\d\+:~he=e-1 124 125" Overriding matches 126syn match mooRangeOperator display ~\.\.~ transparent contains=NONE 127syn match mooOrOperator display ~||~ transparent contains=NONE 128if exists("moo_extended_cstyle_comments") 129 syn match mooScattering ~[,{]\@<=\s*\%(\%(/\*.\{-}\*/\s*\)*\)\@>?~ transparent contains=mooCStyleComment 130else 131 syn match mooScattering ~[,{]\@<=\s*?~ transparent contains=NONE 132endif 133 134" Clusters 135syn cluster mooKeyword contains=mooStatement,mooOperatorIn,mooAny,mooErrorConstant 136syn cluster mooStringContents contains=mooStringError,mooStringSpecialChar 137syn cluster mooEnclosedContents contains=TOP,mooUnenclosedError,mooComment,mooNonCode 138 139" Define the default highlighting. 140hi def link mooUncommentedError Error 141hi def link mooCStyleCommentError Error 142hi def link mooCStyleComment Comment 143hi def link mooStatement Statement 144hi def link mooOperatorIn Operator 145hi def link mooAny Constant " link this to Keyword if you want 146hi def link mooErrorConstant Constant 147hi def link mooType Type 148hi def link mooVariable Type 149hi def link mooStringError Error 150hi def link mooStringSpecialChar SpecialChar 151hi def link mooRegexpOr SpecialChar 152hi def link mooPronounSub SpecialChar 153hi def link mooString String 154hi def link mooNumber Number 155hi def link mooObject Number 156hi def link mooBuiltinProperty Type 157hi def link mooBuiltinFunction Function 158hi def link mooUnknownBuiltinFunction Error 159hi def link mooKnownBuiltinFunction Function 160hi def link mooCorePropOrVerb Identifier 161hi def link mooUnenclosedError Error 162hi def link mooParenthesesError Error 163hi def link mooBracketsError Error 164hi def link mooBracesError Error 165hi def link mooQuestionError Error 166hi def link mooCatchError Error 167hi def link mooExclamation Exception 168hi def link mooComment Comment 169hi def link mooNonCode PreProc 170 171let b:current_syntax = "moo" 172 173" vim: ts=8 174