annotate runtime/indent/cobol.vim @ 19023:9afeb0d2c4ab v8.2.0072

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