summaryrefslogtreecommitdiff
path: root/runtime/syntax/abap.vim
blob: e48dfc3603d31895150a893b6453263bbddcb3e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
" Vim ABAP syntax file
"    Language: SAP - ABAP/R4
"  Maintainer: Marius Piedallu van Wyk <lailoken@gmail.com>
" Last Change: 2021 Jan 02
"     Comment: Thanks to EPI-USE Labs for all your assistance. :)

" Quit when a syntax file was already loaded
if exists("b:current_syntax")
  finish
endif

" Always ignore case
syn case ignore

" Symbol Operators (space delimited)
syn match   abapSymbolOperator  "\W+\W"
syn match   abapSymbolOperator  "\W-\W"
syn match   abapSymbolOperator  "\W/\W"
syn match   abapSymbolOperator  "\W%\W"
syn match   abapSymbolOperator  "\W=\W"
syn match   abapSymbolOperator  "\W<\W"
syn match   abapSymbolOperator  "\W>\W"
syn match   abapSymbolOperator  "\W\*\W"
syn match   abapSymbolOperator  "\W[<>]=\W"
syn match   abapSymbolOperator  "\W<>\W"
syn match   abapSymbolOperator  "\W\*\*\W"
syn match   abapSymbolOperator  "\[\]"
syn match   abapSymbolOperator  "->\*\?"
syn match   abapSymbolOperator  "=>"
syn match   abapSymbolOperator  "[()~:,\.&$]"

" Literals
syn region  abapCharString matchgroup=abapCharString start="'" end="'" contains=abapCharStringEscape
syn match   abapCharStringEscape contained "''"

syn region  abapString matchgroup=abapString start="`" end="`" contains=abapStringEscape
syn match   abapStringEscape contained "``"

syn match   abapNumber  "\-\=\<\d\+\>"
syn region  abapHex     matchgroup=abapHex start="X'" end="'"

setlocal iskeyword=48-57,_,A-Z,a-z,/

syn match   abapNamespace        "\</\w\+/"

" multi-word statements
syn match   abapComplexStatement "\<\(WITH\W\+\(HEADER\W\+LINE\|FRAME\|KEY\)\|WITH\)\>"
syn match   abapComplexStatement "\<NO\W\+STANDARD\W\+PAGE\W\+HEADING\>"
syn match   abapComplexStatement "\<\(EXIT\W\+FROM\W\+STEP\W\+LOOP\|EXIT\)\>"
syn match   abapComplexStatement "\<\(BEGIN\W\+OF\W\+\(BLOCK\|LINE\)\|BEGIN\W\+OF\)\>"
syn match   abapComplexStatement "\<\(END\W\+OF\W\+\(BLOCK\|LINE\)\|END\W\+OF\)\>"
syn match   abapComplexStatement "\<NO\W\+INTERVALS\>"
syn match   abapComplexStatement "\<RESPECTING\W\+BLANKS\>"
syn match   abapComplexStatement "\<SEPARATED\W\+BY\>"
syn match   abapComplexStatement "\<USING\(\W\+EDIT\W\+MASK\)\?\>"
syn match   abapComplexStatement "\<WHERE\(\W\+LINE\)\?\>"
syn match   abapComplexStatement "\<GET\W\+\(TIME\(\W\+STAMP\)\?\(\W\+FIELD\)\?\|PF-STATUS\|BADI\|BIT\|CONNECTION\|CURSOR\|REFERENCE\W\+OF\)\>"
syn match   abapComplexStatement "\<RADIOBUTTON\W\+GROUP\>"
syn match   abapComplexStatement "\<REF\W\+TO\>"
syn match   abapComplexStatement "\<\(PUBLIC\|PRIVATE\|PROTECTED\)\(\W\+SECTION\)\?\>"
syn match   abapComplexStatement "\<DELETING\W\+\(TRAILING\|LEADING\)\>"
syn match   abapComplexStatement "\<\(ALL\W\+OCCURRENCES\)\|\(\(FIRST\|LAST\)\W\+OCCURRENCE\)\>"
syn match   abapComplexStatement "\<INHERITING\W\+FROM\>"
syn match   abapComplexStatement "\<\(UP\W\+\)\?TO\>"

