vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

monk.vim (9966B)


      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
     26 if exists("b:current_syntax")
     27   finish
     28 endif
     29 
     30 let s:cpo_save = &cpo
     31 set cpo&vim
     32 
     33 syn case ignore
     34 
     35 " Fascist highlighting: everything that doesn't fit the rules is an error...
     36 
     37 syn match	monkError	![^ \t()";]*!
     38 syn match	monkError	")"
     39 
     40 " Quoted and backquoted stuff
     41 
     42 syn region monkQuoted matchgroup=Delimiter start="['`]" end=![ \t()";]!me=e-1 contains=ALLBUT,monkStruc,monkSyntax,monkFunc
     43 
     44 syn region monkQuoted matchgroup=Delimiter start="['`](" matchgroup=Delimiter end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc
     45 syn region monkQuoted matchgroup=Delimiter start="['`]#(" matchgroup=Delimiter end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc
     46 
     47 syn region monkStrucRestricted matchgroup=Delimiter start="(" matchgroup=Delimiter end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc
     48 syn region monkStrucRestricted matchgroup=Delimiter start="#(" matchgroup=Delimiter end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc
     49 
     50 syn region monkUnquote matchgroup=Delimiter start="," end=![ \t()";]!me=e-1 contains=ALLBUT,monkStruc,monkSyntax,monkFunc
     51 syn region monkUnquote matchgroup=Delimiter start=",@" end=![ \t()";]!me=e-1 contains=ALLBUT,monkStruc,monkSyntax,monkFunc
     52 
     53 syn region monkUnquote matchgroup=Delimiter start=",(" end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc
     54 syn region monkUnquote matchgroup=Delimiter start=",@(" end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc
     55 
     56 syn region monkUnquote matchgroup=Delimiter start=",#(" end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc
     57 syn region monkUnquote matchgroup=Delimiter start=",@#(" end=")" contains=ALLBUT,monkStruc,monkSyntax,monkFunc
     58 
     59 " R5RS Scheme Functions and Syntax:
     60 
     61 setlocal iskeyword=33,35-39,42-58,60-90,94,95,97-122,126,_
     62 
     63 syn keyword monkSyntax lambda and or if cond case define let let* letrec
     64 syn keyword monkSyntax begin do delay set! else =>
     65 syn keyword monkSyntax quote quasiquote unquote unquote-splicing
     66 syn keyword monkSyntax define-syntax let-syntax letrec-syntax syntax-rules
     67 
     68 syn keyword monkFunc not boolean? eq? eqv? equal? pair? cons car cdr set-car!
     69 syn keyword monkFunc set-cdr! caar cadr cdar cddr caaar caadr cadar caddr
     70 syn keyword monkFunc cdaar cdadr cddar cdddr caaaar caaadr caadar caaddr
     71 syn keyword monkFunc cadaar cadadr caddar cadddr cdaaar cdaadr cdadar cdaddr
     72 syn keyword monkFunc cddaar cddadr cdddar cddddr null? list? list length
     73 syn keyword monkFunc append reverse list-ref memq memv member assq assv assoc
     74 syn keyword monkFunc symbol? symbol->string string->symbol number? complex?
     75 syn keyword monkFunc real? rational? integer? exact? inexact? = < > <= >=
     76 syn keyword monkFunc zero? positive? negative? odd? even? max min + * - / abs
     77 syn keyword monkFunc quotient remainder modulo gcd lcm numerator denominator
     78 syn keyword monkFunc floor ceiling truncate round rationalize exp log sin cos
     79 syn keyword monkFunc tan asin acos atan sqrt expt make-rectangular make-polar
     80 syn keyword monkFunc real-part imag-part magnitude angle exact->inexact
     81 syn keyword monkFunc inexact->exact number->string string->number char=?
     82 syn keyword monkFunc char-ci=? char<? char-ci<? char>? char-ci>? char<=?
     83 syn keyword monkFunc char-ci<=? char>=? char-ci>=? char-alphabetic? char?
     84 syn keyword monkFunc char-numeric? char-whitespace? char-upper-case?
     85 syn keyword monkFunc char-lower-case?
     86 syn keyword monkFunc char->integer integer->char char-upcase char-downcase
     87 syn keyword monkFunc string? make-string string string-length string-ref
     88 syn keyword monkFunc string-set! string=? string-ci=? string<? string-ci<?
     89 syn keyword monkFunc string>? string-ci>? string<=? string-ci<=? string>=?
     90 syn keyword monkFunc string-ci>=? substring string-append vector? make-vector
     91 syn keyword monkFunc vector vector-length vector-ref vector-set! procedure?
     92 syn keyword monkFunc apply map for-each call-with-current-continuation
     93 syn keyword monkFunc call-with-input-file call-with-output-file input-port?
     94 syn keyword monkFunc output-port? current-input-port current-output-port
     95 syn keyword monkFunc open-input-file open-output-file close-input-port
     96 syn keyword monkFunc close-output-port eof-object? read read-char peek-char
     97 syn keyword monkFunc write display newline write-char call/cc
     98 syn keyword monkFunc list-tail string->list list->string string-copy
     99 syn keyword monkFunc string-fill! vector->list list->vector vector-fill!
    100 syn keyword monkFunc force with-input-from-file with-output-to-file
    101 syn keyword monkFunc char-ready? load transcript-on transcript-off eval
    102 syn keyword monkFunc dynamic-wind port? values call-with-values
    103 syn keyword monkFunc monk-report-environment null-environment
    104 syn keyword monkFunc interaction-environment
    105 
    106 " Keywords specific to STC's implementation
    107 
    108 syn keyword monkFunc $event-clear $event-parse $event->string $make-event-map
    109 syn keyword monkFunc $resolve-event-definition change-pattern copy copy-strip
    110 syn keyword monkFunc count-data-children count-map-children count-rep data-map
    111 syn keyword monkFunc duplicate duplicate-strip file-check file-lookup get
    112 syn keyword monkFunc insert list-lookup node-has-data? not-verify path?
    113 syn keyword monkFunc path-defined-as-repeating? path-nodeclear path-nodedepth
    114 syn keyword monkFunc path-nodename path-nodeparentname path->string path-valid?
    115 syn keyword monkFunc regex string->path timestamp uniqueid verify
    116 
    117 " Keywords from the Monk function library (from e*Gate 4.1 programmers ref)
    118 syn keyword monkFunc allcap? capitalize char-punctuation? char-substitute
    119 syn keyword monkFunc char-to-char conv count-used-children degc->degf
    120 syn keyword monkFunc diff-two-dates display-error empty-string? fail_id
    121 syn keyword monkFunc fail_id_if fail_translation fail_translation_if
    122 syn keyword monkFunc find-get-after find-get-before get-timestamp julian-date?
    123 syn keyword monkFunc julian->standard leap-year? map-string not-empty-string?
    124 syn keyword monkFunc standard-date? standard->julian string-begins-with?
    125 syn keyword monkFunc string-contains? string-ends-with? string-search-from-left
    126 syn keyword monkFunc string-search-from-right string->ssn strip-punct
    127 syn keyword monkFunc strip-string substring=? symbol-table-get symbol-table-put
    128 syn keyword monkFunc trim-string-left trim-string-right valid-decimal?
    129 syn 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 
    135 syn match	monkNumber	"[-#+0-9.][-#+/0-9a-f@i.boxesfdl]*"
    136 syn match	monkError	![-#+0-9.][-#+/0-9a-f@i.boxesfdl]*[^-#+/0-9a-f@i.boxesfdl \t()";][^ \t()";]*!
    137 
    138 syn match	monkOther	![+-][ \t()";]!me=e-1
    139 syn 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 
    143 syn match	monkDelimiter	!\.[ \t()";]!me=e-1
    144 syn match	monkDelimiter	!\.$!
    145 " ... and a single dot is not a number but a delimiter
    146 
    147 " Simple literals:
    148 
    149 syn match	monkBoolean	"#[tf]"
    150 syn match	monkError	!#[tf][^ \t()";]\+!
    151 
    152 syn match	monkChar	"#\\"
    153 syn match	monkChar	"#\\."
    154 syn match	monkError	!#\\.[^ \t()";]\+!
    155 syn match	monkChar	"#\\space"
    156 syn match	monkError	!#\\space[^ \t()";]\+!
    157 syn match	monkChar	"#\\newline"
    158 syn match	monkError	!#\\newline[^ \t()";]\+!
    159 
    160 " This keeps all other stuff unhighlighted, except *stuff* and <stuff>:
    161 
    162 syn match	monkOther	,[a-z!$%&*/:<=>?^_~][-a-z!$%&*/:<=>?^_~0-9+.@]*,
    163 syn match	monkError	,[a-z!$%&*/:<=>?^_~][-a-z!$%&*/:<=>?^_~0-9+.@]*[^-a-z!$%&*/:<=>?^_~0-9+.@ \t()";]\+[^ \t()";]*,
    164 
    165 syn match	monkOther	"\.\.\."
    166 syn match	monkError	!\.\.\.[^ \t()";]\+!
    167 " ... a special identifier
    168 
    169 syn match	monkConstant	,\*[-a-z!$%&*/:<=>?^_~0-9+.@]*\*[ \t()";],me=e-1
    170 syn match	monkConstant	,\*[-a-z!$%&*/:<=>?^_~0-9+.@]*\*$,
    171 syn match	monkError	,\*[-a-z!$%&*/:<=>?^_~0-9+.@]*\*[^-a-z!$%&*/:<=>?^_~0-9+.@ \t()";]\+[^ \t()";]*,
    172 
    173 syn match	monkConstant	,<[-a-z!$%&*/:<=>?^_~0-9+.@]*>[ \t()";],me=e-1
    174 syn match	monkConstant	,<[-a-z!$%&*/:<=>?^_~0-9+.@]*>$,
    175 syn match	monkError	,<[-a-z!$%&*/:<=>?^_~0-9+.@]*>[^-a-z!$%&*/:<=>?^_~0-9+.@ \t()";]\+[^ \t()";]*,
    176 
    177 " Monk input and output structures
    178 syn match	monkSyntax	"\(\~input\|\[I\]->\)[^ \t]*"
    179 syn match	monkFunc	"\(\~output\|\[O\]->\)[^ \t]*"
    180 
    181 " Non-quoted lists, and strings:
    182 
    183 syn region monkStruc matchgroup=Delimiter start="(" matchgroup=Delimiter end=")" contains=ALL
    184 syn region monkStruc matchgroup=Delimiter start="#(" matchgroup=Delimiter end=")" contains=ALL
    185 
    186 syn region	monkString	start=+"+  skip=+\\[\\"]+ end=+"+
    187 
    188 " Comments:
    189 
    190 syn match	monkComment	";.*$"
    191 
    192 " Synchronization and the wrapping up...
    193 
    194 syn sync match matchPlace grouphere NONE "^[^ \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 
    200 hi def link monkSyntax		Statement
    201 hi def link monkFunc		Function
    202 
    203 hi def link monkString		String
    204 hi def link monkChar		Character
    205 hi def link monkNumber		Number
    206 hi def link monkBoolean		Boolean
    207 
    208 hi def link monkDelimiter	Delimiter
    209 hi def link monkConstant	Constant
    210 
    211 hi def link monkComment		Comment
    212 hi def link monkError		Error
    213 
    214 
    215 let b:current_syntax = "monk"
    216 
    217 let &cpo = s:cpo_save
    218 unlet s:cpo_save