7
|
1 " Vim syntax file
|
6647
|
2 " Language: COBOL
|
|
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
1125
|
4 " (formerly Davyd Ondrejko <vondraco@columbus.rr.com>)
|
7
|
5 " (formerly Sitaram Chamarty <sitaram@diac.com> and
|
6647
|
6 " James Mitchell <james_mitchell@acm.org>)
|
|
7 " Last Change: 2015 Feb 13
|
7
|
8
|
|
9 " For version 5.x: Clear all syntax items
|
|
10 " For version 6.x: Quit when a syntax file was already loaded
|
|
11 if version < 600
|
|
12 syntax clear
|
|
13 elseif exists("b:current_syntax")
|
|
14 finish
|
|
15 endif
|
|
16
|
|
17 " MOST important - else most of the keywords wont work!
|
|
18 if version < 600
|
|
19 set isk=@,48-57,-
|
|
20 else
|
|
21 setlocal isk=@,48-57,-
|
|
22 endif
|
|
23
|
|
24 syn case ignore
|
|
25
|
1125
|
26 syn cluster cobolStart contains=cobolAreaA,cobolAreaB,cobolComment,cobolCompiler
|
|
27 syn cluster cobolAreaA contains=cobolParagraph,cobolSection,cobolDivision
|
|
28 "syn cluster cobolAreaB contains=
|
|
29 syn cluster cobolAreaAB contains=cobolLine
|
|
30 syn cluster cobolLine contains=cobolReserved
|
|
31 syn match cobolMarker "^\%( \{,5\}[^ ]\)\@=.\{,6}" nextgroup=@cobolStart
|
|
32 syn match cobolSpace "^ \{6\}" nextgroup=@cobolStart
|
|
33 syn match cobolAreaA " \{1,4\}" contained nextgroup=@cobolAreaA,@cobolAreaAB
|
|
34 syn match cobolAreaB " \{5,\}\|- *" contained nextgroup=@cobolAreaB,@cobolAreaAB
|
|
35 syn match cobolComment "[/*C].*$" contained
|
|
36 syn match cobolCompiler "$.*$" contained
|
|
37 syn match cobolLine ".*$" contained contains=cobolReserved,@cobolLine
|
|
38
|
|
39 syn match cobolDivision "[A-Z][A-Z0-9-]*[A-Z0-9]\s\+DIVISION\."he=e-1 contained contains=cobolDivisionName
|
|
40 syn keyword cobolDivisionName contained IDENTIFICATION ENVIRONMENT DATA PROCEDURE
|
|
41 syn match cobolSection "[A-Z][A-Z0-9-]*[A-Z0-9]\s\+SECTION\."he=e-1 contained contains=cobolSectionName
|
|
42 syn keyword cobolSectionName contained CONFIGURATION INPUT-OUTPUT FILE WORKING-STORAGE LOCAL-STORAGE LINKAGE
|
|
43 syn match cobolParagraph "\a[A-Z0-9-]*[A-Z0-9]\.\|\d[A-Z0-9-]*[A-Z]\."he=e-1 contained contains=cobolParagraphName
|
|
44 syn keyword cobolParagraphName contained PROGRAM-ID SOURCE-COMPUTER OBJECT-COMPUTER SPECIAL-NAMES FILE-CONTROL I-O-CONTROL
|
|
45
|
|
46
|
|
47 "syn match cobolKeys "^\a\{1,6\}" contains=cobolReserved
|
7
|
48 syn keyword cobolReserved contained ACCEPT ACCESS ADD ADDRESS ADVANCING AFTER ALPHABET ALPHABETIC
|
|
49 syn keyword cobolReserved contained ALPHABETIC-LOWER ALPHABETIC-UPPER ALPHANUMERIC ALPHANUMERIC-EDITED ALS
|
|
50 syn keyword cobolReserved contained ALTERNATE AND ANY ARE AREA AREAS ASCENDING ASSIGN AT AUTHOR BEFORE BINARY
|
|
51 syn keyword cobolReserved contained BLANK BLOCK BOTTOM BY CANCEL CBLL CD CF CH CHARACTER CHARACTERS CLASS
|
|
52 syn keyword cobolReserved contained CLOCK-UNITS CLOSE COBOL CODE CODE-SET COLLATING COLUMN COMMA COMMON
|
1125
|
53 syn keyword cobolReserved contained COMMUNICATIONS COMPUTATIONAL COMPUTE CONTENT CONTINUE
|
|
54 syn keyword cobolReserved contained CONTROL CONVERTING CORR CORRESPONDING COUNT CURRENCY DATE DATE-COMPILED
|
7
|
55 syn keyword cobolReserved contained DATE-WRITTEN DAY DAY-OF-WEEK DE DEBUG-CONTENTS DEBUG-ITEM DEBUG-LINE
|
|
56 syn keyword cobolReserved contained DEBUG-NAME DEBUG-SUB-1 DEBUG-SUB-2 DEBUG-SUB-3 DEBUGGING DECIMAL-POINT
|
|
57 syn keyword cobolReserved contained DELARATIVES DELETE DELIMITED DELIMITER DEPENDING DESCENDING DESTINATION
|
|
58 syn keyword cobolReserved contained DETAIL DISABLE DISPLAY DIVIDE DIVISION DOWN DUPLICATES DYNAMIC EGI ELSE EMI
|
|
59 syn keyword cobolReserved contained ENABLE END-ADD END-COMPUTE END-DELETE END-DIVIDE END-EVALUATE END-IF
|
1125
|
60 syn keyword cobolReserved contained END-MULTIPLY END-OF-PAGE END-READ END-RECEIVE END-RETURN
|
7
|
61 syn keyword cobolReserved contained END-REWRITE END-SEARCH END-START END-STRING END-SUBTRACT END-UNSTRING
|
1125
|
62 syn keyword cobolReserved contained END-WRITE EQUAL ERROR ESI EVALUATE EVERY EXCEPTION EXIT
|
|
63 syn keyword cobolReserved contained EXTEND EXTERNAL FALSE FD FILLER FINAL FIRST FOOTING FOR FROM
|
7
|
64 syn keyword cobolReserved contained GENERATE GIVING GLOBAL GREATER GROUP HEADING HIGH-VALUE HIGH-VALUES I-O
|
1125
|
65 syn keyword cobolReserved contained IN INDEX INDEXED INDICATE INITIAL INITIALIZE
|
|
66 syn keyword cobolReserved contained INITIATE INPUT INSPECT INSTALLATION INTO IS JUST
|
7
|
67 syn keyword cobolReserved contained JUSTIFIED KEY LABEL LAST LEADING LEFT LENGTH LOCK MEMORY
|
|
68 syn keyword cobolReserved contained MERGE MESSAGE MODE MODULES MOVE MULTIPLE MULTIPLY NATIVE NEGATIVE NEXT NO NOT
|
1125
|
69 syn keyword cobolReserved contained NUMBER NUMERIC NUMERIC-EDITED OCCURS OF OFF OMITTED ON OPEN
|
7
|
70 syn keyword cobolReserved contained OPTIONAL OR ORDER ORGANIZATION OTHER OUTPUT OVERFLOW PACKED-DECIMAL PADDING
|
|
71 syn keyword cobolReserved contained PAGE PAGE-COUNTER PERFORM PF PH PIC PICTURE PLUS POINTER POSITION POSITIVE
|
1125
|
72 syn keyword cobolReserved contained PRINTING PROCEDURES PROCEDD PROGRAM PURGE QUEUE QUOTES
|
7
|
73 syn keyword cobolReserved contained RANDOM RD READ RECEIVE RECORD RECORDS REDEFINES REEL REFERENCE REFERENCES
|
|
74 syn keyword cobolReserved contained RELATIVE RELEASE REMAINDER REMOVAL REPLACE REPLACING REPORT REPORTING
|
|
75 syn keyword cobolReserved contained REPORTS RERUN RESERVE RESET RETURN RETURNING REVERSED REWIND REWRITE RF RH
|
|
76 syn keyword cobolReserved contained RIGHT ROUNDED RUN SAME SD SEARCH SECTION SECURITY SEGMENT SEGMENT-LIMITED
|
|
77 syn keyword cobolReserved contained SELECT SEND SENTENCE SEPARATE SEQUENCE SEQUENTIAL SET SIGN SIZE SORT
|
1125
|
78 syn keyword cobolReserved contained SORT-MERGE SOURCE STANDARD
|
7
|
79 syn keyword cobolReserved contained STANDARD-1 STANDARD-2 START STATUS STOP STRING SUB-QUEUE-1 SUB-QUEUE-2
|
|
80 syn keyword cobolReserved contained SUB-QUEUE-3 SUBTRACT SUM SUPPRESS SYMBOLIC SYNC SYNCHRONIZED TABLE TALLYING
|
|
81 syn keyword cobolReserved contained TAPE TERMINAL TERMINATE TEST TEXT THAN THEN THROUGH THRU TIME TIMES TO TOP
|
|
82 syn keyword cobolReserved contained TRAILING TRUE TYPE UNIT UNSTRING UNTIL UP UPON USAGE USE USING VALUE VALUES
|
1125
|
83 syn keyword cobolReserved contained VARYING WHEN WITH WORDS WRITE
|
7
|
84 syn match cobolReserved contained "\<CONTAINS\>"
|
|
85 syn match cobolReserved contained "\<\(IF\|INVALID\|END\|EOP\)\>"
|
|
86 syn match cobolReserved contained "\<ALL\>"
|
|
87
|
1125
|
88 syn cluster cobolLine add=cobolConstant,cobolNumber,cobolPic
|
7
|
89 syn keyword cobolConstant SPACE SPACES NULL ZERO ZEROES ZEROS LOW-VALUE LOW-VALUES
|
|
90
|
1125
|
91 syn match cobolNumber "\<-\=\d*\.\=\d\+\>" contained
|
|
92 syn match cobolPic "\<S*9\+\>" contained
|
|
93 syn match cobolPic "\<$*\.\=9\+\>" contained
|
|
94 syn match cobolPic "\<Z*\.\=9\+\>" contained
|
|
95 syn match cobolPic "\<V9\+\>" contained
|
|
96 syn match cobolPic "\<9\+V\>" contained
|
|
97 syn match cobolPic "\<-\+[Z9]\+\>" contained
|
|
98 syn match cobolTodo "todo" contained containedin=cobolComment
|
7
|
99
|
|
100 " For MicroFocus or other inline comments, include this line.
|
|
101 " syn region cobolComment start="*>" end="$" contains=cobolTodo,cobolMarker
|
|
102
|
1125
|
103 syn match cobolBadLine "[^ D\*$/-].*" contained
|
|
104 " If comment mark somehow gets into column past Column 7.
|
|
105 syn match cobolBadLine "\s\+\*.*" contained
|
|
106 syn cluster cobolStart add=cobolBadLine
|
|
107
|
|
108
|
7
|
109 syn keyword cobolGoTo GO GOTO
|
|
110 syn keyword cobolCopy COPY
|
|
111
|
|
112 " cobolBAD: things that are BAD NEWS!
|
|
113 syn keyword cobolBAD ALTER ENTER RENAMES
|
|
114
|
1125
|
115 syn cluster cobolLine add=cobolGoTo,cobolCopy,cobolBAD,cobolWatch,cobolEXECs
|
|
116
|
7
|
117 " cobolWatch: things that are important when trying to understand a program
|
|
118 syn keyword cobolWatch OCCURS DEPENDING VARYING BINARY COMP REDEFINES
|
|
119 syn keyword cobolWatch REPLACING RUN
|
|
120 syn match cobolWatch "COMP-[123456XN]"
|
|
121
|
|
122 syn keyword cobolEXECs EXEC END-EXEC
|
|
123
|
|
124
|
1125
|
125 syn cluster cobolAreaA add=cobolDeclA
|
|
126 syn cluster cobolAreaAB add=cobolDecl
|
|
127 syn match cobolDeclA "\(0\=1\|77\|78\) " contained nextgroup=cobolLine
|
|
128 syn match cobolDecl "[1-4]\d " contained nextgroup=cobolLine
|
|
129 syn match cobolDecl "0\=[2-9] " contained nextgroup=cobolLine
|
|
130 syn match cobolDecl "66 " contained nextgroup=cobolLine
|
7
|
131
|
1125
|
132 syn match cobolWatch "88 " contained nextgroup=cobolLine
|
7
|
133
|
1125
|
134 "syn match cobolBadID "\k\+-\($\|[^-A-Z0-9]\)" contained
|
7
|
135
|
1125
|
136 syn cluster cobolLine add=cobolCALLs,cobolString,cobolCondFlow
|
|
137 syn keyword cobolCALLs CALL END-CALL CANCEL GOBACK PERFORM END-PERFORM INVOKE
|
7
|
138 syn match cobolCALLs "EXIT \+PROGRAM"
|
|
139 syn match cobolExtras /\<VALUE \+\d\+\./hs=s+6,he=e-1
|
|
140
|
|
141 syn match cobolString /"[^"]*\("\|$\)/
|
|
142 syn match cobolString /'[^']*\('\|$\)/
|
|
143
|
1125
|
144 "syn region cobolLine start="^.\{6}[ D-]" end="$" contains=ALL
|
|
145 syn match cobolIndicator "\%7c[D-]" contained
|
7
|
146
|
|
147 if exists("cobol_legacy_code")
|
6647
|
148 syn region cobolCondFlow contains=ALLBUT,cobolLine,cobolBadLine start="\<\(IF\|INVALID\|END\|EOP\)\>" skip=/\('\|"\)[^"]\{-}\("\|'\|$\)/ end="\." keepend
|
7
|
149 endif
|
|
150
|
|
151 " many legacy sources have junk in columns 1-6: must be before others
|
|
152 " Stuff after column 72 is in error - must be after all other "match" entries
|
|
153 if exists("cobol_legacy_code")
|
1125
|
154 syn match cobolBadLine "\%73c.*" containedin=ALLBUT,cobolComment
|
7
|
155 else
|
1125
|
156 syn match cobolBadLine "\%73c.*" containedin=ALL
|
7
|
157 endif
|
|
158
|
|
159 " Define the default highlighting.
|
|
160 " For version 5.7 and earlier: only when not done already
|
|
161 " For version 5.8 and later: only when an item doesn't have highlighting yet
|
|
162 if version >= 508 || !exists("did_cobol_syntax_inits")
|
|
163 if version < 508
|
|
164 let did_cobol_syntax_inits = 1
|
|
165 command -nargs=+ HiLink hi link <args>
|
|
166 else
|
|
167 command -nargs=+ HiLink hi def link <args>
|
|
168 endif
|
|
169
|
|
170 HiLink cobolBAD Error
|
|
171 HiLink cobolBadID Error
|
|
172 HiLink cobolBadLine Error
|
1125
|
173 if exists("g:cobol_legacy_code")
|
|
174 HiLink cobolMarker Comment
|
|
175 else
|
|
176 HiLink cobolMarker Error
|
|
177 endif
|
7
|
178 HiLink cobolCALLs Function
|
|
179 HiLink cobolComment Comment
|
|
180 HiLink cobolKeys Comment
|
|
181 HiLink cobolAreaB Special
|
|
182 HiLink cobolCompiler PreProc
|
|
183 HiLink cobolCondFlow Special
|
|
184 HiLink cobolCopy PreProc
|
1125
|
185 HiLink cobolDeclA cobolDecl
|
7
|
186 HiLink cobolDecl Type
|
|
187 HiLink cobolExtras Special
|
|
188 HiLink cobolGoTo Special
|
|
189 HiLink cobolConstant Constant
|
|
190 HiLink cobolNumber Constant
|
|
191 HiLink cobolPic Constant
|
|
192 HiLink cobolReserved Statement
|
1125
|
193 HiLink cobolDivision Label
|
|
194 HiLink cobolSection Label
|
|
195 HiLink cobolParagraph Label
|
|
196 HiLink cobolDivisionName Keyword
|
|
197 HiLink cobolSectionName Keyword
|
|
198 HiLink cobolParagraphName Keyword
|
7
|
199 HiLink cobolString Constant
|
|
200 HiLink cobolTodo Todo
|
|
201 HiLink cobolWatch Special
|
1125
|
202 HiLink cobolIndicator Special
|
7
|
203
|
|
204 delcommand HiLink
|
|
205 endif
|
|
206
|
|
207 let b:current_syntax = "cobol"
|
|
208
|
|
209 " vim: ts=6 nowrap
|