" hyphenated-word statements
syn match   abapComplexStatement "\<LINE-COUNT\>"
syn match   abapComplexStatement "\<ADD-CORRESPONDING\>"
syn match   abapComplexStatement "\<AUTHORITY-CHECK\>"
syn match   abapComplexStatement "\<BREAK-POINT\>"
syn match   abapComplexStatement "\<CLASS-DATA\>"
syn match   abapComplexStatement "\<CLASS-METHODS\>"
syn match   abapComplexStatement "\<CLASS-METHOD\>"
syn match   abapComplexStatement "\<DIVIDE-CORRESPONDING\>"
syn match   abapComplexStatement "\<EDITOR-CALL\>"
syn match   abapComplexStatement "\<END-OF-DEFINITION\>"
syn match   abapComplexStatement "\<END-OF-PAGE\>"
syn match   abapComplexStatement "\<END-OF-SELECTION\>"
syn match   abapComplexStatement "\<FIELD-GROUPS\>"
syn match   abapComplexStatement "\<FIELD-SYMBOLS\>"
syn match   abapComplexStatement "\<FUNCTION-POOL\>"
syn match   abapComplexStatement "\<IS\W\+\(NOT\W\+\)\?\(ASSIGNED\|BOUND\|INITIAL\|SUPPLIED\)\>"
syn match   abapComplexStatement "\<MOVE-CORRESPONDING\>"
syn match   abapComplexStatement "\<MULTIPLY-CORRESPONDING\>"
syn match   abapComplexStatement "\<NEW-LINE\>"
syn match   abapComplexStatement "\<NEW-PAGE\>"
syn match   abapComplexStatement "\<NEW-SECTION\>"
syn match   abapComplexStatement "\<PRINT-CONTROL\>"
syn match   abapComplexStatement "\<RP-PROVIDE-FROM-LAST\>"
syn match   abapComplexStatement "\<SELECT-OPTIONS\>"
syn match   abapComplexStatement "\<SELECTION-SCREEN\>"
syn match   abapComplexStatement "\<START-OF-SELECTION\>"
syn match   abapComplexStatement "\<SUBTRACT-CORRESPONDING\>"
syn match   abapComplexStatement "\<SYNTAX-CHECK\>"
syn match   abapComplexStatement "\<SYNTAX-TRACE\>"
syn match   abapComplexStatement "\<TOP-OF-PAGE\>"
syn match   abapComplexStatement "\<TYPE-POOL\>"
syn match   abapComplexStatement "\<TYPE-POOLS\>"
syn match   abapComplexStatement "\<LINE-SIZE\>"
syn match   abapComplexStatement "\<LINE-COUNT\>"
syn match   abapComplexStatement "\<MESSAGE-ID\>"
syn match   abapComplexStatement "\<DISPLAY-MODE\>"
syn match   abapComplexStatement "\<READ\(-ONLY\)\?\>"

" ABAP statements
syn keyword abapStatement ADD ALIAS ALIASES ASSERT ASSIGN ASSIGNING AT
syn keyword abapStatement BACK
syn keyword abapStatement CALL CASE CATCH CHECK CLASS CLEAR CLOSE CNT COLLECT COMMIT COMMUNICATION COMPUTE CONCATENATE CONDENSE CONSTANTS CONTINUE CONTROLS CONVERT CREATE CURRENCY
syn keyword abapStatement DATA DEFINE DEFINITION DEFERRED DELETE DESCRIBE DETAIL DIVIDE DO
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
syn keyword abapStatement FETCH FIELDS FORM FORMAT FREE FROM FUNCTION
syn keyword abapStatement GENERATE
syn keyword abapStatement HIDE
syn keyword abapStatement IF IMPORT IMPORTING INDEX INFOTYPES INITIALIZATION INTERFACE INTERFACES INPUT INSERT IMPLEMENTATION 
syn keyword abapStatement LEAVE LIKE LINE LOAD LOCAL LOOP
syn keyword abapStatement MESSAGE METHOD METHODS MODIFY MODULE MOVE MULTIPLY
syn keyword abapStatement ON OVERLAY OPTIONAL OTHERS
syn keyword abapStatement PACK PARAMETERS PERFORM POSITION PROGRAM PROVIDE PUT
syn keyword abapStatement RAISE RANGES RECEIVE RECEIVING REDEFINITION REFERENCE REFRESH REJECT REPLACE REPORT RESERVE RESTORE RETURNING ROLLBACK
syn keyword abapStatement SCAN SCROLL SEARCH SELECT SET SHIFT SKIP SORT SORTED SPLIT STANDARD STATICS STEP STOP SUBMIT SUBTRACT SUM SUMMARY SUPPRESS
syn keyword abapStatement TABLES TIMES TRANSFER TRANSLATE TRY TYPE TYPES
syn keyword abapStatement UNASSIGN ULINE UNPACK UPDATE
syn keyword abapStatement WHEN WHILE WINDOW WRITE

