(183 lines)
1 " Language: Tomo2 " Maintainer: Bruce Hill <bruce@bruce-hill.com>3 " License: WTFPL5 " Bail if our syntax is already loaded.6 if exists('b:current_syntax') && b:current_syntax == 'tomo'7 finish8 endif10 syn match TomoErrorWord /\i*/ contained11 hi def link TomoErrorWord Error13 syn match TomoVar /[a-zA-Z_][a-zA-Z_0-9]*/15 syn match TomoNumber /0x[0-9a-fA-F_]\+%\?\|[0-9][0-9_]*\(\.\([0-9][0-9_]*\|\.\@!\)\)\?\(e[0-9_]\+\)\?%\?\|\.\@<!\.[0-9][0-9_]*\(e[0-9_]\+\)\?%\?/16 hi def link TomoNumber Number18 syn match TomoChar /`./19 hi def link TomoChar String21 syn region TomoString start=/".\@=/ end=/"\|$/ contains=TomoStringInterp,TomoEscape22 syn region TomoString start=/'.\@=/ end=/'\|$/ contains=TomoStringInterp,TomoEscape23 syn region TomoString start=/`.\@=/ end=/`\|$/ contains=TomoStringInterpAt,TomoEscape24 syn region TomoString start=/".\@!\%(^\z(\s*\).*\)\@<=/ end=/^\z1"\|^\%(\z1\s\)\@!\s*\S\@=/ contains=TomoStringInterp,TomoEscape25 syn region TomoString start=/'.\@!\%(^\z(\s*\).*\)\@<=/hs=e+1 end=/^\z1'\|^\%(\z1\s\)\@!\s*\S\@=/he=s-1 contains=TomoStringInterp,TomoEscape26 syn region TomoString start=/`.\@!\%(^\z(\s*\).*\)\@<=/hs=e+1 end=/^\z1`\|^\%(\z1\s\)\@!\s*\S\@=/he=s-1 contains=TomoStringInterpAt,TomoEscape27 hi def link TomoString String29 syn region TomoPath start=;(\(\~/\|\./\|\.\./\|/\); skip=/\\.\|([^)]*)/ end=;$\|); contains=TomoEscape30 hi def link TomoPath String32 "syn region TomoDSLString start=/\z(["'`|/;([{<]\).\@=/hs=e end=/\z1/ contains=TomoStringInterp,TomoEscape contained33 "syn region TomoDSLString start=/\z(["'`|/;([{<]\).\@!\%(^\z(\s*\).*\)\@<=/hs=e end=/^\z2\z1/he=e contains=TomoStringInterp,TomoEscape contained34 "syn region TomoDSLString start=/\[/hs=e+1 end=/]/he=s-1 contains=TomoStringInterp,TomoEscape contained35 "syn region TomoDSLString start=/{/hs=e+1 end=/}/he=s-1 contains=TomoStringInterp,TomoEscape contained36 "syn region TomoDSLString start=/</hs=e+1 end=/>/he=s-1 contains=TomoStringInterp,TomoEscape contained37 "syn region TomoDSLString start=/(/hs=e+1 end=/)/he=s-1 contains=TomoStringInterp,TomoEscape contained38 "hi def link TomoDSLString String40 syn match TomoArray /\[/ nextgroup=TomoTypeAnnotation41 syn match TomoTable /{/ nextgroup=TomoTypeAnnotation43 syn match TomoDocTest /^\s*>>>/44 syn region TomoDocTest start=/^\s*===/ end=/$/45 hi TomoDocTest ctermfg=gray47 syn match TomoDocError /!!!.*/48 hi TomoDocError ctermfg=red cterm=italic50 syn match TomoDSL /\$\d\@!\w*/ nextgroup=TomoString51 hi def link TomoDSL String52 hi TomoDSL ctermfg=white cterm=bold54 "syn match TomoCustomStringInterp /[~!@#$%^&*+=\?]\?/ contained nextgroup=TomoDSLString55 "hi TomoCustomStringInterp ctermfg=gray57 syn match TomoStringDollar /\$/ contained58 hi TomoStringDollar ctermfg=LightBlue60 syn match TomoStringAt /@/ contained61 hi TomoStringAt ctermfg=LightBlue63 syn match TomoStringInterpWord /[a-zA-Z_][a-zA-Z_0-9]*/ contained64 hi TomoStringInterpWord ctermfg=LightBlue66 syn match TomoStringInterp /\$/ contained nextgroup=TomoStringDollar,TomoStringInterpWord,TomoParenGroup,@TomoAll67 hi TomoStringInterp ctermfg=LightBlue69 syn match TomoStringInterpAt /@/ contained nextgroup=TomoStringAt,TomoStringInterpWord,TomoParenGroup,@TomoAll70 hi TomoStringInterpAt ctermfg=LightBlue72 syn match TomoEscape /\\\([abenrtvN]\|x\x\x\|\d\{3}\|{[^}]*}\|\[[^]]*\]\)\|\\./73 hi TomoEscape ctermfg=LightBlue75 syn keyword TomoExtern extern76 hi def link TomoExtern Statement78 syn keyword TomoConditional if unless else when then defer holding79 hi def link TomoConditional Conditional81 syn keyword TomoLoop for while do until repeat82 hi def link TomoLoop Repeat84 syn keyword TomoFail fail85 hi def link TomoFail Exception87 syn keyword TomoStatement stop skip break continue fail pass return del struct lang extend assert88 hi def link TomoStatement Statement90 syn keyword TomoNone none91 hi TomoNone ctermfg=red93 syn keyword TomoSerializing deserialize94 hi TomoSerializing ctermfg=blue cterm=bold96 syn region TomoUse matchgroup=Keyword start=/\<use\>/ matchgroup=TomoDelim end=/$\|;/97 hi def link TomoUse String99 syn match TomoArgDefault /=/ nextgroup=@TomoAll skipwhite contained100 hi def link TomoArgDefault Operator101 syn match TomoReturnSignature /->/ nextgroup=TomoType skipwhite contained102 hi def link TomoReturnSignature Operator103 syn region TomoFnArgSignature start=/(/ end=/)/ contains=TomoVar,TomoDelim,TomoTypeAnnotation,TomoArgDefault,TomoComment nextgroup=TomoReturnSignature skipwhite contained104 syn match TomoFnName /\<[a-zA-Z_][a-zA-Z_0-9]*\>/ nextgroup=TomoFnArgSignature skipwhite contained105 hi def link TomoFnName Function106 syn keyword TomoFuncDef func nextgroup=TomoFnName skipwhite107 hi def link TomoFuncDef Keyword108 syn keyword TomoConvertDef convert nextgroup=TomoFnArgSignature skipwhite109 hi def link TomoConvertDef Keyword111 syn match TomoTagEquals /=/ skipwhite nextgroup=TomoErrorWord,TomoNumber contained112 hi def link TomoTagEquals Operator113 syn match TomoTagType /(/ nextgroup=TomoType contained114 syn match TomoTag /[a-zA-Z_]\i*/ nextgroup=TomoTagType contained115 hi TomoTag cterm=bold117 syn keyword TomoEnum enum skipwhite nextgroup=TomoTaggedUnion118 hi def link TomoEnum Keyword119 syn region TomoTaggedUnion start=/:=/ skip=/|/ end=/$/ contains=TomoTag,TomoTagEquals contained121 " syn region TomoFnDecl start=/\<def\>/ end=/(\@=\|$/ contains=TomoFnName,TomoKeyword123 syn keyword TomoBoolean yes no124 hi def link TomoBoolean Boolean126 syn match TomoStructName /\w\+\( *{\)\@=/127 hi TomoStructName cterm=bold129 syn keyword TomoOperator in and or xor is not mod mod1 _min_ _max_ _mix_ mutexed130 syn match TomoOperator ;\([a-zA-Z0-9_)] *\)\@<=/;131 syn match TomoOperator ;[+*^<>=-]=\?;132 syn match TomoOperator /[:!]\?=/133 syn match TomoOperator /[#?:]/134 hi def link TomoOperator Operator136 syn match TomoDelim /,/137 hi def link TomoDelim Delimiter139 syn match TomoTableValueType /:/ nextgroup=TomoType contained140 hi def link TomoTableValueType Type141 syn match TomoTypeDelim /,/ contained142 hi def link TomoTypeDelim Type143 syn match TomoAssoc /=/ contained144 hi def link TomoAssoc Type145 syn region TomoType start=/\[/ end=/\]\|\():\)\@=\|$/ contains=TomoType contained nextgroup=TomoTableValueType146 syn region TomoType start=/{/ end=/}\|\():\)\@=\|$/ contains=TomoType,TomoAssoc contained nextgroup=TomoTableValueType147 syn region TomoType start=/func(/ end=/) *\(->\)\?/ contains=TomoType,TomoTypeDelim nextgroup=TomoType contained148 syn match TomoType /[a-zA-Z_]\i*/ contained nextgroup=TomoTableValueType149 syn match TomoType /\$[a-zA-Z_0-9]\+/ contained nextgroup=TomoTableValueType150 syn match TomoType /[@?&]\+/ contained nextgroup=TomoType151 hi def link TomoType Type153 syn match TomoTypeAnnotation /:=\@!/ nextgroup=TomoType contained154 hi def link TomoTypeAnnotation Operator156 syn region TomoComment start=;#; end=/$/157 hi def link TomoComment Comment159 syn region TomoSay start=;!!; end=/$/ contains=TomoEscape,TomoStringInterp160 hi TomoSay ctermfg=white cterm=bold162 syn region TomoInlineCParens start=/(/ end=/)/ contains=TomoInlineCParens contained163 hi def link TomoInlineCParens String165 syn region TomoInlineCBraces start=/{/ end=/}/ contains=TomoInlineCBraces contained166 hi def link TomoInlineCBraces String168 syn match TomoInlineC ;\<C_code\> *; nextgroup=TomoInlineCBraces,TomoInlineCParens169 hi def link TomoInlineC Keyword171 syn region TomoParenGroup start=/(/ end=/)/ contains=@TomoAll,TomoParenGroup contained173 syn match TomoLinkerDirective ;^\s*!link.*$;174 hi TomoLinkerDirective ctermbg=blue ctermfg=black176 syn cluster TomoAll contains=TomoVar,TomoComment,TomoChar,TomoString,TomoDSL,TomoPath,TomoKeyword,TomoOperator,177 \TomoConditional,TomoLoop,TomoFail,TomoNone,TomoSerializing,TomoStatement,TomoStructure,TomoTypedef,TomoEmptyTable,TomoUse,178 \TomoNumber,TomoFnDecl,TomoBoolean,TomoDocTest,TomoDocError,TomoArray,TomoTable,179 \TomoLinkerDirective,TomoInlineC181 if !exists('b:current_syntax')182 let b:current_syntax = 'tomo'183 endif