annotate runtime/syntax/sed.vim @ 16338:366978ec2c03 v8.1.1174

patch 8.1.1174: cannot build with Ruby 1.8 commit https://github.com/vim/vim/commit/8dc4c7292364d31cfb8afa8a67984b78b657b192 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 14 19:42:13 2019 +0200 patch 8.1.1174: cannot build with Ruby 1.8 Problem: Cannot build with Ruby 1.8. (Tom G. Christensen) Solution: Include ruby/st.h. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/4257)
author Bram Moolenaar <Bram@vim.org>
date Sun, 14 Apr 2019 19:45:04 +0200
parents 46763b01cd9a
children 3295247d97a5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim syntax file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: sed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Maintainer: Haakon Riiser <hakonrk@fys.uio.no>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 " URL: http://folk.uio.no/hakonrk/vim/syntax/sed.vim
2231
aa6412cab544 Various improvements to undo file code to make it more robust.
Bram Moolenaar <bram@vim.org>
parents: 602
diff changeset
5 " Last Change: 2010 May 29
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 2231
diff changeset
7 " quit when a syntax file was already loaded
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 2231
diff changeset
8 if exists("b:current_syntax")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 syn match sedError "\S"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 syn match sedWhitespace "\s\+" contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 syn match sedSemicolon ";"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 syn match sedAddress "[[:digit:]$]"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 syn match sedAddress "\d\+\~\d\+"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 syn region sedAddress matchgroup=Special start="[{,;]\s*/\(\\/\)\="lc=1 skip="[^\\]\(\\\\\)*\\/" end="/I\=" contains=sedTab,sedRegexpMeta
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 syn region sedAddress matchgroup=Special start="^\s*/\(\\/\)\=" skip="[^\\]\(\\\\\)*\\/" end="/I\=" contains=sedTab,sedRegexpMeta
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 syn match sedComment "^\s*#.*$"
602
111509d2767a updated for version 7.0171
vimboss
parents: 7
diff changeset
21 syn match sedFunction "[dDgGhHlnNpPqQx=]\s*\($\|;\)" contains=sedSemicolon,sedWhitespace
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 syn match sedLabel ":[^;]*"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 syn match sedLineCont "^\(\\\\\)*\\$" contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 syn match sedLineCont "[^\\]\(\\\\\)*\\$"ms=e contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 syn match sedSpecial "[{},!]"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 if exists("highlight_sedtabs")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 syn match sedTab "\t" contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 " Append/Change/Insert
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 syn region sedACI matchgroup=sedFunction start="[aci]\\$" matchgroup=NONE end="^.*$" contains=sedLineCont,sedTab
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 syn region sedBranch matchgroup=sedFunction start="[bt]" matchgroup=sedSemicolon end=";\|$" contains=sedWhitespace
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 syn region sedRW matchgroup=sedFunction start="[rw]" matchgroup=sedSemicolon end=";\|$" contains=sedWhitespace
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 " Substitution/transform with various delimiters
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 syn region sedFlagwrite matchgroup=sedFlag start="w" matchgroup=sedSemicolon end=";\|$" contains=sedWhitespace contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 syn match sedFlag "[[:digit:]gpI]*w\=" contains=sedFlagwrite contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 syn match sedRegexpMeta "[.*^$]" contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 syn match sedRegexpMeta "\\." contains=sedTab contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 syn match sedRegexpMeta "\[.\{-}\]" contains=sedTab contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 syn match sedRegexpMeta "\\{\d\*,\d*\\}" contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 syn match sedRegexpMeta "\\(.\{-}\\)" contains=sedTab contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 syn match sedReplaceMeta "&\|\\\($\|.\)" contains=sedTab contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 " Metacharacters: $ * . \ ^ [ ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 " @ is used as delimiter and treated on its own below
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 let __at = char2nr("@")
2231
aa6412cab544 Various improvements to undo file code to make it more robust.
Bram Moolenaar <bram@vim.org>
parents: 602
diff changeset
49 let __sed_i = char2nr(" ") " ASCII: 32, EBCDIC: 64
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 if has("ebcdic")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 let __sed_last = 255
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 let __sed_last = 126
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 let __sed_metacharacters = '$*.\^[~'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 while __sed_i <= __sed_last
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 let __sed_delimiter = escape(nr2char(__sed_i), __sed_metacharacters)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 if __sed_i != __at
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 exe 'syn region sedAddress matchgroup=Special start=@\\'.__sed_delimiter.'\(\\'.__sed_delimiter.'\)\=@ skip=@[^\\]\(\\\\\)*\\'.__sed_delimiter.'@ end=@'.__sed_delimiter.'I\=@ contains=sedTab'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 exe 'syn region sedRegexp'.__sed_i 'matchgroup=Special start=@'.__sed_delimiter.'\(\\\\\|\\'.__sed_delimiter.'\)*@ skip=@[^\\'.__sed_delimiter.']\(\\\\\)*\\'.__sed_delimiter.'@ end=@'.__sed_delimiter.'@me=e-1 contains=sedTab,sedRegexpMeta keepend contained nextgroup=sedReplacement'.__sed_i
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 exe 'syn region sedReplacement'.__sed_i 'matchgroup=Special start=@'.__sed_delimiter.'\(\\\\\|\\'.__sed_delimiter.'\)*@ skip=@[^\\'.__sed_delimiter.']\(\\\\\)*\\'.__sed_delimiter.'@ end=@'.__sed_delimiter.'@ contains=sedTab,sedReplaceMeta keepend contained nextgroup=sedFlag'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 let __sed_i = __sed_i + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 syn region sedAddress matchgroup=Special start=+\\@\(\\@\)\=+ skip=+[^\\]\(\\\\\)*\\@+ end=+@I\=+ contains=sedTab,sedRegexpMeta
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 syn region sedRegexp64 matchgroup=Special start=+@\(\\\\\|\\@\)*+ skip=+[^\\@]\(\\\\\)*\\@+ end=+@+me=e-1 contains=sedTab,sedRegexpMeta keepend contained nextgroup=sedReplacement64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 syn region sedReplacement64 matchgroup=Special start=+@\(\\\\\|\\@\)*+ skip=+[^\\@]\(\\\\\)*\\@+ end=+@+ contains=sedTab,sedReplaceMeta keepend contained nextgroup=sedFlag
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 " Since the syntax for the substituion command is very similar to the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 " syntax for the transform command, I use the same pattern matching
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 " for both commands. There is one problem -- the transform command
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 " (y) does not allow any flags. To save memory, I ignore this problem.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 syn match sedST "[sy]" nextgroup=sedRegexp\d\+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
10051
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
76 hi def link sedAddress Macro
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
77 hi def link sedACI NONE
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
78 hi def link sedBranch Label
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
79 hi def link sedComment Comment
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
80 hi def link sedDelete Function
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
81 hi def link sedError Error
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
82 hi def link sedFlag Type
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
83 hi def link sedFlagwrite Constant
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
84 hi def link sedFunction Function
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
85 hi def link sedLabel Label
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
86 hi def link sedLineCont Special
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
87 hi def link sedPutHoldspc Function
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
88 hi def link sedReplaceMeta Special
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
89 hi def link sedRegexpMeta Special
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
90 hi def link sedRW Constant
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
91 hi def link sedSemicolon Special
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
92 hi def link sedST Function
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
93 hi def link sedSpecial Special
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
94 hi def link sedWhitespace NONE
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 2231
diff changeset
95 if exists("highlight_sedtabs")
10051
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
96 hi def link sedTab Todo
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 2231
diff changeset
97 endif
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 2231
diff changeset
98 let __sed_i = char2nr(" ") " ASCII: 32, EBCDIC: 64
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 2231
diff changeset
99 while __sed_i <= __sed_last
10051
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
100 exe "hi def link sedRegexp".__sed_i "Macro"
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
101 exe "hi def link sedReplacement".__sed_i "NONE"
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 2231
diff changeset
102 let __sed_i = __sed_i + 1
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 2231
diff changeset
103 endwhile
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
2231
aa6412cab544 Various improvements to undo file code to make it more robust.
Bram Moolenaar <bram@vim.org>
parents: 602
diff changeset
106 unlet __sed_i __sed_last __sed_delimiter __sed_metacharacters
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 let b:current_syntax = "sed"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 " vim: sts=4 sw=4 ts=8