1" Vim syntax file 2" Language: ChaiScript 3" Maintainer: Jason Turner <lefticus 'at' gmail com> 4 5" Quit when a (custom) syntax file was already loaded 6if exists("b:current_syntax") 7 finish 8end 9 10syn case match 11 12" syncing method 13syn sync fromstart 14 15" Strings 16syn region chaiscriptString start=+"+ end=+"+ skip=+\\\\\|\\"+ contains=chaiscriptSpecial,chaiscriptEval,@Spell 17 18" Escape characters 19syn match chaiscriptSpecial contained "\\[\\abfnrtv\'\"]\|\\\d\{,3}" 20 21" String evals 22syn region chaiscriptEval contained start="${" end="}" 23 24" integer number 25syn match chaiscriptNumber "\<\d\+\>" 26 27" floating point number, with dot, optional exponent 28syn match chaiscriptFloat "\<\d\+\.\d*\%(e[-+]\=\d\+\)\=\>" 29 30" floating point number, starting with a dot, optional exponent 31syn match chaiscriptFloat "\.\d\+\%(e[-+]\=\d\+\)\=\>" 32 33" floating point number, without dot, with exponent 34syn match chaiscriptFloat "\<\d\+e[-+]\=\d\+\>" 35 36" Hex strings 37syn match chaiscriptNumber "\<0x\x\+\>" 38 39" Binary strings 40syn match chaiscriptNumber "\<0b[01]\+\>" 41 42" Various language features 43syn keyword chaiscriptCond if else 44syn keyword chaiscriptRepeat while for do 45syn keyword chaiscriptStatement break continue return 46syn keyword chaiscriptExceptions try catch throw 47 48"Keyword 49syn keyword chaiscriptKeyword def true false attr 50 51"Built in types 52syn keyword chaiscriptType fun var 53 54"Built in funcs, keep it simple 55syn keyword chaiscriptFunc eval throw 56 57"Let's treat all backtick operator function lookups as built in too 58syn region chaiscriptFunc matchgroup=chaiscriptFunc start="`" end="`" 59 60" Account for the "[1..10]" syntax, treating it as an operator 61" Intentionally leaving out all of the normal, well known operators 62syn match chaiscriptOperator "\.\." 63 64" Guard seperator as an operator 65syn match chaiscriptOperator ":" 66 67" Comments 68syn match chaiscriptComment "//.*$" contains=@Spell 69syn region chaiscriptComment matchgroup=chaiscriptComment start="/\*" end="\*/" contains=@Spell 70 71 72 73hi def link chaiscriptExceptions Exception 74hi def link chaiscriptKeyword Keyword 75hi def link chaiscriptStatement Statement 76hi def link chaiscriptRepeat Repeat 77hi def link chaiscriptString String 78hi def link chaiscriptNumber Number 79hi def link chaiscriptFloat Float 80hi def link chaiscriptOperator Operator 81hi def link chaiscriptConstant Constant 82hi def link chaiscriptCond Conditional 83hi def link chaiscriptFunction Function 84hi def link chaiscriptComment Comment 85hi def link chaiscriptTodo Todo 86hi def link chaiscriptError Error 87hi def link chaiscriptSpecial SpecialChar 88hi def link chaiscriptFunc Identifier 89hi def link chaiscriptType Type 90hi def link chaiscriptEval Special 91 92let b:current_syntax = "chaiscript" 93 94" vim: nowrap sw=2 sts=2 ts=8 noet 95