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