monk.vim 10.0 KB

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