Mercurial > vim
diff runtime/syntax/scheme.vim @ 17:9be87deaeb52 v7.0009
updated for version 7.0009
author | vimboss |
---|---|
date | Fri, 16 Jul 2004 20:18:37 +0000 |
parents | 3fc0f57ecb91 |
children | 404aac550f35 |
line wrap: on
line diff
--- a/runtime/syntax/scheme.vim +++ b/runtime/syntax/scheme.vim @@ -1,11 +1,14 @@ " Vim syntax file " Language: Scheme (R5RS) -" Maintainer: Dirk van Deun <dirk@igwe.vub.ac.be> -" Last Change: April 30, 1998 +" Last Change: July 14, 2004 +" Maintainer: Sergey Khorev <iamphet@nm.ru> +" Original author: Dirk van Deun <dirk@igwe.vub.ac.be> " This script incorrectly recognizes some junk input as numerals: " parsing the complete system of Scheme numerals using the pattern " language is practically impossible: I did a lax approximation. + +" MzScheme extensions can be activated with setting is_mzscheme variable " Suggestions and bug reports are solicited by the author. @@ -23,12 +26,12 @@ syn case ignore " Fascist highlighting: everything that doesn't fit the rules is an error... -syn match schemeError oneline ![^ \t()";]*! +syn match schemeError oneline ![^ \t()\[\]";]*! syn match schemeError oneline ")" " Quoted and backquoted stuff -syn region schemeQuoted matchgroup=Delimiter start="['`]" end=![ \t()";]!me=e-1 contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc +syn region schemeQuoted matchgroup=Delimiter start="['`]" end=![ \t()\[\]";]!me=e-1 contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc syn region schemeQuoted matchgroup=Delimiter start="['`](" matchgroup=Delimiter end=")" contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc syn region schemeQuoted matchgroup=Delimiter start="['`]#(" matchgroup=Delimiter end=")" contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc @@ -36,15 +39,26 @@ syn region schemeQuoted matchgroup=Delim syn region schemeStrucRestricted matchgroup=Delimiter start="(" matchgroup=Delimiter end=")" contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc syn region schemeStrucRestricted matchgroup=Delimiter start="#(" matchgroup=Delimiter end=")" contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc -syn region schemeUnquote matchgroup=Delimiter start="," end=![ \t()";]!me=e-1 contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc -syn region schemeUnquote matchgroup=Delimiter start=",@" end=![ \t()";]!me=e-1 contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc +" Popular Scheme extension: +" using [] as well as () +syn region schemeStrucRestricted matchgroup=Delimiter start="\[" matchgroup=Delimiter end="\]" contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc +syn region schemeStrucRestricted matchgroup=Delimiter start="#\[" matchgroup=Delimiter end="\]" contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc -syn region schemeUnquote matchgroup=Delimiter start=",(" end=")" contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc -syn region schemeUnquote matchgroup=Delimiter start=",@(" end=")" contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc +syn region schemeUnquote matchgroup=Delimiter start="," end=![ \t\[\]()";]!me=e-1 contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc +syn region schemeUnquote matchgroup=Delimiter start=",@" end=![ \t\[\]()";]!me=e-1 contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc + +syn region schemeUnquote matchgroup=Delimiter start=",(" end=")" contains=ALL +syn region schemeUnquote matchgroup=Delimiter start=",@(" end=")" contains=ALL syn region schemeUnquote matchgroup=Delimiter start=",#(" end=")" contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc syn region schemeUnquote matchgroup=Delimiter start=",@#(" end=")" contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc +syn region schemeUnquote matchgroup=Delimiter start=",\[" end="\]" contains=ALL +syn region schemeUnquote matchgroup=Delimiter start=",@\[" end="\]" contains=ALL + +syn region schemeUnquote matchgroup=Delimiter start=",#\[" end="\]" contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc +syn region schemeUnquote matchgroup=Delimiter start=",@#\[" end="\]" contains=ALLBUT,schemeStruc,schemeSyntax,schemeFunc + " R5RS Scheme Functions and Syntax: if version < 600 @@ -96,63 +110,126 @@ syn keyword schemeFunc dynamic-wind port syn keyword schemeFunc scheme-report-environment null-environment syn keyword schemeFunc interaction-environment -" Writing out the complete description of Scheme numerals without -" using variables is a day's work for a trained secretary... -" This is a useful lax approximation: - -syn match schemeNumber oneline "[-#+0-9.][-#+/0-9a-f@i.boxesfdl]*" -syn match schemeError oneline ![-#+0-9.][-#+/0-9a-f@i.boxesfdl]*[^-#+/0-9a-f@i.boxesfdl \t()";][^ \t()";]*! - -syn match schemeOther oneline ![+-][ \t()";]!me=e-1 -syn match schemeOther oneline ![+-]$! " ... so that a single + or -, inside a quoted context, would not be " interpreted as a number (outside such contexts, it's a schemeFunc) -syn match schemeDelimiter oneline !\.[ \t()";]!me=e-1 +syn match schemeDelimiter oneline !\.[ \t\[\]()";]!me=e-1 syn match schemeDelimiter oneline !\.$! " ... and a single dot is not a number but a delimiter -" Simple literals: - -syn match schemeBoolean oneline "#[tf]" -syn match schemeError oneline !#[tf][^ \t()";]\+! - -syn match schemeChar oneline "#\\" -syn match schemeChar oneline "#\\." -syn match schemeError oneline !#\\.[^ \t()";]\+! -syn match schemeChar oneline "#\\space" -syn match schemeError oneline !#\\space[^ \t()";]\+! -syn match schemeChar oneline "#\\newline" -syn match schemeError oneline !#\\newline[^ \t()";]\+! - " This keeps all other stuff unhighlighted, except *stuff* and <stuff>: -syn match schemeOther oneline ,[a-z!$%&*/:<=>?^_~][-a-z!$%&*/:<=>?^_~0-9+.@]*, -syn match schemeError oneline ,[a-z!$%&*/:<=>?^_~][-a-z!$%&*/:<=>?^_~0-9+.@]*[^-a-z!$%&*/:<=>?^_~0-9+.@ \t()";]\+[^ \t()";]*, +syn match schemeOther oneline ,[a-z!$%&*/:<=>?^_~+@#%-][-a-z!$%&*/:<=>?^_~0-9+.@#%]*, +syn match schemeError oneline ,[a-z!$%&*/:<=>?^_~+@#%-][-a-z!$%&*/:<=>?^_~0-9+.@#%]*[^-a-z!$%&*/:<=>?^_~0-9+.@ \t\[\]()";]\+[^ \t\[\]()";]*, syn match schemeOther oneline "\.\.\." -syn match schemeError oneline !\.\.\.[^ \t()";]\+! +syn match schemeError oneline !\.\.\.[^ \t\[\]()";]\+! " ... a special identifier -syn match schemeConstant oneline ,\*[-a-z!$%&*/:<=>?^_~0-9+.@]*\*[ \t()";],me=e-1 +syn match schemeConstant oneline ,\*[-a-z!$%&*/:<=>?^_~0-9+.@]*\*[ \t\[\]()";],me=e-1 syn match schemeConstant oneline ,\*[-a-z!$%&*/:<=>?^_~0-9+.@]*\*$, -syn match schemeError oneline ,\*[-a-z!$%&*/:<=>?^_~0-9+.@]*\*[^-a-z!$%&*/:<=>?^_~0-9+.@ \t()";]\+[^ \t()";]*, +syn match schemeError oneline ,\*[-a-z!$%&*/:<=>?^_~0-9+.@]*\*[^-a-z!$%&*/:<=>?^_~0-9+.@ \t\[\]()";]\+[^ \t\[\]()";]*, -syn match schemeConstant oneline ,<[-a-z!$%&*/:<=>?^_~0-9+.@]*>[ \t()";],me=e-1 +syn match schemeConstant oneline ,<[-a-z!$%&*/:<=>?^_~0-9+.@]*>[ \t\[\]()";],me=e-1 syn match schemeConstant oneline ,<[-a-z!$%&*/:<=>?^_~0-9+.@]*>$, -syn match schemeError oneline ,<[-a-z!$%&*/:<=>?^_~0-9+.@]*>[^-a-z!$%&*/:<=>?^_~0-9+.@ \t()";]\+[^ \t()";]*, +syn match schemeError oneline ,<[-a-z!$%&*/:<=>?^_~0-9+.@]*>[^-a-z!$%&*/:<=>?^_~0-9+.@ \t\[\]()";]\+[^ \t\[\]()";]*, " Non-quoted lists, and strings: syn region schemeStruc matchgroup=Delimiter start="(" matchgroup=Delimiter end=")" contains=ALL syn region schemeStruc matchgroup=Delimiter start="#(" matchgroup=Delimiter end=")" contains=ALL +syn region schemeStruc matchgroup=Delimiter start="\[" matchgroup=Delimiter end="\]" contains=ALL +syn region schemeStruc matchgroup=Delimiter start="#\[" matchgroup=Delimiter end="\]" contains=ALL + +" Simple literals: syn region schemeString start=+"+ skip=+\\[\\"]+ end=+"+ " Comments: syn match schemeComment ";.*$" + +" Writing out the complete description of Scheme numerals without +" using variables is a day's work for a trained secretary... + +syn match schemeOther oneline ![+-][ \t\[\]()";]!me=e-1 +syn match schemeOther oneline ![+-]$! +" +" This is a useful lax approximation: +syn match schemeNumber oneline "[-#+0-9.][-#+/0-9a-f@i.boxesfdl]*" +syn match schemeError oneline ![-#+0-9.][-#+/0-9a-f@i.boxesfdl]*[^-#+/0-9a-f@i.boxesfdl \t\[\]()";][^ \t\[\]()";]*! + +syn match schemeBoolean oneline "#[tf]" +syn match schemeError oneline !#[tf][^ \t\[\]()";]\+! + +syn match schemeChar oneline "#\\" +syn match schemeChar oneline "#\\." +syn match schemeError oneline !#\\.[^ \t\[\]()";]\+! +syn match schemeChar oneline "#\\space" +syn match schemeError oneline !#\\space[^ \t\[\]()";]\+! +syn match schemeChar oneline "#\\newline" +syn match schemeError oneline !#\\newline[^ \t\[\]()";]\+! + +if exists("b:is_mzscheme") || exists("is_mzscheme") + " MzScheme extensions added by Sergey Khorev + " multiline comment + syntax region schemeMultilineComment start=/#|/ end=/|#/ + " #%xxx are the special MzScheme identifiers + syn match schemeOther oneline "#%[-a-z!$%&*/:<=>?^_~0-9+.@#%]\+" + " anything limited by |'s is identifier + syn match schemeOther oneline "|[^|]\+|" + + syn match schemeChar oneline "#\\return" + + " Modules require stmt + syn keyword schemeExtSyntax module require dynamic-require lib prefix all-except prefix-all-except rename + " modules provide stmt + syn keyword schemeExtSyntax provide struct all-from all-from-except all-defined all-defined-except + " Other from MzScheme + syn keyword schemeExtSyntax with-handlers when unless instantiate define-struct case-lambda syntax-case + syn keyword schemeExtSyntax free-identifier=? bound-identifier=? module-identifier=? syntax-object->datum + syn keyword schemeExtSyntax datum->syntax-object + syn keyword schemeExtSyntax let-values let*-values letrec-values set!-values fluid-let parameterize begin0 + syn keyword schemeExtSyntax error raise opt-lambda define-values unit unit/sig define-signature + syn keyword schemeExtSyntax invoke-unit/sig define-values/invoke-unit/sig compound-unit/sig import export + syn keyword schemeExtSyntax link syntax quasisyntax unsyntax with-syntax + hi def link schemeExtSyntax Type + + syn keyword schemeExtFunc format system-type current-extension-compiler current-extension-linker + syn keyword schemeExtFunc use-standard-linker use-standard-compiler + syn keyword schemeExtFunc find-executable-path append-object-suffix append-extension-suffix + syn keyword schemeExtFunc current-library-collection-paths current-extension-compiler-flags make-parameter + syn keyword schemeExtFunc current-directory build-path normalize-path current-extension-linker-flags + syn keyword schemeExtFunc file-exists? directory-exists? delete-directory/files delete-directory delete-file + syn keyword schemeExtFunc system compile-file system-library-subpath getenv putenv current-standard-link-libraries + syn keyword schemeExtFunc remove* file-size find-files fold-files directory-list shell-execute split-path + syn keyword schemeExtFunc current-error-port process/ports process printf fprintf open-input-string open-output-string + syn keyword schemeExtFunc get-output-string + " exceptions + syn keyword schemeExtFunc exn exn:application:arity exn:application:continuation exn:application:fprintf:mismatch + syn keyword schemeExtFunc exn:application:mismatch exn:application:type exn:application:mismatch exn:break exn:i/o:filesystem exn:i/o:port + syn keyword schemeExtFunc exn:i/o:port:closed exn:i/o:tcp exn:i/o:udp exn:misc exn:misc:application exn:misc:unsupported exn:module exn:read + syn keyword schemeExtFunc exn:read:non-char exn:special-comment exn:syntax exn:thread exn:user exn:variable exn:application:mismatch + syn keyword schemeExtFunc exn? exn:application:arity? exn:application:continuation? exn:application:fprintf:mismatch? exn:application:mismatch? + syn keyword schemeExtFunc exn:application:type? exn:application:mismatch? exn:break? exn:i/o:filesystem? exn:i/o:port? exn:i/o:port:closed? + syn keyword schemeExtFunc exn:i/o:tcp? exn:i/o:udp? exn:misc? exn:misc:application? exn:misc:unsupported? exn:module? exn:read? exn:read:non-char? + syn keyword schemeExtFunc exn:special-comment? exn:syntax? exn:thread? exn:user? exn:variable? exn:application:mismatch? + " Command-line parsing + syn keyword schemeExtFunc command-line current-command-line-arguments once-any help-labels multi once-each + hi def link schemeExtFunc PreProc + + " syntax quoting, unquoting and quasiquotation + syn region schemeUnquote matchgroup=Delimiter start="#," end=![ \t\[\]()";]!me=e-1 contains=ALL + syn region schemeUnquote matchgroup=Delimiter start="#,@" end=![ \t\[\]()";]!me=e-1 contains=ALL + syn region schemeUnquote matchgroup=Delimiter start="#,(" end=")" contains=ALL + syn region schemeUnquote matchgroup=Delimiter start="#,@(" end=")" contains=ALL + syn region schemeUnquote matchgroup=Delimiter start="#,\[" end="\]" contains=ALL + syn region schemeUnquote matchgroup=Delimiter start="#,@\[" end="\]" contains=ALL + syn region schemeQuoted matchgroup=Delimiter start="#['`]" end=![ \t()\[\]";]!me=e-1 contains=ALL + syn region schemeQuoted matchgroup=Delimiter start="#['`](" matchgroup=Delimiter end=")" contains=ALL +endif + " Synchronization and the wrapping up... syn sync match matchPlace grouphere NONE "^[^ \t]" @@ -181,6 +258,7 @@ if version >= 508 || !exists("did_scheme HiLink schemeConstant Constant HiLink schemeComment Comment + HiLink schemeMultilineComment Comment HiLink schemeError Error delcommand HiLink