codekingpro/portable-devtools
114k
1" Vim syntax file2" Language: Monk (See-Beyond Technologies)3" Maintainer: Mike Litherland <litherm@ccf.org>4" Last Change: 2012 Feb 03 by Thilo Six5 6" This syntax file is good enough for my needs, but others7" may desire more features. Suggestions and bug reports8" are solicited by the author (above).9 10" Originally based on the Scheme syntax file by:11 12" Maintainer: Dirk van Deun <dvandeun@poboxes.com>13" Last Change: April 30, 199814 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 pattern20" language is practically impossible: I did a lax approximation.21 22" Initializing:23 24" quit when a syntax file was already loaded25if exists("b:current_syntax")26 finish27endif28 29let s:cpo_save = &cpo30set cpo&vim31 32syn case ignore33 34" Fascist highlighting: everything that doesn't fit the rules is an error...35 36syn match monkError oneline ![^ \t()";]*!37syn match monkError oneline ")"38 39" Quoted and backquoted stuff40 41syn region monkQuoted matchgroup=Delimiter start="['`]" end=![ \t()";]!me=e-1 contains=ALLBUT,monkStruc,monkSyntax,monkFunc42 43syn region monkQuoted matchgroup=Delimiter start="['`](" matchgroup=Delimiter end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc44syn region monkQuoted matchgroup=Delimiter start="['`]#(" matchgroup=Delimiter end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc45 46syn region monkStrucRestricted matchgroup=Delimiter start="(" matchgroup=Delimiter end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc47syn region monkStrucRestricted matchgroup=Delimiter start="#(" matchgroup=Delimiter end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc48 49syn region monkUnquote matchgroup=Delimiter start="," end=![ \t()";]!me=e-1 contains=ALLBUT,monkStruc,monkSyntax,monkFunc50syn region monkUnquote matchgroup=Delimiter start=",@" end=![ \t()";]!me=e-1 contains=ALLBUT,monkStruc,monkSyntax,monkFunc51 52syn region monkUnquote matchgroup=Delimiter start=",(" end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc53syn region monkUnquote matchgroup=Delimiter start=",@(" end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc54 55syn region monkUnquote matchgroup=Delimiter start=",#(" end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc56syn region monkUnquote matchgroup=Delimiter start=",@#(" end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc57 58" R5RS Scheme Functions and Syntax:59 60setlocal iskeyword=33,35-39,42-58,60-90,94,95,97-122,126,_61 62syn keyword monkSyntax lambda and or if cond case define let let* letrec63syn keyword monkSyntax begin do delay set! else =>64syn keyword monkSyntax quote quasiquote unquote unquote-splicing65syn keyword monkSyntax define-syntax let-syntax letrec-syntax syntax-rules66 67syn keyword monkFunc not boolean? eq? eqv? equal? pair? cons car cdr set-car!68syn keyword monkFunc set-cdr! caar cadr cdar cddr caaar caadr cadar caddr69syn keyword monkFunc cdaar cdadr cddar cdddr caaaar caaadr caadar caaddr70syn keyword monkFunc cadaar cadadr caddar cadddr cdaaar cdaadr cdadar cdaddr71syn keyword monkFunc cddaar cddadr cdddar cddddr null? list? list length72syn keyword monkFunc append reverse list-ref memq memv member assq assv assoc73syn keyword monkFunc symbol? symbol->string string->symbol number? complex?74syn keyword monkFunc real? rational? integer? exact? inexact? = < > <= >=75syn keyword monkFunc zero? positive? negative? odd? even? max min + * - / abs76syn keyword monkFunc quotient remainder modulo gcd lcm numerator denominator77syn keyword monkFunc floor ceiling truncate round rationalize exp log sin cos78syn keyword monkFunc tan asin acos atan sqrt expt make-rectangular make-polar79syn keyword monkFunc real-part imag-part magnitude angle exact->inexact80syn keyword monkFunc inexact->exact number->string string->number char=?81syn keyword monkFunc char-ci=? char<? char-ci<? char>? char-ci>? char<=?82syn keyword monkFunc char-ci<=? char>=? char-ci>=? char-alphabetic? char?83syn keyword monkFunc char-numeric? char-whitespace? char-upper-case?84syn keyword monkFunc char-lower-case?85syn keyword monkFunc char->integer integer->char char-upcase char-downcase86syn keyword monkFunc string? make-string string string-length string-ref87syn keyword monkFunc string-set! string=? string-ci=? string<? string-ci<?88syn keyword monkFunc string>? string-ci>? string<=? string-ci<=? string>=?89syn keyword monkFunc string-ci>=? substring string-append vector? make-vector90syn keyword monkFunc vector vector-length vector-ref vector-set! procedure?91syn keyword monkFunc apply map for-each call-with-current-continuation92syn keyword monkFunc call-with-input-file call-with-output-file input-port?93syn keyword monkFunc output-port? current-input-port current-output-port94syn keyword monkFunc open-input-file open-output-file close-input-port95syn keyword monkFunc close-output-port eof-object? read read-char peek-char96syn keyword monkFunc write display newline write-char call/cc97syn keyword monkFunc list-tail string->list list->string string-copy98syn keyword monkFunc string-fill! vector->list list->vector vector-fill!99syn keyword monkFunc force with-input-from-file with-output-to-file100syn keyword monkFunc char-ready? load transcript-on transcript-off eval101syn keyword monkFunc dynamic-wind port? values call-with-values102syn keyword monkFunc monk-report-environment null-environment103syn keyword monkFunc interaction-environment104 105" Keywords specific to STC's implementation106 107syn keyword monkFunc $event-clear $event-parse $event->string $make-event-map108syn keyword monkFunc $resolve-event-definition change-pattern copy copy-strip109syn keyword monkFunc count-data-children count-map-children count-rep data-map110syn keyword monkFunc duplicate duplicate-strip file-check file-lookup get111syn keyword monkFunc insert list-lookup node-has-data? not-verify path?112syn keyword monkFunc path-defined-as-repeating? path-nodeclear path-nodedepth113syn keyword monkFunc path-nodename path-nodeparentname path->string path-valid?114syn keyword monkFunc regex string->path timestamp uniqueid verify115 116" Keywords from the Monk function library (from e*Gate 4.1 programmers ref)117syn keyword monkFunc allcap? capitalize char-punctuation? char-substitute118syn keyword monkFunc char-to-char conv count-used-children degc->degf119syn keyword monkFunc diff-two-dates display-error empty-string? fail_id120syn keyword monkFunc fail_id_if fail_translation fail_translation_if121syn keyword monkFunc find-get-after find-get-before get-timestamp julian-date?122syn keyword monkFunc julian->standard leap-year? map-string not-empty-string?123syn keyword monkFunc standard-date? standard->julian string-begins-with?124syn keyword monkFunc string-contains? string-ends-with? string-search-from-left125syn keyword monkFunc string-search-from-right string->ssn strip-punct126syn keyword monkFunc strip-string substring=? symbol-table-get symbol-table-put127syn keyword monkFunc trim-string-left trim-string-right valid-decimal?128syn keyword monkFunc valid-integer? verify-type129 130" Writing out the complete description of Scheme numerals without131" using variables is a day's work for a trained secretary...132" This is a useful lax approximation:133 134syn match monkNumber oneline "[-#+0-9.][-#+/0-9a-f@i.boxesfdl]*"135syn match monkError oneline ![-#+0-9.][-#+/0-9a-f@i.boxesfdl]*[^-#+/0-9a-f@i.boxesfdl \t()";][^ \t()";]*!136 137syn match monkOther oneline ![+-][ \t()";]!me=e-1138syn match monkOther oneline ![+-]$!139" ... so that a single + or -, inside a quoted context, would not be140" interpreted as a number (outside such contexts, it's a monkFunc)141 142syn match monkDelimiter oneline !\.[ \t()";]!me=e-1143syn match monkDelimiter oneline !\.$!144" ... and a single dot is not a number but a delimiter145 146" Simple literals:147 148syn match monkBoolean oneline "#[tf]"149syn match monkError oneline !#[tf][^ \t()";]\+!150 151syn match monkChar oneline "#\\"152syn match monkChar oneline "#\\."153syn match monkError oneline !#\\.[^ \t()";]\+!154syn match monkChar oneline "#\\space"155syn match monkError oneline !#\\space[^ \t()";]\+!156syn match monkChar oneline "#\\newline"157syn match monkError oneline !#\\newline[^ \t()";]\+!158 159" This keeps all other stuff unhighlighted, except *stuff* and <stuff>:160 161syn match monkOther oneline ,[a-z!$%&*/:<=>?^_~][-a-z!$%&*/:<=>?^_~0-9+.@]*,162syn match monkError oneline ,[a-z!$%&*/:<=>?^_~][-a-z!$%&*/:<=>?^_~0-9+.@]*[^-a-z!$%&*/:<=>?^_~0-9+.@ \t()";]\+[^ \t()";]*,163 164syn match monkOther oneline "\.\.\."165syn match monkError oneline !\.\.\.[^ \t()";]\+!166" ... a special identifier167 168syn match monkConstant oneline ,\*[-a-z!$%&*/:<=>?^_~0-9+.@]*\*[ \t()";],me=e-1169syn match monkConstant oneline ,\*[-a-z!$%&*/:<=>?^_~0-9+.@]*\*$,170syn match monkError oneline ,\*[-a-z!$%&*/:<=>?^_~0-9+.@]*\*[^-a-z!$%&*/:<=>?^_~0-9+.@ \t()";]\+[^ \t()";]*,171 172syn match monkConstant oneline ,<[-a-z!$%&*/:<=>?^_~0-9+.@]*>[ \t()";],me=e-1173syn match monkConstant oneline ,<[-a-z!$%&*/:<=>?^_~0-9+.@]*>$,174syn match monkError oneline ,<[-a-z!$%&*/:<=>?^_~0-9+.@]*>[^-a-z!$%&*/:<=>?^_~0-9+.@ \t()";]\+[^ \t()";]*,175 176" Monk input and output structures177syn match monkSyntax oneline "\(\~input\|\[I\]->\)[^ \t]*"178syn match monkFunc oneline "\(\~output\|\[O\]->\)[^ \t]*"179 180" Non-quoted lists, and strings:181 182syn region monkStruc matchgroup=Delimiter start="(" matchgroup=Delimiter end=")" contains=ALL183syn region monkStruc matchgroup=Delimiter start="#(" matchgroup=Delimiter end=")" contains=ALL184 185syn region monkString start=+"+ skip=+\\[\\"]+ end=+"+186 187" Comments:188 189syn match monkComment ";.*$"190 191" Synchronization and the wrapping up...192 193syn sync match matchPlace grouphere NONE "^[^ \t]"194" ... i.e. synchronize on a line that starts at the left margin195 196" Define the default highlighting.197" Only when an item doesn't have highlighting yet198 199hi def link monkSyntax Statement200hi def link monkFunc Function201 202hi def link monkString String203hi def link monkChar Character204hi def link monkNumber Number205hi def link monkBoolean Boolean206 207hi def link monkDelimiter Delimiter208hi def link monkConstant Constant209 210hi def link monkComment Comment211hi def link monkError Error212 213 214let b:current_syntax = "monk"215 216let &cpo = s:cpo_save217unlet s:cpo_save218 