2 " Language: Oracle Procedureal SQL (PL/SQL)
3 " Maintainer: Jeff Lanzarotta (jefflanzarotta at yahoo dot com)
4 " Original Maintainer: C. Laurence Gonsalves (clgonsal@kami.com)
5 " URL: http://lanzarotta.tripod.com/vim/syntax/plsql.vim.zip
6 " Last Change: September 18, 2002
7 " History: Geoff Evans & Bill Pribyl (bill at plnet dot org)
9 " Austin Ziegler (austin at halostatue dot ca)
12 " For version 5.x, clear all syntax items.
13 " For version 6.x, quit when a syntax file was already loaded.
16 elseif exists("b:current_syntax")
21 syn keyword plsqlTodo TODO FIXME XXX DEBUG NOTE
22 syn cluster plsqlCommentGroup contains=plsqlTodo
26 syn match plsqlGarbage "[^ \t()]"
27 syn match plsqlIdentifier "[a-z][a-z0-9$_#]*"
28 syn match plsqlHostIdentifier ":[a-z][a-z0-9$_#]*"
30 " When wanted, highlight the trailing whitespace.
31 if exists("c_space_errors")
32 if !exists("c_no_trail_space_error")
33 syn match plsqlSpaceError "\s\+$"
36 if !exists("c_no_tab_space_error")
37 syn match plsqlSpaceError " \+\t"me=e-1
42 syn match plsqlSymbol "\(;\|,\|\.\)"
45 syn match plsqlOperator "\(+\|-\|\*\|/\|=\|<\|>\|@\|\*\*\|!=\|\~=\)"
46 syn match plsqlOperator "\(^=\|<=\|>=\|:=\|=>\|\.\.\|||\|<<\|>>\|\"\)"
48 " Some of Oracle's SQL keywords.
49 syn keyword plsqlSQLKeyword ABORT ACCESS ACCESSED ADD AFTER ALL ALTER AND ANY
50 syn keyword plsqlSQLKeyword AS ASC ATTRIBUTE AUDIT AUTHORIZATION AVG BASE_TABLE
51 syn keyword plsqlSQLKeyword BEFORE BETWEEN BY CASCADE CAST CHECK CLUSTER
52 syn keyword plsqlSQLKeyword CLUSTERS COLAUTH COLUMN COMMENT COMPRESS CONNECT
53 syn keyword plsqlSQLKeyword CONSTRAINT CRASH CREATE CURRENT DATA DATABASE
54 syn keyword plsqlSQLKeyword DATA_BASE DBA DEFAULT DELAY DELETE DESC DISTINCT
55 syn keyword plsqlSQLKeyword DROP DUAL ELSE EXCLUSIVE EXISTS EXTENDS EXTRACT
56 syn keyword plsqlSQLKeyword FILE FORCE FOREIGN FROM GRANT GROUP HAVING HEAP
57 syn keyword plsqlSQLKeyword IDENTIFIED IDENTIFIER IMMEDIATE IN INCLUDING
58 syn keyword plsqlSQLKeyword INCREMENT INDEX INDEXES INITIAL INSERT INSTEAD
59 syn keyword plsqlSQLKeyword INTERSECT INTO INVALIDATE IS ISOLATION KEY LIBRARY
60 syn keyword plsqlSQLKeyword LIKE LOCK MAXEXTENTS MINUS MODE MODIFY MULTISET
61 syn keyword plsqlSQLKeyword NESTED NOAUDIT NOCOMPRESS NOT NOWAIT OF OFF OFFLINE
62 syn keyword plsqlSQLKeyword ON ONLINE OPERATOR OPTION OR ORDER ORGANIZATION
63 syn keyword plsqlSQLKeyword PCTFREE PRIMARY PRIOR PRIVATE PRIVILEGES PUBLIC
64 syn keyword plsqlSQLKeyword QUOTA RELEASE RENAME REPLACE RESOURCE REVOKE ROLLBACK
65 syn keyword plsqlSQLKeyword ROW ROWLABEL ROWS SCHEMA SELECT SEPARATE SESSION SET
66 syn keyword plsqlSQLKeyword SHARE SIZE SPACE START STORE SUCCESSFUL SYNONYM
67 syn keyword plsqlSQLKeyword SYSDATE TABLE TABLES TABLESPACE TEMPORARY TO TREAT
68 syn keyword plsqlSQLKeyword TRIGGER TRUNCATE UID UNION UNIQUE UNLIMITED UPDATE
69 syn keyword plsqlSQLKeyword USE USER VALIDATE VALUES VIEW WHENEVER WHERE WITH
71 " PL/SQL's own keywords.
72 syn keyword plsqlKeyword AGENT AND ANY ARRAY ASSIGN AS AT AUTHID BEGIN BODY BY
73 syn keyword plsqlKeyword BULK C CASE CHAR_BASE CHARSETFORM CHARSETID CLOSE
74 syn keyword plsqlKeyword COLLECT CONSTANT CONSTRUCTOR CONTEXT CURRVAL DECLARE
75 syn keyword plsqlKeyword DVOID EXCEPTION EXCEPTION_INIT EXECUTE EXIT FETCH
76 syn keyword plsqlKeyword FINAL FUNCTION GOTO HASH IMMEDIATE IN INDICATOR
77 syn keyword plsqlKeyword INSTANTIABLE IS JAVA LANGUAGE LIBRARY MAP MAXLEN
78 syn keyword plsqlKeyword MEMBER NAME NEW NOCOPY NUMBER_BASE OBJECT OCICOLL
79 syn keyword plsqlKeyword OCIDATE OCIDATETIME OCILOBLOCATOR OCINUMBER OCIRAW
80 syn keyword plsqlKeyword OCISTRING OF OPAQUE OPEN OR ORDER OTHERS OUT
81 syn keyword plsqlKeyword OVERRIDING PACKAGE PARALLEL_ENABLE PARAMETERS
82 syn keyword plsqlKeyword PARTITION PIPELINED PRAGMA PROCEDURE RAISE RANGE REF
83 syn keyword plsqlKeyword RESULT RETURN REVERSE ROWTYPE SB1 SELF SHORT SIZE_T
84 syn keyword plsqlKeyword SQL SQLCODE SQLERRM STATIC STRUCT SUBTYPE TDO THEN
85 syn keyword plsqlKeyword TABLE TIMEZONE_ABBR TIMEZONE_HOUR TIMEZONE_MINUTE
86 syn keyword plsqlKeyword TIMEZONE_REGION TYPE UNDER UNSIGNED USING VARIANCE
87 syn keyword plsqlKeyword VARRAY VARYING WHEN WRITE
88 syn match plsqlKeyword "\<END\>"
89 syn match plsqlKeyword "\.COUNT\>"hs=s+1
90 syn match plsqlKeyword "\.EXISTS\>"hs=s+1
91 syn match plsqlKeyword "\.FIRST\>"hs=s+1
92 syn match plsqlKeyword "\.LAST\>"hs=s+1
93 syn match plsqlKeyword "\.DELETE\>"hs=s+1
94 syn match plsqlKeyword "\.PREV\>"hs=s+1
95 syn match plsqlKeyword "\.NEXT\>"hs=s+1
98 syn keyword plsqlFunction ABS ACOS ADD_MONTHS ASCII ASCIISTR ASIN ATAN ATAN2
99 syn keyword plsqlFunction BFILENAME BITAND CEIL CHARTOROWID CHR COALESCE
100 syn keyword plsqlFunction COMMIT COMMIT_CM COMPOSE CONCAT CONVERT COS COSH
101 syn keyword plsqlFunction COUNT CUBE CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP
102 syn keyword plsqlFunction DBTIMEZONE DECODE DECOMPOSE DEREF DUMP EMPTY_BLOB
103 syn keyword plsqlFunction EMPTY_CLOB EXISTS EXP FLOOR FROM_TZ GETBND GLB
104 syn keyword plsqlFunction GREATEST GREATEST_LB GROUPING HEXTORAW INITCAP
105 syn keyword plsqlFunction INSTR INSTR2 INSTR4 INSTRB INSTRC ISNCHAR LAST_DAY
106 syn keyword plsqlFunction LEAST LEAST_UB LENGTH LENGTH2 LENGTH4 LENGTHB LENGTHC
107 syn keyword plsqlFunction LN LOCALTIME LOCALTIMESTAMP LOG LOWER LPAD
108 syn keyword plsqlFunction LTRIM LUB MAKE_REF MAX MIN MOD MONTHS_BETWEEN
109 syn keyword plsqlFunction NCHARTOROWID NCHR NEW_TIME NEXT_DAY NHEXTORAW
110 syn keyword plsqlFunction NLS_CHARSET_DECL_LEN NLS_CHARSET_ID NLS_CHARSET_NAME
111 syn keyword plsqlFunction NLS_INITCAP NLS_LOWER NLSSORT NLS_UPPER NULLFN NULLIF
112 syn keyword plsqlFunction NUMTODSINTERVAL NUMTOYMINTERVAL NVL POWER
113 syn keyword plsqlFunction RAISE_APPLICATION_ERROR RAWTOHEX RAWTONHEX REF
114 syn keyword plsqlFunction REFTOHEX REPLACE ROLLBACK_NR ROLLBACK_SV ROLLUP ROUND
115 syn keyword plsqlFunction ROWIDTOCHAR ROWIDTONCHAR ROWLABEL RPAD RTRIM
116 syn keyword plsqlFunction SAVEPOINT SESSIONTIMEZONE SETBND SET_TRANSACTION_USE
117 syn keyword plsqlFunction SIGN SIN SINH SOUNDEX SQLCODE SQLERRM SQRT STDDEV
118 syn keyword plsqlFunction SUBSTR SUBSTR2 SUBSTR4 SUBSTRB SUBSTRC SUM
119 syn keyword plsqlFunction SYS_AT_TIME_ZONE SYS_CONTEXT SYSDATE SYS_EXTRACT_UTC
120 syn keyword plsqlFunction SYS_GUID SYS_LITERALTODATE SYS_LITERALTODSINTERVAL
121 syn keyword plsqlFunction SYS_LITERALTOTIME SYS_LITERALTOTIMESTAMP
122 syn keyword plsqlFunction SYS_LITERALTOTZTIME SYS_LITERALTOTZTIMESTAMP
123 syn keyword plsqlFunction SYS_LITERALTOYMINTERVAL SYS_OVER__DD SYS_OVER__DI
124 syn keyword plsqlFunction SYS_OVER__ID SYS_OVER_IID SYS_OVER_IIT
125 syn keyword plsqlFunction SYS_OVER__IT SYS_OVER__TI SYS_OVER__TT
126 syn keyword plsqlFunction SYSTIMESTAMP TAN TANH TO_ANYLOB TO_BLOB TO_CHAR
127 syn keyword plsqlFunction TO_CLOB TO_DATE TO_DSINTERVAL TO_LABEL TO_MULTI_BYTE
128 syn keyword plsqlFunction TO_NCHAR TO_NCLOB TO_NUMBER TO_RAW TO_SINGLE_BYTE
129 syn keyword plsqlFunction TO_TIME TO_TIMESTAMP TO_TIMESTAMP_TZ TO_TIME_TZ
130 syn keyword plsqlFunction TO_YMINTERVAL TRANSLATE TREAT TRIM TRUNC TZ_OFFSET UID
131 syn keyword plsqlFunction UNISTR UPPER UROWID USER USERENV VALUE VARIANCE
132 syn keyword plsqlFunction VSIZE WORK XOR
133 syn match plsqlFunction "\<SYS\$LOB_REPLICATION\>"
136 syn keyword plsqlException ACCESS_INTO_NULL CASE_NOT_FOUND COLLECTION_IS_NULL
137 syn keyword plsqlException CURSOR_ALREADY_OPEN DUP_VAL_ON_INDEX INVALID_CURSOR
138 syn keyword plsqlException INVALID_NUMBER LOGIN_DENIED NO_DATA_FOUND
139 syn keyword plsqlException NOT_LOGGED_ON PROGRAM_ERROR ROWTYPE_MISMATCH
140 syn keyword plsqlException SELF_IS_NULL STORAGE_ERROR SUBSCRIPT_BEYOND_COUNT
141 syn keyword plsqlException SUBSCRIPT_OUTSIDE_LIMIT SYS_INVALID_ROWID
142 syn keyword plsqlException TIMEOUT_ON_RESOURCE TOO_MANY_ROWS VALUE_ERROR
143 syn keyword plsqlException ZERO_DIVIDE
145 " Oracle Pseudo Colums.
146 syn keyword plsqlPseudo CURRVAL LEVEL NEXTVAL ROWID ROWNUM
148 if exists("plsql_highlight_triggers")
149 syn keyword plsqlTrigger INSERTING UPDATING DELETING
153 syn keyword plsqlConditional ELSIF ELSE IF
154 syn match plsqlConditional "\<END\s\+IF\>"
157 syn keyword plsqlRepeat FOR LOOP WHILE FORALL
158 syn match plsqlRepeat "\<END\s\+LOOP\>"
160 " Various types of comments.
161 if exists("c_comment_strings")
162 syntax match plsqlCommentSkip contained "^\s*\*\($\|\s\+\)"
163 syntax region plsqlCommentString contained start=+L\="+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=plsqlCommentSkip
164 syntax region plsqlComment2String contained start=+L\="+ skip=+\\\\\|\\"+ end=+"+ end="$"
165 syntax region plsqlCommentL start="--" skip="\\$" end="$" keepend contains=@plsqlCommentGroup,plsqlComment2String,plsqlCharLiteral,plsqlBooleanLiteral,plsqlNumbersCom,plsqlSpaceError
166 syntax region plsqlComment start="/\*" end="\*/" contains=@plsqlCommentGroup,plsqlComment2String,plsqlCharLiteral,plsqlBooleanLiteral,plsqlNumbersCom,plsqlSpaceError
168 syntax region plsqlCommentL start="--" skip="\\$" end="$" keepend contains=@plsqlCommentGroup,plsqlSpaceError
169 syntax region plsqlComment start="/\*" end="\*/" contains=@plsqlCommentGroup,plsqlSpaceError
172 syn sync ccomment plsqlComment
173 syn sync ccomment plsqlCommentL
175 " To catch unterminated string literals.
176 syn match plsqlStringError "'.*$"
178 " Various types of literals.
179 syn match plsqlNumbers transparent "\<[+-]\=\d\|[+-]\=\.\d" contains=plsqlIntLiteral,plsqlFloatLiteral
180 syn match plsqlNumbersCom contained transparent "\<[+-]\=\d\|[+-]\=\.\d" contains=plsqlIntLiteral,plsqlFloatLiteral
181 syn match plsqlIntLiteral contained "[+-]\=\d\+"
182 syn match plsqlFloatLiteral contained "[+-]\=\d\+\.\d*"
183 syn match plsqlFloatLiteral contained "[+-]\=\d*\.\d*"
184 syn match plsqlCharLiteral "'[^']'"
185 syn match plsqlStringLiteral "'\([^']\|''\)*'"
186 syn keyword plsqlBooleanLiteral TRUE FALSE NULL
188 " The built-in types.
189 syn keyword plsqlStorage ANYDATA ANYTYPE BFILE BINARY_INTEGER BLOB BOOLEAN
190 syn keyword plsqlStorage BYTE CHAR CHARACTER CLOB CURSOR DATE DAY DEC DECIMAL
191 syn keyword plsqlStorage DOUBLE DSINTERVAL_UNCONSTRAINED FLOAT HOUR
192 syn keyword plsqlStorage INT INTEGER INTERVAL LOB LONG MINUTE
193 syn keyword plsqlStorage MLSLABEL MONTH NATURAL NATURALN NCHAR NCHAR_CS NCLOB
194 syn keyword plsqlStorage NUMBER NUMERIC NVARCHAR PLS_INT PLS_INTEGER
195 syn keyword plsqlStorage POSITIVE POSITIVEN PRECISION RAW REAL RECORD
196 syn keyword plsqlStorage SECOND SIGNTYPE SMALLINT STRING SYS_REFCURSOR TABLE TIME
197 syn keyword plsqlStorage TIMESTAMP TIMESTAMP_UNCONSTRAINED
198 syn keyword plsqlStorage TIMESTAMP_TZ_UNCONSTRAINED
199 syn keyword plsqlStorage TIMESTAMP_LTZ_UNCONSTRAINED UROWID VARCHAR
200 syn keyword plsqlStorage VARCHAR2 YEAR YMINTERVAL_UNCONSTRAINED ZONE
202 " A type-attribute is really a type.
203 syn match plsqlTypeAttribute "%\(TYPE\|ROWTYPE\)\>"
205 " All other attributes.
206 syn match plsqlAttribute "%\(BULK_EXCEPTIONS\|BULK_ROWCOUNT\|ISOPEN\|FOUND\|NOTFOUND\|ROWCOUNT\)\>"
208 " This'll catch mis-matched close-parens.
209 syn cluster plsqlParenGroup contains=plsqlParenError,@plsqlCommentGroup,plsqlCommentSkip,plsqlIntLiteral,plsqlFloatLiteral,plsqlNumbersCom
210 if exists("c_no_bracket_error")
211 syn region plsqlParen transparent start='(' end=')' contains=ALLBUT,@plsqlParenGroup
212 syn match plsqlParenError ")"
213 syn match plsqlErrInParen contained "[{}]"
215 syn region plsqlParen transparent start='(' end=')' contains=ALLBUT,@plsqlParenGroup,plsqlErrInBracket
216 syn match plsqlParenError "[\])]"
217 syn match plsqlErrInParen contained "[{}]"
218 syn region plsqlBracket transparent start='\[' end=']' contains=ALLBUT,@plsqlParenGroup,plsqlErrInParen
219 syn match plsqlErrInBracket contained "[);{}]"
222 " Syntax Synchronizing
223 syn sync minlines=10 maxlines=100
225 " Define the default highlighting.
226 " For version 5.x and earlier, only when not done already.
227 " For version 5.8 and later, only when an item doesn't have highlighting yet.
228 if version >= 508 || !exists("did_plsql_syn_inits")
230 let did_plsql_syn_inits = 1
231 command -nargs=+ HiLink hi link <args>
233 command -nargs=+ HiLink hi def link <args>
236 HiLink plsqlAttribute Macro
237 HiLink plsqlBlockError Error
238 HiLink plsqlBooleanLiteral Boolean
239 HiLink plsqlCharLiteral Character
240 HiLink plsqlComment Comment
241 HiLink plsqlCommentL Comment
242 HiLink plsqlConditional Conditional
243 HiLink plsqlError Error
244 HiLink plsqlErrInBracket Error
245 HiLink plsqlErrInBlock Error
246 HiLink plsqlErrInParen Error
247 HiLink plsqlException Function
248 HiLink plsqlFloatLiteral Float
249 HiLink plsqlFunction Function
250 HiLink plsqlGarbage Error
251 HiLink plsqlHostIdentifier Label
252 HiLink plsqlIdentifier Normal
253 HiLink plsqlIntLiteral Number
254 HiLink plsqlOperator Operator
255 HiLink plsqlParen Normal
256 HiLink plsqlParenError Error
257 HiLink plsqlSpaceError Error
258 HiLink plsqlPseudo PreProc
259 HiLink plsqlKeyword Keyword
260 HiLink plsqlRepeat Repeat
261 HiLink plsqlStorage StorageClass
262 HiLink plsqlSQLKeyword Function
263 HiLink plsqlStringError Error
264 HiLink plsqlStringLiteral String
265 HiLink plsqlCommentString String
266 HiLink plsqlComment2String String
267 HiLink plsqlSymbol Normal
268 HiLink plsqlTrigger Function
269 HiLink plsqlTypeAttribute StorageClass
270 HiLink plsqlTodo Todo
275 let b:current_syntax = "plsql"