annotate runtime/indent/cobol.vim @ 8769:7ac9d9e98892 v7.4.1673

commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Mar 28 20:53:08 2016 +0200 patch 7.4.1673 Problem: The justify plugin has to be copied or sourced to be used. Solution: Turn it into a package.
author Christian Brabandt <cb@256bit.org>
date Mon, 28 Mar 2016 21:00:07 +0200
parents 7bc41231fbc7
children 63b0b7b79b25
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
1 " Vim indent file
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
2 " Language: cobol
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
3 " Author: Tim Pope <vimNOSPAM@tpope.info>
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
4 " $Id: cobol.vim,v 1.1 2007/05/05 18:08:19 vimboss Exp $
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
5
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
6 if exists("b:did_indent")
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
7 finish
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
8 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
9 let b:did_indent = 1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
10
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
11 setlocal expandtab
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
12 setlocal indentexpr=GetCobolIndent(v:lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
13 setlocal indentkeys&
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
14 setlocal indentkeys+=0<*>,0/,0$,0=01,=~division,=~section,0=~end,0=~then,0=~else,0=~when,*<Return>,.
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
15
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
16 " Only define the function once.
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
17 if exists("*GetCobolIndent")
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
18 finish
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
19 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
20
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
21 let s:skip = 'getline(".") =~ "^.\\{6\\}[*/$-]\\|\"[^\"]*\""'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
22
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
23 function! s:prevgood(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
24 " Find a non-blank line above the current line.
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
25 " Skip over comments.
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
26 let lnum = a:lnum
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
27 while lnum > 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
28 let lnum = prevnonblank(lnum - 1)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
29 let line = getline(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
30 if line !~? '^\s*[*/$-]' && line !~? '^.\{6\}[*/$CD-]'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
31 break
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
32 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
33 endwhile
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
34 return lnum
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
35 endfunction
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
36
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
37 function! s:stripped(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
38 return substitute(strpart(getline(a:lnum),0,72),'^\s*','','')
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
39 endfunction
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
40
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
41 function! s:optionalblock(lnum,ind,blocks,clauses)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
42 let ind = a:ind
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
43 let clauses = '\c\<\%(\<NOT\s\+\)\@<!\%(NOT\s\+\)\=\%('.a:clauses.'\)'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
44 let begin = '\c-\@<!\<\%('.a:blocks.'\)\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
45 let beginfull = begin.'\ze.*\%(\n\%(\s*\%([*/$-].*\)\=\n\)*\)\=\s*\%('.clauses.'\)'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
46 let end = '\c\<end-\%('.a:blocks.'\)\>\|\%(\.\%( \|$\)\)\@='
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
47 let cline = s:stripped(a:lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
48 let line = s:stripped(s:prevgood(a:lnum))
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
49 if cline =~? clauses "&& line !~? '^search\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
50 call cursor(a:lnum,1)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
51 let lastclause = searchpair(beginfull,clauses,end,'bWr',s:skip)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
52 if getline(lastclause) =~? clauses && s:stripped(lastclause) !~? '^'.begin
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
53 let ind = indent(lastclause)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
54 elseif lastclause > 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
55 let ind = indent(lastclause) + &sw
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
56 "let ind = ind + &sw
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
57 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
58 elseif line =~? clauses && cline !~? end
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
59 let ind = ind + &sw
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
60 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
61 return ind
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
62 endfunction
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
63
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
64 function! GetCobolIndent(lnum) abort
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
65 let minshft = 6
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
66 let ashft = minshft + 1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
67 let bshft = ashft + 4
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
68 " (Obsolete) numbered lines
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
69 if getline(a:lnum) =~? '^\s*\d\{6\}\%($\|[ */$CD-]\)'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
70 return 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
71 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
72 let cline = s:stripped(a:lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
73 " Comments, etc. must start in the 7th column
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
74 if cline =~? '^[*/$-]'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
75 return minshft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
76 elseif cline =~# '^[CD]' && indent(a:lnum) == minshft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
77 return minshft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
78 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
79 " Divisions, sections, and file descriptions start in area A
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
80 if cline =~? '\<\(DIVISION\|SECTION\)\%($\|\.\)' || cline =~? '^[FS]D\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
81 return ashft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
82 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
83 " Fields
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
84 if cline =~? '^0*\(1\|77\)\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
85 return ashft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
86 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
87 if cline =~? '^\d\+\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
88 let cnum = matchstr(cline,'^\d\+\>')
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
89 let default = 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
90 let step = -1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
91 while step < 2
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
92 let lnum = a:lnum
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
93 while lnum > 0 && lnum < line('$') && lnum > a:lnum - 500 && lnum < a:lnum + 500
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
94 let lnum = step > 0 ? nextnonblank(lnum + step) : prevnonblank(lnum + step)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
95 let line = getline(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
96 let lindent = indent(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
97 if line =~? '^\s*\d\+\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
98 let num = matchstr(line,'^\s*\zs\d\+\>')
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
99 if 0+cnum == num
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
100 return lindent
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
101 elseif 0+cnum > num && default < lindent + &sw
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
102 let default = lindent + &sw
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
103 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
104 elseif lindent < bshft && lindent >= ashft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
105 break
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
106 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
107 endwhile
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
108 let step = step + 2
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
109 endwhile
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
110 return default ? default : bshft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
111 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
112 let lnum = s:prevgood(a:lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
113 " Hit the start of the file, use "zero" indent.
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
114 if lnum == 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
115 return ashft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
116 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
117 " Initial spaces are ignored
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
118 let line = s:stripped(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
119 let ind = indent(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
120 " Paragraphs. There may be some false positives.
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
121 if cline =~? '^\(\a[A-Z0-9-]*[A-Z0-9]\|\d[A-Z0-9-]*\a\)\.' "\s*$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
122 if cline !~? '^EXIT\s*\.' && line =~? '\.\s*$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
123 return ashft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
124 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
125 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
126 " Paragraphs in the identification division.
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
127 "if cline =~? '^\(PROGRAM-ID\|AUTHOR\|INSTALLATION\|' .
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
128 "\ 'DATE-WRITTEN\|DATE-COMPILED\|SECURITY\)\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
129 "return ashft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
130 "endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
131 if line =~? '\.$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
132 " XXX
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
133 return bshft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
134 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
135 if line =~? '^PERFORM\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
136 let perfline = substitute(line, '\c^PERFORM\s*', "", "")
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
137 if perfline =~? '^\%(\k\+\s\+TIMES\)\=\s*$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
138 let ind = ind + &sw
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
139 elseif perfline =~? '^\%(WITH\s\+TEST\|VARYING\|UNTIL\)\>.*[^.]$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
140 let ind = ind + &sw
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
141 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
142 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
143 if line =~? '^\%(IF\|THEN\|ELSE\|READ\|EVALUATE\|SEARCH\|SELECT\)\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
144 let ind = ind + &sw
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
145 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
146 let ind = s:optionalblock(a:lnum,ind,'ADD\|COMPUTE\|DIVIDE\|MULTIPLY\|SUBTRACT','ON\s\+SIZE\s\+ERROR')
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
147 let ind = s:optionalblock(a:lnum,ind,'STRING\|UNSTRING\|ACCEPT\|DISPLAY\|CALL','ON\s\+OVERFLOW\|ON\s\+EXCEPTION')
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
148 if cline !~? '^AT\s\+END\>' || line !~? '^SEARCH\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
149 let ind = s:optionalblock(a:lnum,ind,'DELETE\|REWRITE\|START\|WRITE\|READ','INVALID\s\+KEY\|AT\s\+END\|NO\s\+DATA\|AT\s\+END-OF-PAGE')
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
150 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
151 if cline =~? '^WHEN\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
152 call cursor(a:lnum,1)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
153 " We also search for READ so that contained AT ENDs are skipped
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
154 let lastclause = searchpair('\c-\@<!\<\%(SEARCH\|EVALUATE\|READ\)\>','\c\<\%(WHEN\|AT\s\+END\)\>','\c\<END-\%(SEARCH\|EVALUATE\|READ\)\>','bW',s:skip)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
155 let g:foo = s:stripped(lastclause)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
156 if s:stripped(lastclause) =~? '\c\<\%(WHEN\|AT\s\+END\)\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
157 "&& s:stripped(lastclause) !~? '^\%(SEARCH\|EVALUATE\|READ\)\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
158 let ind = indent(lastclause)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
159 elseif lastclause > 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
160 let ind = indent(lastclause) + &sw
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
161 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
162 elseif line =~? '^WHEN\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
163 let ind = ind + &sw
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
164 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
165 "I'm not sure why I had this
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
166 "if line =~? '^ELSE\>-\@!' && line !~? '\.$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
167 "let ind = indent(s:prevgood(lnum))
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
168 "endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
169 if cline =~? '^\(END\)\>-\@!'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
170 " On lines with just END, 'guess' a simple shift left
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
171 let ind = ind - &sw
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
172 elseif cline =~? '^\(END-IF\|THEN\|ELSE\)\>-\@!'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
173 call cursor(a:lnum,indent(a:lnum))
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
174 let match = searchpair('\c-\@<!\<IF\>','\c-\@<!\%(THEN\|ELSE\)\>','\c-\@<!\<END-IF\>\zs','bnW',s:skip)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
175 if match > 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
176 let ind = indent(match)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
177 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
178 elseif cline =~? '^END-[A-Z]'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
179 let beginword = matchstr(cline,'\c\<END-\zs[A-Z0-9-]\+')
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
180 let endword = 'END-'.beginword
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
181 let first = 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
182 let suffix = '.*\%(\n\%(\%(\s*\|.\{6\}\)[*/].*\n\)*\)\=\s*'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
183 if beginword =~? '^\%(ADD\|COMPUTE\|DIVIDE\|MULTIPLY\|SUBTRACT\)$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
184 let beginword = beginword . suffix . '\<\%(NOT\s\+\)\=ON\s\+SIZE\s\+ERROR'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
185 let g:beginword = beginword
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
186 let first = 1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
187 elseif beginword =~? '^\%(STRING\|UNSTRING\)$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
188 let beginword = beginword . suffix . '\<\%(NOT\s\+\)\=ON\s\+OVERFLOW'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
189 let first = 1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
190 elseif beginword =~? '^\%(ACCEPT\|DISPLAY\)$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
191 let beginword = beginword . suffix . '\<\%(NOT\s\+\)\=ON\s\+EXCEPTION'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
192 let first = 1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
193 elseif beginword ==? 'CALL'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
194 let beginword = beginword . suffix . '\<\%(NOT\s\+\)\=ON\s\+\%(EXCEPTION\|OVERFLOW\)'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
195 let first = 1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
196 elseif beginword =~? '^\%(DELETE\|REWRITE\|START\|READ\|WRITE\)$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
197 let first = 1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
198 let beginword = beginword . suffix . '\<\%(NOT\s\+\)\=\(INVALID\s\+KEY'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
199 if beginword =~? '^READ'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
200 let first = 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
201 let beginword = beginword . '\|AT\s\+END\|NO\s\+DATA'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
202 elseif beginword =~? '^WRITE'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
203 let beginword = beginword . '\|AT\s\+END-OF-PAGE'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
204 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
205 let beginword = beginword . '\)'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
206 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
207 call cursor(a:lnum,indent(a:lnum))
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
208 let match = searchpair('\c-\@<!\<'.beginword.'\>','','\c\<'.endword.'\>\zs','bnW'.(first? 'r' : ''),s:skip)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
209 if match > 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
210 let ind = indent(match)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
211 elseif cline =~? '^\(END-\(READ\|EVALUATE\|SEARCH\|PERFORM\)\)\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
212 let ind = ind - &sw
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
213 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
214 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
215 return ind < bshft ? bshft : ind
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
216 endfunction