" More statemets
syn keyword abapStatement LINES
syn keyword abapStatement INTO GROUP BY HAVING ORDER BY SINGLE
syn keyword abapStatement APPENDING CORRESPONDING FIELDS OF TABLE
syn keyword abapStatement LEFT RIGHT OUTER INNER JOIN AS CLIENT SPECIFIED BYPASSING BUFFER ROWS CONNECTING
syn keyword abapStatement OCCURS STRUCTURE OBJECT PROPERTY
syn keyword abapStatement CASTING APPEND RAISING VALUE COLOR
syn keyword abapStatement CHANGING EXCEPTION EXCEPTIONS DEFAULT CHECKBOX COMMENT
syn keyword abapStatement ID NUMBER FOR TITLE OUTPUT

" Special ABAP specific tables:
syn match   abapSpecialTables "\<\(sy\|\(hrp\|p\|pa\)\d\d\d\d\|t\d\d\d.\|innnn\)-"me=e-1 contained
syn match   abapStructure     "\<\w\+-[^\>]"me=e-2 contains=abapSpecialTables,abapStatement,abapComplexStatement
syn match   abapField         "-\w\+"ms=s+1

" Pointer
syn match   abapSpecial  "<\w\+>"

" Abap common constants:
syn keyword abapSpecial  TRUE FALSE NULL SPACE

" Includes
syn region abapInclude   start="include" end="." contains=abapComment

" Types
syn keyword abapTypes    c n i int8 p f d t x string xstring decfloat16 decfloat34

" Atritmitic operators
syn keyword abapOperator abs sign ceil floor trunc frac acos asin atan cos sin tan
syn keyword abapOperator cosh sinh tanh exp log log10 sqrt

" String operators
syn keyword abapStatement strlen xstrlen charlen numofchar dbmaxlen

syn keyword abapOperator EQ NE LT LE GT GE NOT AND OR XOR IN LIKE BETWEEN

" An error? Not strictly... but cannot think of reason this is intended.
syn match   abapError    "\.\."

" Comments
syn region  abapComment  start="^\*" end="$" contains=abapTodo
syn match   abapComment  "\".*" contains=abapTodo
syn keyword abapTodo     contained TODO NOTE
syn match   abapTodo     "\#EC\W\+\w\+"

" Define the default highlighting.
" Only when an item doesn't have highlighting yet

hi def link abapError          Error
hi def link abapComment        Comment
hi def link abapInclude        Include
hi def link abapStatement      Statement
hi def link abapComplexStatement      Statement
hi def link abapSpecial        Special
hi def link abapNamespace      Special
hi def link abapSpecialTables  Special
hi def link abapSymbolOperator abapOperator
hi def link abapOperator       Operator
hi def link abapCharString     String
hi def link abapString         String
hi def link abapFloat          Float
hi def link abapTypes          Type
hi def link abapSymbol         Structure
hi def link abapStructure      Structure
hi def link abapField          Variable
hi def link abapNumber         Number
hi def link abapHex            Number


let b:current_syntax = "abap"

" vim: ts=8 sw=2