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