2 " Language: SAP - ABAP/R4
4 " Maintainer: Marius Piedallu van Wyk <lailoken@gmail.com>
5 " Last Change: 2013 Jun 13
6 " Comment: Thanks to EPI-USE Labs for all your assistance. :)
8 " For version < 6.0: Clear all syntax items
9 " For version >= 6.0: Quit when a syntax file was already loaded
12 elseif exists("b:current_syntax")
19 " Symbol Operators (space delimited)
20 syn match abapSymbolOperator "\W+\W"
21 syn match abapSymbolOperator "\W-\W"
22 syn match abapSymbolOperator "\W/\W"
23 syn match abapSymbolOperator "\W%\W"
24 syn match abapSymbolOperator "\W=\W"
25 syn match abapSymbolOperator "\W<\W"
26 syn match abapSymbolOperator "\W>\W"
27 syn match abapSymbolOperator "\W\*\W"
28 syn match abapSymbolOperator "\W[<>]=\W"
29 syn match abapSymbolOperator "\W<>\W"
30 syn match abapSymbolOperator "\W\*\*\W"
31 syn match abapSymbolOperator "\[\]"
32 syn match abapSymbolOperator "->\*\?"
33 syn match abapSymbolOperator "=>"
34 syn match abapSymbolOperator "[()~:,\.&$]"
37 syn region abapCharString matchgroup=abapCharString start="'" end="'" contains=abapCharStringEscape
38 syn match abapCharStringEscape contained "''"
40 syn region abapString matchgroup=abapString start="`" end="`" contains=abapStringEscape
41 syn match abapStringEscape contained "``"
43 syn match abapNumber "\-\=\<\d\+\>"
44 syn region abapHex matchgroup=abapHex start="X'" end="'"
47 setlocal iskeyword=48-57,_,A-Z,a-z,/
49 set iskeyword=48-57,_,A-Z,a-z,/
52 syn match abapNamespace "\</\w\+/"
54 " multi-word statements
55 syn match abapComplexStatement "\<\(WITH\W\+\(HEADER\W\+LINE\|FRAME\|KEY\)\|WITH\)\>"
56 syn match abapComplexStatement "\<NO\W\+STANDARD\W\+PAGE\W\+HEADING\>"
57 syn match abapComplexStatement "\<\(EXIT\W\+FROM\W\+STEP\W\+LOOP\|EXIT\)\>"
58 syn match abapComplexStatement "\<\(BEGIN\W\+OF\W\+\(BLOCK\|LINE\)\|BEGIN\W\+OF\)\>"
59 syn match abapComplexStatement "\<\(END\W\+OF\W\+\(BLOCK\|LINE\)\|END\W\+OF\)\>"
60 syn match abapComplexStatement "\<NO\W\+INTERVALS\>"
61 syn match abapComplexStatement "\<RESPECTING\W\+BLANKS\>"
62 syn match abapComplexStatement "\<SEPARATED\W\+BY\>"
63 syn match abapComplexStatement "\<USING\(\W\+EDIT\W\+MASK\)\?\>"
64 syn match abapComplexStatement "\<WHERE\(\W\+LINE\)\?\>"
65 syn match abapComplexStatement "\<RADIOBUTTON\W\+GROUP\>"
66 syn match abapComplexStatement "\<REF\W\+TO\>"
67 syn match abapComplexStatement "\<\(PUBLIC\|PRIVATE\|PROTECTED\)\(\W\+SECTION\)\?\>"
68 syn match abapComplexStatement "\<DELETING\W\+\(TRAILING\|LEADING\)\>"
69 syn match abapComplexStatement "\<\(ALL\W\+OCCURRENCES\)\|\(\(FIRST\|LAST\)\W\+OCCURRENCE\)\>"
70 syn match abapComplexStatement "\<INHERITING\W\+FROM\>"
71 syn match abapComplexStatement "\<\(UP\W\+\)\?TO\>"
73 " hyphenated-word statements
74 syn match abapComplexStatement "\<LINE-COUNT\>"
75 syn match abapComplexStatement "\<ADD-CORRESPONDING\>"
76 syn match abapComplexStatement "\<AUTHORITY-CHECK\>"
77 syn match abapComplexStatement "\<BREAK-POINT\>"
78 syn match abapComplexStatement "\<CLASS-DATA\>"
79 syn match abapComplexStatement "\<CLASS-METHODS\>"
80 syn match abapComplexStatement "\<CLASS-METHOD\>"
81 syn match abapComplexStatement "\<DIVIDE-CORRESPONDING\>"
82 syn match abapComplexStatement "\<EDITOR-CALL\>"
83 syn match abapComplexStatement "\<END-OF-DEFINITION\>"
84 syn match abapComplexStatement "\<END-OF-PAGE\>"
85 syn match abapComplexStatement "\<END-OF-SELECTION\>"
86 syn match abapComplexStatement "\<FIELD-GROUPS\>"
87 syn match abapComplexStatement "\<FIELD-SYMBOLS\>"
88 syn match abapComplexStatement "\<FUNCTION-POOL\>"
89 syn match abapComplexStatement "\<IS\W\+\(NOT\W\+\)\?\(ASSIGNED\|BOUND\|INITIAL\|SUPPLIED\)\>"
90 syn match abapComplexStatement "\<MOVE-CORRESPONDING\>"
91 syn match abapComplexStatement "\<MULTIPLY-CORRESPONDING\>"
92 syn match abapComplexStatement "\<NEW-LINE\>"
93 syn match abapComplexStatement "\<NEW-PAGE\>"
94 syn match abapComplexStatement "\<NEW-SECTION\>"
95 syn match abapComplexStatement "\<PRINT-CONTROL\>"
96 syn match abapComplexStatement "\<RP-PROVIDE-FROM-LAST\>"
97 syn match abapComplexStatement "\<SELECT-OPTIONS\>"
98 syn match abapComplexStatement "\<SELECTION-SCREEN\>"
99 syn match abapComplexStatement "\<START-OF-SELECTION\>"
100 syn match abapComplexStatement "\<SUBTRACT-CORRESPONDING\>"
101 syn match abapComplexStatement "\<SYNTAX-CHECK\>"
102 syn match abapComplexStatement "\<SYNTAX-TRACE\>"
103 syn match abapComplexStatement "\<TOP-OF-PAGE\>"
104 syn match abapComplexStatement "\<TYPE-POOL\>"
105 syn match abapComplexStatement "\<TYPE-POOLS\>"
106 syn match abapComplexStatement "\<LINE-SIZE\>"
107 syn match abapComplexStatement "\<LINE-COUNT\>"
108 syn match abapComplexStatement "\<MESSAGE-ID\>"
109 syn match abapComplexStatement "\<DISPLAY-MODE\>"
110 syn match abapComplexStatement "\<READ\(-ONLY\)\?\>"
113 syn keyword abapStatement ADD ALIAS ALIASES ASSERT ASSIGN ASSIGNING AT
114 syn keyword abapStatement BACK
115 syn keyword abapStatement CALL CASE CATCH CHECK CLASS CLEAR CLOSE CNT COLLECT COMMIT COMMUNICATION COMPUTE CONCATENATE CONDENSE CONSTANTS CONTINUE CONTROLS CONVERT CREATE CURRENCY
116 syn keyword abapStatement DATA DEFINE DEFINITION DEFERRED DELETE DESCRIBE DETAIL DIVIDE DO
117 syn keyword abapStatement ELSE ELSEIF ENDAT ENDCASE ENDCLASS ENDDO ENDEXEC ENDFORM ENDFUNCTION ENDIF ENDIFEND ENDINTERFACE ENDLOOP ENDMETHOD ENDMODULE ENDON ENDPROVIDE ENDSELECT ENDTRY ENDWHILE EVENT EVENTS EXEC EXIT EXPORT EXPORTING EXTRACT
118 syn keyword abapStatement FETCH FIELDS FORM FORMAT FREE FROM FUNCTION
119 syn keyword abapStatement GENERATE GET
120 syn keyword abapStatement HIDE
121 syn keyword abapStatement IF IMPORT IMPORTING INDEX INFOTYPES INITIALIZATION INTERFACE INTERFACES INPUT INSERT IMPLEMENTATION
122 syn keyword abapStatement LEAVE LIKE LINE LOAD LOCAL LOOP
123 syn keyword abapStatement MESSAGE METHOD METHODS MODIFY MODULE MOVE MULTIPLY
124 syn keyword abapStatement ON OVERLAY OPTIONAL OTHERS
125 syn keyword abapStatement PACK PARAMETERS PERFORM POSITION PROGRAM PROVIDE PUT
126 syn keyword abapStatement RAISE RANGES RECEIVE RECEIVING REDEFINITION REFERENCE REFRESH REJECT REPLACE REPORT RESERVE RESTORE RETURNING ROLLBACK
127 syn keyword abapStatement SCAN SCROLL SEARCH SELECT SET SHIFT SKIP SORT SORTED SPLIT STANDARD STATICS STEP STOP SUBMIT SUBTRACT SUM SUMMARY SUPPRESS
128 syn keyword abapStatement TABLES TIMES TRANSFER TRANSLATE TRY TYPE TYPES
129 syn keyword abapStatement UNASSIGN ULINE UNPACK UPDATE
130 syn keyword abapStatement WHEN WHILE WINDOW WRITE
133 syn keyword abapStatement LINES
134 syn keyword abapStatement INTO GROUP BY HAVING ORDER BY SINGLE
135 syn keyword abapStatement APPENDING CORRESPONDING FIELDS OF TABLE
136 syn keyword abapStatement LEFT RIGHT OUTER INNER JOIN AS CLIENT SPECIFIED BYPASSING BUFFER ROWS CONNECTING
137 syn keyword abapStatement OCCURS STRUCTURE OBJECT PROPERTY
138 syn keyword abapStatement CASTING APPEND RAISING VALUE COLOR
139 syn keyword abapStatement CHANGING EXCEPTION EXCEPTIONS DEFAULT CHECKBOX COMMENT
140 syn keyword abapStatement ID NUMBER FOR TITLE OUTPUT
142 " Special ABAP specific tables:
143 syn match abapSpecialTables "\<\(sy\|\(hrp\|p\|pa\)\d\d\d\d\|t\d\d\d.\|innnn\)-"me=e-1 contained
144 syn match abapStructure "\<\w\+-[^\>]"me=e-2 contains=abapSpecialTables,abapStatement,abapComplexStatement
145 syn match abapField "-\w\+"ms=s+1
148 syn match abapSpecial "<\w\+>"
150 " Abap common constants:
151 syn keyword abapSpecial TRUE FALSE NULL SPACE
154 syn region abapInclude start="include" end="." contains=abapComment
157 syn keyword abapTypes c n i p f d t x string xstring decfloat16 decfloat34
159 " Atritmitic operators
160 syn keyword abapOperator abs sign ceil floor trunc frac acos asin atan cos sin tan
161 syn keyword abapOperator cosh sinh tanh exp log log10 sqrt
164 syn keyword abapStatement strlen xstrlen charlen numofchar dbmaxlen
166 syn keyword abapOperator EQ NE LT LE GT GE NOT AND OR XOR IN LIKE BETWEEN
168 " An error? Not strictly... but cannot think of reason this is intended.
169 syn match abapError "\.\."
172 syn region abapComment start="^\*" end="$" contains=abapTodo
173 syn match abapComment "\".*" contains=abapTodo
174 syn keyword abapTodo contained TODO NOTE
175 syn match abapTodo "\#EC\W\+\w\+"
177 " Define the default highlighting.
178 " For version 5.7 and earlier: only when not done already
179 " For version 5.8 and later: only when an item doesn't have highlighting yet
180 if version >= 508 || !exists("did_abap_syntax_inits")
182 let did_abap_syntax_inits = 1
183 command -nargs=+ HiLink hi link <args>
185 command -nargs=+ HiLink hi def link <args>
188 HiLink abapError Error
189 HiLink abapComment Comment
190 HiLink abapInclude Include
191 HiLink abapStatement Statement
192 HiLink abapComplexStatement Statement
193 HiLink abapSpecial Special
194 HiLink abapNamespace Special
195 HiLink abapSpecialTables Special
196 HiLink abapSymbolOperator abapOperator
197 HiLink abapOperator Operator
198 HiLink abapCharString String
199 HiLink abapString String
200 HiLink abapFloat Float
201 HiLink abapTypes Type
202 HiLink abapSymbol Structure
203 HiLink abapStructure Structure
204 HiLink abapField Variable
205 HiLink abapNumber Number
206 HiLink abapHex Number
211 let b:current_syntax = "abap"