1" Vim syntax file 2" Language: Monk (See-Beyond Technologies) 3" Maintainer: Mike Litherland <[email protected]> 4" Last Change: 2012 Feb 03 by Thilo Six 5 6" This syntax file is good enough for my needs, but others 7" may desire more features. Suggestions and bug reports 8" are solicited by the author (above). 9 10" Originally based on the Scheme syntax file by: 11 12" Maintainer: Dirk van Deun <[email protected]> 13" Last Change: April 30, 1998 14 15" In fact it's almost identical. :) 16 17" The original author's notes: 18" This script incorrectly recognizes some junk input as numerals: 19" parsing the complete system of Scheme numerals using the pattern 20" language is practically impossible: I did a lax approximation. 21 22" Initializing: 23 24" For version 5.x: Clear all syntax items 25" For version 6.x: Quit when a syntax file was already loaded 26if version < 600 27 syntax clear 28elseif exists("b:current_syntax") 29 finish 30endif 31 32let s:cpo_save = &cpo 33set cpo&vim 34 35syn case ignore 36 37" Fascist highlighting: everything that doesn't fit the rules is an error... 38 39syn match monkError oneline ![^ \t()";]*! 40syn match monkError oneline ")" 41 42" Quoted and backquoted stuff 43 44syn region monkQuoted matchgroup=Delimiter start="['`]" end=![ \t()";]!me=e-1 contains=ALLBUT,monkStruc,monkSyntax,monkFunc 45 46syn region monkQuoted matchgroup=Delimiter start="['`](" matchgroup=Delimiter end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc 47syn region monkQuoted matchgroup=Delimiter start="['`]#(" matchgroup=Delimiter end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc 48 49syn region monkStrucRestricted matchgroup=Delimiter start="(" matchgroup=Delimiter end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc 50syn region monkStrucRestricted matchgroup=Delimiter start="#(" matchgroup=Delimiter end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc 51 52syn region monkUnquote matchgroup=Delimiter start="," end=![ \t()";]!me=e-1 contains=ALLBUT,monkStruc,monkSyntax,monkFunc 53syn region monkUnquote matchgroup=Delimiter start=",@" end=![ \t()";]!me=e-1 contains=ALLBUT,monkStruc,monkSyntax,monkFunc 54 55syn region monkUnquote matchgroup=Delimiter start=",(" end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc 56syn region monkUnquote matchgroup=Delimiter start=",@(" end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc 57 58syn region monkUnquote matchgroup=Delimiter start=",#(" end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc 59syn region monkUnquote matchgroup=Delimiter start=",@#(" end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc 60 61" R5RS Scheme Functions and Syntax: 62 63if version < 600 64 set iskeyword=33,35-39,42-58,60-90,94,95,97-122,126,_ 65else 66 setlocal iskeyword=33,35-39,42-58,60-90,94,95,97-122,126,_ 67endif 68 69syn keyword monkSyntax lambda and or if cond case define let let* letrec 70syn keyword monkSyntax begin do delay set! else => 71syn keyword monkSyntax quote quasiquote unquote unquote-splicing 72syn keyword monkSyntax define-syntax let-syntax letrec-syntax syntax-rules 73 74syn keyword monkFunc not boolean? eq? eqv? equal? pair? cons car cdr set-car! 75syn keyword monkFunc set-cdr! caar cadr cdar cddr caaar caadr cadar caddr 76syn keyword monkFunc cdaar cdadr cddar cdddr caaaar caaadr caadar caaddr 77syn keyword monkFunc cadaar cadadr caddar cadddr cdaaar cdaadr cdadar cdaddr 78syn keyword monkFunc cddaar cddadr cdddar cddddr null? list? list length 79syn keyword monkFunc append reverse list-ref memq memv member assq assv assoc 80syn keyword monkFunc symbol? symbol->string string->symbol number? complex? 81syn keyword monkFunc real? rational? integer? exact? inexact? = < > <= >= 82syn keyword monkFunc zero? positive? negative? odd? even? max min + * - / abs 83syn keyword monkFunc quotient remainder modulo gcd lcm numerator denominator 84syn keyword monkFunc floor ceiling truncate round rationalize exp log sin cos 85syn keyword monkFunc tan asin acos atan sqrt expt make-rectangular make-polar 86syn keyword monkFunc real-part imag-part magnitude angle exact->inexact 87syn keyword monkFunc inexact->exact number->string string->number char=? 88syn keyword monkFunc char-ci=? char<? char-ci<? char>? char-ci>? char<=? 89syn keyword monkFunc char-ci<=? char>=? char-ci>=? char-alphabetic? char? 90syn keyword monkFunc char-numeric? char-whitespace? char-upper-case? 91syn keyword monkFunc char-lower-case? 92syn keyword monkFunc char->integer integer->char char-upcase char-downcase 93syn keyword monkFunc string? make-string string string-length string-ref 94syn keyword monkFunc string-set! string=? string-ci=? string<? string-ci<? 95syn keyword monkFunc string>? string-ci>? string<=? string-ci<=? string>=? 96syn keyword monkFunc string-ci>=? substring string-append vector? make-vector 97syn keyword monkFunc vector vector-length vector-ref vector-set! procedure? 98syn keyword monkFunc apply map for-each call-with-current-continuation 99syn keyword monkFunc call-with-input-file call-with-output-file input-port? 100syn keyword monkFunc output-port? current-input-port current-output-port 101syn keyword monkFunc open-input-file open-output-file close-input-port 102syn keyword monkFunc close-output-port eof-object? read read-char peek-char 103syn keyword monkFunc write display newline write-char call/cc 104syn keyword monkFunc list-tail string->list list->string string-copy 105syn keyword monkFunc string-fill! vector->list list->vector vector-fill! 106syn keyword monkFunc force with-input-from-file with-output-to-file 107syn keyword monkFunc char-ready? load transcript-on transcript-off eval 108syn keyword monkFunc dynamic-wind port? values call-with-values 109syn keyword monkFunc monk-report-environment null-environment 110syn keyword monkFunc interaction-environment 111 112" Keywords specific to STC's implementation 113 114syn keyword monkFunc $event-clear $event-parse $event->string $make-event-map 115syn keyword monkFunc $resolve-event-definition change-pattern copy copy-strip 116syn keyword monkFunc count-data-children count-map-children count-rep data-map 117syn keyword monkFunc duplicate duplicate-strip file-check file-lookup get 118syn keyword monkFunc insert list-lookup node-has-data? not-verify path? 119syn keyword monkFunc path-defined-as-repeating? path-nodeclear path-nodedepth 120syn keyword monkFunc path-nodename path-nodeparentname path->string path-valid? 121syn keyword monkFunc regex string->path timestamp uniqueid verify 122 123" Keywords from the Monk function library (from e*Gate 4.1 programmers ref) 124syn keyword monkFunc allcap? capitalize char-punctuation? char-substitute 125syn keyword monkFunc char-to-char conv count-used-children degc->degf 126syn keyword monkFunc diff-two-dates display-error empty-string? fail_id 127syn keyword monkFunc fail_id_if fail_translation fail_translation_if 128syn keyword monkFunc find-get-after find-get-before get-timestamp julian-date? 129syn keyword monkFunc julian->standard leap-year? map-string not-empty-string? 130syn keyword monkFunc standard-date? standard->julian string-begins-with? 131syn keyword monkFunc string-contains? string-ends-with? string-search-from-left 132syn keyword monkFunc string-search-from-right string->ssn strip-punct 133syn keyword monkFunc strip-string substring=? symbol-table-get symbol-table-put 134syn keyword monkFunc trim-string-left trim-string-right valid-decimal? 135syn keyword monkFunc valid-integer? verify-type 136 137" Writing out the complete description of Scheme numerals without 138" using variables is a day's work for a trained secretary... 139" This is a useful lax approximation: 140 141syn match monkNumber oneline "[-#+0-9.][-#+/[email protected]]*" 142syn match monkError oneline ![-#+0-9.][-#+/[email protected]]*[^-#+/[email protected] \t()";][^ \t()";]*! 143 144syn match monkOther oneline ![+-][ \t()";]!me=e-1 145syn match monkOther oneline ![+-]$! 146" ... so that a single + or -, inside a quoted context, would not be 147" interpreted as a number (outside such contexts, it's a monkFunc) 148 149syn match monkDelimiter oneline !\.[ \t()";]!me=e-1 150syn match monkDelimiter oneline !\.$! 151" ... and a single dot is not a number but a delimiter 152 153" Simple literals: 154 155syn match monkBoolean oneline "#[tf]" 156syn match monkError oneline !#[tf][^ \t()";]\+! 157 158syn match monkChar oneline "#\\" 159syn match monkChar oneline "#\\." 160syn match monkError oneline !#\\.[^ \t()";]\+! 161syn match monkChar oneline "#\\space" 162syn match monkError oneline !#\\space[^ \t()";]\+! 163syn match monkChar oneline "#\\newline" 164syn match monkError oneline !#\\newline[^ \t()";]\+! 165 166" This keeps all other stuff unhighlighted, except *stuff* and <stuff>: 167 168syn match monkOther oneline ,[a-z!$%&*/:<=>?^_~][-a-z!$%&*/:<=>?^_~0-9+.@]*, 169syn match monkError oneline ,[a-z!$%&*/:<=>?^_~][-a-z!$%&*/:<=>?^_~0-9+.@]*[^-a-z!$%&*/:<=>?^_~0-9+.@ \t()";]\+[^ \t()";]*, 170 171syn match monkOther oneline "\.\.\." 172syn match monkError oneline !\.\.\.[^ \t()";]\+! 173" ... a special identifier 174 175syn match monkConstant oneline ,\*[-a-z!$%&*/:<=>?^_~0-9+.@]*\*[ \t()";],me=e-1 176syn match monkConstant oneline ,\*[-a-z!$%&*/:<=>?^_~0-9+.@]*\*$, 177syn match monkError oneline ,\*[-a-z!$%&*/:<=>?^_~0-9+.@]*\*[^-a-z!$%&*/:<=>?^_~0-9+.@ \t()";]\+[^ \t()";]*, 178 179syn match monkConstant oneline ,<[-a-z!$%&*/:<=>?^_~0-9+.@]*>[ \t()";],me=e-1 180syn match monkConstant oneline ,<[-a-z!$%&*/:<=>?^_~0-9+.@]*>$, 181syn match monkError oneline ,<[-a-z!$%&*/:<=>?^_~0-9+.@]*>[^-a-z!$%&*/:<=>?^_~0-9+.@ \t()";]\+[^ \t()";]*, 182 183" Monk input and output structures 184syn match monkSyntax oneline "\(\~input\|\[I\]->\)[^ \t]*" 185syn match monkFunc oneline "\(\~output\|\[O\]->\)[^ \t]*" 186 187" Non-quoted lists, and strings: 188 189syn region monkStruc matchgroup=Delimiter start="(" matchgroup=Delimiter end=")" contains=ALL 190syn region monkStruc matchgroup=Delimiter start="#(" matchgroup=Delimiter end=")" contains=ALL 191 192syn region monkString start=+"+ skip=+\\[\\"]+ end=+"+ 193 194" Comments: 195 196syn match monkComment ";.*$" 197 198" Synchronization and the wrapping up... 199 200syn sync match matchPlace grouphere NONE "^[^ \t]" 201" ... i.e. synchronize on a line that starts at the left margin 202 203" Define the default highlighting. 204" For version 5.7 and earlier: only when not done already 205" For version 5.8 and later: only when an item doesn't have highlighting yet 206if version >= 508 || !exists("did_monk_syntax_inits") 207 if version < 508 208 let did_monk_syntax_inits = 1 209 command -nargs=+ HiLink hi link <args> 210 else 211 command -nargs=+ HiLink hi def link <args> 212 endif 213 214 HiLink monkSyntax Statement 215 HiLink monkFunc Function 216 217 HiLink monkString String 218 HiLink monkChar Character 219 HiLink monkNumber Number 220 HiLink monkBoolean Boolean 221 222 HiLink monkDelimiter Delimiter 223 HiLink monkConstant Constant 224 225 HiLink monkComment Comment 226 HiLink monkError Error 227 228 delcommand HiLink 229endif 230 231let b:current_syntax = "monk" 232 233let &cpo = s:cpo_save 234unlet s:cpo_save 235