diff --git a/syntax/rpgle.vim b/syntax/rpgle.vim index c1fd422..159d889 100644 --- a/syntax/rpgle.vim +++ b/syntax/rpgle.vim @@ -1,529 +1,529 @@ -" Vim syntax file -" Language: Free-Form ILE RPG -" Maintainer: Andreas Louv -" Last Change: Oct 21, 2019 -" Version: 81 -" URL: https://github.com/andlrc/rpgle.vim - -if exists('b:current_syntax') - finish -endif - -"runtime! syntax/sqlanywhere.vim -syntax include @esql syntax/sqlanywhere.vim - -let b:current_syntax = 'rpgle' - -syntax case ignore -syntax iskeyword @,48-57,192-255,-,%,*,/,_ - -" Comments {{{ - -syntax match rpgleLineComment '//.*' contains=rpgleSpecialComment - \ contains=@rpgleCommentProps -syntax region rpgleBracketedComment start='/\*' - \ end='\*/' - \ contains=@rpgleCommentProps -" syntax keyword rpgleSpecialComment BESCHREIBUNG AUTHOR ERSTELLDATUM PROGRAMMNUTZEN -" \ ÄNDERUNGSDATUM -syntax match rpgleSpecialComment '\(programmnutzen:\|beschreibung:\|author:\|erstelldatum:\|änderungsdatum:\|beispielaufruf:\|compilebefehl:\)' -syntax cluster rpgleComment contains=rpgleLineComment,rpgleBracketedComment,rpgleSpecialComment - -syntax cluster rpgleCommentProps contains=rpgleTodo,@Spell -syntax keyword rpgleTodo contained TODO FIXME - -syntax match rpgleDsReference '\(\w\+\.\)\+\w\+' contained contains=rpgleDsPath -syntax match rpgleDsReferenceSql ':\(\w\+\.\)\+\w\+' contained contains=rpgleDsPath -syntax match rpgleDsPath '\(\w\|\.\)\+\ze\.' contained nextgroup=rpgledsSeperator -syntax match rpgleDsSeperator '\.' contained nextgroup=rpgleDsItem -syntax match rpgleDsItem '\w\+' contained - -syntax match rpgleSqlReference ':\zs\w\+' contained - -syntax keyword db2SqlKeywords CLOSQLCSR DATFMT -syntax keyword db2SqlValues *ENDMOD *NONE *ISO - -" }}} -" Compiler directive {{{ - -syntax keyword rpglePreProc **FREE - -syntax keyword rpglePreProc /COPY /DEFINE /EJECT /ELSE /ELSEIF /END-FREE - \ /ENDIF /EOF /FREE /IF /INCLUDE /RESTORE /SET - \ /SPACE /TITLE /UNDEFINE /SET - \ nextgroup=rpglePreProcValue - -syntax match rpglePreProcValue /.*/ contained display - -" }}} -" Header Specs {{{ - -" CTL-OPT ... ; -syntax region rpgleCtlSpec matchgroup=rpgleKeywords - \ start=/\/ - \ end=/;/ - \ contains=@rpgleCtlProps -syntax cluster rpgleCtlProps contains=rpgleCtlKeywords,rpgleNumber, - \@rpgleString,rpgleConstant,rpgleError, - \rpgleCtlParanBalance - -syntax region rpgleCtlParanBalance matchgroup=xxx - \ start=/(/ - \ end=/)/ - \ contains=@rpgleCtlProps - -" Header Keywords -syntax keyword rpgleCtlKeywords contained - \ ALLOC ACTGRP ALTSEQ ALWNULL AUT BNDDIR CCSID - \ CCSIDCVT COPYNEST COPYRIGHT CURSYM CVTOPT - \ DATEDIT DATFMT DCLOPT DEBUG DECEDIT DECPREC - \ DFTACTGRP DFTNAME ENBPFRCOL EXPROPTS - \ EXTBININT FIXNBR FLYDIV FORMSALIGN FTRANS - \ GENLVL INDENT INTPREC LANGID MAIN NOMAIN - \ OPENOPT OPTIMIZE OPTION PGMINFO PRFDTA - \ SRTSEQ STGMDL TEXT THREAD TIMFMT TRUNCNBR - \ USERPRF VALIDATE REQPREXP - -" }}} -" Declaration Specs {{{ - -" Numbers and Strings - -syntax match rpgleNumber display - \ /\<-\=\%(\d\|\.\)\+\>/ - -syntax match rpgleError /\%(^\|\W\)\@1<='\_.\{-}'\W\@=/ -syntax match rpgleString /'\([+-]\n\|''\|[^']\)*'/ contains=rpgleStringProps -syntax cluster rpgleString contains=rpgleString - -if get(g:, 'rpgle_spellString', 1) - syntax cluster rpgleStringProps contains=@Spell -endif - -" Constants -syntax keyword rpgleConstant *ALL *BLANK *BLANKS *ENTRY *HIVAL *LOVAL *NULL - \ *OFF *ON *ZERO *ZEROS *LOCK *ISO0 *HMS0 *EUR *UTF8 - \ *SYS *OMIT *ALLOC *REQUIRE *WARN *PROC *DATA - -" *IN01 .. *IN99, *INH1 .. *INH9, *INL1 .. *INL9, *INLR, *INRT -syntax match rpgleSpecialKey display /\%(\*IN0[1-9]\|\*IN[1-9][0-9]\)/ -syntax match rpgleSpecialKey display /\*INH[1-9]/ -syntax match rpgleSpecialKey display /\*INL[1-9]/ -syntax match rpgleSpecialKey display /\*INU[1-8]/ -syntax keyword rpgleSpecialKey *INLR *INRT - -" Operators -syntax match rpgleOperator display /<>/ -syntax match rpgleOperator display />=/ -syntax match rpgleOperator display /<=/ -syntax match rpgleOperator display /\/ -syntax match rpgleOperator display /\/ -syntax match rpgleOperator display /\/ -syntax match rpgleOperator display /\/ -syntax match rpgleOperator display /\/ -syntax match rpgleOperator display /[*=><+]/ -syntax match rpgleOperator display /\<-\>/ - -" Standalone, Constant -syntax region rpgleDclSpec display matchgroup=rpgleDclKeywords - \ start=/\/ - \ end=/$/ - \ contains=rpgleDclProp - -" Procedure Interface -syntax keyword rpgleError END-PI -syntax region rpgleDclSpec matchgroup=rpgleDclKeywords - \ keepend - \ start=/\/ - \ end=/\/ - \ contains=rpgleDclProp,rpgleDclPiName - \ fold - -" Special PI Name -syntax keyword rpgleDclPiName *N - -" Prototype -syntax keyword rpgleError END-PR -syntax region rpgleDclSpec matchgroup=rpgleDclKeywords - \ keepend - \ start=/\/ - \ end=/\(\\|OVERLOAD\)/ - \ contains=rpgleDclProp - \ fold - -" Data Structure -syntax keyword rpgleError LIKEDS LIKEREC END-DS - -syntax keyword rpgleError ;; - -syntax region rpgleDclSpec matchgroup=rpgleDclKeywords - \ keepend - \ start=/\/ - \ end=/\/ - \ contains=rpgleDclProp - -syntax region rpgleDclSpec matchgroup=rpgleDclKeywords - \ keepend - \ start=/\/ - \ end=/\/ - \ contains=rpgleDclProp - -" These this syntax regions cannot be "display", even though it is on one line, -" as the rule above could be matched wrongly then. -syntax region rpgleDclSpec matchgroup=rpgleDclKeywords - \ start=/\\ze.*LIKEDS/ - \ start=/\\ze.*LIKEREC/ - \ end=/$/ - \ contains=rpgleDclProp - -" Declaration Types -syntax keyword rpgleDclTypes contained - \ BINDEC CHAR DATE DATE FLOAT GRAPH IND INT OBJECT - \ PACKED POINTER TIME TIMESTAMP UCS2 UCS2 UNS - \ VARCHAR VARGRAPH VARUCS2 ZONED - -" Declaration Keywords -syntax keyword rpgleDclKeywords contained - \ ALIAS ALIGN ALT ALTSEQ ASCEND BASED CCSID - \ CLASS CONST CTDATA DATFMT DESCEND DIM DTAARA - \ EXPORT EXT EXTFLD EXTFMT EXTNAME EXTPGM - \ EXTPROC FROMFILE IMPORT INZ LEN LIKE LIKEDS - \ LIKEFILE LIKEREC NOOPT NULLIND OCCURS OPDESC - \ OPTIONS OVERLAY PACKEVEN PERRCD POS PREFIX - \ PSDS QUALIFIED RTNPARM STATIC TEMPLATE TIMFMT - \ TOFILE VALUE PRINTER USROPN OFLIND INDDS WORKSTN - \ SFILE INFDS SQLTYPE OVERLOAD - - -" Declaration Constants -syntax keyword rpgleDclSpecialKeys contained - \ *NOPASS *OMIT *VARSIZE *STRING *RIGHTADJ *AUTO *VAR *DCLCASE *EXACT - \ *TRIM - -syntax keyword rpgleDclSqlTypes contained - \ CLOB CLOB_LOCATOR DBCLOB DBCLOB_LOCATOR - \ BLOB BLOB_LOCATOR - \ BINARY VARBINARY - \ XML_CLOB XML_DBCLOB XML_BLOB XML_LOCATOR - \ XML_BLOB_FILE XML_CLOB_FILE XML_DBCLOB_FILE - \ BLOB_FILE CLOB_FILE DBCLOB_FILE - \ ROW_ID RESULT_SET_LOCATOR - -syntax region rpgleDclParenBalance matchgroup=rpgleDclBrackets - \ start=/(/ - \ end=/)/ - \ contains=@rpgleComment,rpgleDclSpecialKeys,rpgleDclSqlTypes, - \rpgleNumber,@rpgleString, - \rpgleConstant,rpgleError, - \rpgleDclParenBalance,rpgleBIF - - -syntax match rpgleDclProp /\s*/ contained nextgroup=rpgleDclPropName -syntax match rpgleDclPropName /\k\+/ contained nextgroup=rpgleDclPropTail - \ contains=@rpgleComment -syntax match rpgleDclPropTail /.\+/ contained - \ contains=@rpgleComment,rpgleDclTypes, - \rpgleDclKeywords,rpgleError, - \rpgleDclParenBalance - -" }}} -" Calculation Specs {{{ - -" IF ... ENDIF -syntax keyword rpgleError ENDIF -syntax region rpgleIf matchgroup=rpgleConditional - \ start=/\/ - \ end=/\/ - \ contains=@rpgleNest,rpgleElse - \ fold - -" ELSE ELSEIF -syntax keyword rpgleError ELSE ELSEIF -syntax keyword rpgleElse contained ELSE ELSEIF - -" NOT, AND, OR -syntax keyword rpgleConditional NOT AND OR - -" DOW .. ENDDO, DOU .. ENDDO -syntax keyword rpgleError ENDDO -syntax region rpgleDo matchgroup=rpgleRepeat - \ start=/\/ - \ end=/\/ - \ contains=@rpgleNest - \ fold - -" FOR ... ENDFOR -syntax region rpgleFor matchgroup=rpgleRepeat - \ start=/\/ - \ end=/\/ - \ contains=@rpgleNest - \ fold -syntax keyword rpgleError ENDFOR - -syntax region rpgleForEach matchgroup=rpgleRepeat - \ start=/\/ - \ end=/\/ - \ contains=@rpgleNest - \ fold - -" ITER, LEAVE -syntax keyword rpgleRepeat contained ITER LEAVE - -" MONITOR ... ENDMON -syntax keyword rpgleError ENDMON -syntax region rpgleMonitor matchgroup=rpgleConditional - \ start=/\/ - \ end=/\/ - \ contains=@rpgleNest,rpgleOnError - \ fold - -" ON-ERROR -syntax keyword rpgleError ON-ERROR -syntax keyword rpgleOnError contained ON-ERROR - -" ON-EXIT -syntax keyword rpgleOnExit contained ON-EXIT - -" SELECT ... ENDSL -syntax keyword rpgleError ENDSL -syntax region rpgleSelect matchgroup=rpgleKeywords - \ start=/\/ - \ end=/\/ - \ contains=@rpgleNest,rpgleWhenOther - \ fold - -" WHEN, OTHER -syntax keyword rpgleError WHEN OTHER -syntax keyword rpgleWhenOther contained WHEN OTHER - -" Exec SQL -syntax region rpgleSql matchgroup=rpgleKeywords - \ start=/\/ - \ end=/;/ - \ contains=@esql,rpgleDsReferenceSql,rpgleSqlReference,db2SqlKeywords, - \ db2SqlValues - -" Build In Functions -syntax match rpgleError /%\w\+/ - -syntax keyword rpgleBIF %ABS - \ %ADDR - \ %ALLOC - \ %BITAND - \ %BITNOT - \ %BITOR - \ %BITXOR - \ %CHAR - \ %CHECK - \ %CHECKR - \ %DATA - \ %GEN - \ %OKEDOKE - \ %DATE - \ %DAYS - \ %DEC - \ %DECH - \ %DECPOS - \ %DIFF - \ %DIV - \ %EDITC - \ %EDITFLT - \ %EDITW - \ %ELEM - \ %EOF - \ %EQUAL - \ %ERROR - \ %FIELDS - \ %FLOAT - \ %FOUND - \ %GRAPH - \ %HANDLER - \ %HOURS - \ %INT - \ %INTH - \ %KDS - \ %LEN - \ %LOOKUP - \ %LOOKUPLT - \ %LOOKUPLE - \ %LOOKUPGT - \ %LOOKUPGE - \ %MAX - \ %MIN - \ %MINUTES - \ %MONTHS - \ %MSECONDS - \ %NULLIND - \ %OCCUR - \ %OPEN - \ %PADDR - \ %PARMS - \ %PARMNUM - \ %PARSER - \ %PROC - \ %REALLOC - \ %REM - \ %REPLACE - \ %SCAN - \ %SCANR - \ %SCANRPL - \ %SECONDS - \ %SHTDN - \ %SIZE - \ %SQRT - \ %STATUS - \ %STR - \ %SUBARR - \ %SUBDT - \ %SUBST - \ %THIS - \ %TIME - \ %TIMESTAMP - \ %TLOOKUPxx - \ %TRIM - \ %TRIML - \ %TRIMR - \ %UCS2 - \ %UNS - \ %UNSH - \ %XFOOT - \ %XLATE - \ %XML - \ %YEARS - \ %RANGE - \ %LIST - \ %UPPER - \ %LOWER - -" Procedures, the match group is to avoid infinite recursion as a -" ``rpgleProcCall'' can be within another ``rpgleProcCall'' -syntax match rpgleError /)/ -syntax region rpgleProcCall matchgroup=rpgleProcCallName - \ start=/%\@1/ - \ end=/\/ - \ contains=@rpgleNest - \ fold - -" EXSR -syntax keyword rpgleKeywords EXSR - -" }}} -" Procedure Specs {{{ - -syntax region rpgleDclProcBody matchgroup=rpgleDclProc - \ start=/\/ - \ end=/\/ - \ contains=@rpgleDclProcNest - \ fold -syntax cluster rpgleDclProcNest contains=@rpgleNest,rpgleSub,rpgleDclSpec, - \rpgleDclProcName,rpgleError,rpgleOnExit -syntax keyword rpgleError END-PROC - -" Procedure Name -syntax match rpgleDclProcName display contained skipwhite - \ /\%(DCL-PROC\s\+\)\@10<=\w\+/ - \ nextgroup=rpgleDclProcExport - -" Export -syntax keyword rpgleDclProcExport contained EXPORT - -" }}} - -syntax region rpgleParenBalance matchgroup=rpgleBIFBrackets - \ start=/(/ - \ end=/)/ - \ contains=@rpgleNest - -" All nestable groups, i.e. mostly Calculation Spec keywords: -syntax cluster rpgleNest contains=rpgleBIF,@rpgleComment,rpgleConditional, - \rpgleConstant,rpgleDo,rpgleFor,rpgleForEach,rpgleIf, - \rpgleKeywords,rpgleMonitor,rpgleNumber, - \rpgleOperator,rpglePreProc,rpgleProcCall, - \rpgleRepeat,rpgleSelect,rpgleSpecialKey, - \rpgleSql,@rpgleString,rpgleError, - \rpgleParenBalance,rpgleDsReference - -"syntax match rpgleDclProcName display skipwhite /\k*\ze\((.*)\)/ - -syntax sync fromstart - -highlight link rpgleProcCallName Function -highlight link rpgleError Error -highlight link rpglePreProc PreProc -highlight link rpgleProc Function -highlight link rpgleSpecialKey SpecialKey -highlight link rpgleNumber Number -highlight link rpgleString String -highlight link rpgleOperator Operator -highlight link rpgleComment Comment -highlight link rpgleSpecialComment SpecialComment -highlight link rpgleTodo Todo -highlight link rpgleConstant Constant -highlight link rpgleConditional Conditional -highlight link rpgleRepeat Repeat -highlight link rpgleKeywords Keyword -highlight link rpgleSpecial Special -highlight link rpgleTypes Type -highlight link rpgleDsReference Operator -highlight link rpgleDsPath PreProc -highlight link rpgleDsItem Identifier -highlight link rpgleSqlReference Identifier -highlight link db2SqlKeywords Conditional -highlight link db2SqlValues PreProc - -highlight link rpgleLineComment rpgleComment -highlight link rpgleBracketedComment rpgleComment - -highlight link rpgleCtlKeywords rpgleKeywords -highlight link rpgleDclTypes rpgleTypes -highlight link rpgleDclSqlTypes rpgleTypes -highlight link rpgleDclKeywords rpgleKeywords -highlight link rpgleDclProc rpgleKeywords -highlight link rpgleDclProcExport rpgleKeywords -highlight link rpgleDclProcName rpgleProc -highlight link rpgleDclPiName rpgleSpecial -highlight link rpgleDclSpecialKeys rpgleSpecialKey -highlight link rpgleElse rpgleConditional -highlight link rpgleOnError rpgleKeywords -highlight link rpgleOnExit rpgleKeywords -highlight link rpgleWhenOther rpgleKeywords -highlight link rpgleBIF rpgleSpecial -highlight link rpgleBIFBrackets rpgleSpecial -highlight link rpgleDclBrackets Comment - -highlight link rpgleDclPropName Constant - -" vim: foldmethod=marker +" Vim syntax file +" Language: Free-Form ILE RPG +" Maintainer: Andreas Louv +" Last Change: Oct 21, 2019 +" Version: 81 +" URL: https://github.com/andlrc/rpgle.vim + +if exists('b:current_syntax') + finish +endif + +"runtime! syntax/sqlanywhere.vim +syntax include @esql syntax/sqlanywhere.vim + +let b:current_syntax = 'rpgle' + +syntax case ignore +syntax iskeyword @,48-57,192-255,-,%,*,/,_ + +" Comments {{{ + +syntax match rpgleLineComment '//.*' contains=rpgleSpecialComment + \ contains=@rpgleCommentProps +syntax region rpgleBracketedComment start='/\*' + \ end='\*/' + \ contains=@rpgleCommentProps +" syntax keyword rpgleSpecialComment BESCHREIBUNG AUTHOR ERSTELLDATUM PROGRAMMNUTZEN +" \ ÄNDERUNGSDATUM +syntax match rpgleSpecialComment '\(programmnutzen:\|beschreibung:\|author:\|erstelldatum:\|änderungsdatum:\|beispielaufruf:\|compilebefehl:\)' +syntax cluster rpgleComment contains=rpgleLineComment,rpgleBracketedComment,rpgleSpecialComment + +syntax cluster rpgleCommentProps contains=rpgleTodo,@Spell +syntax keyword rpgleTodo contained TODO FIXME + +syntax match rpgleDsReference '\(\w\+\.\)\+\w\+' contained contains=rpgleDsPath +syntax match rpgleDsReferenceSql ':\(\w\+\.\)\+\w\+' contained contains=rpgleDsPath +syntax match rpgleDsPath '\(\w\|\.\)\+\ze\.' contained nextgroup=rpgledsSeperator +syntax match rpgleDsSeperator '\.' contained nextgroup=rpgleDsItem +syntax match rpgleDsItem '\w\+' contained + +syntax match rpgleSqlReference ':\zs\w\+' contained + +syntax keyword db2SqlKeywords CLOSQLCSR DATFMT +syntax keyword db2SqlValues *ENDMOD *NONE *ISO + +" }}} +" Compiler directive {{{ + +syntax keyword rpglePreProc **FREE + +syntax keyword rpglePreProc /COPY /DEFINE /EJECT /ELSE /ELSEIF /END-FREE + \ /ENDIF /EOF /FREE /IF /INCLUDE /RESTORE /SET + \ /SPACE /TITLE /UNDEFINE /SET + \ nextgroup=rpglePreProcValue + +syntax match rpglePreProcValue /.*/ contained display + +" }}} +" Header Specs {{{ + +" CTL-OPT ... ; +syntax region rpgleCtlSpec matchgroup=rpgleKeywords + \ start=/\/ + \ end=/;/ + \ contains=@rpgleCtlProps +syntax cluster rpgleCtlProps contains=rpgleCtlKeywords,rpgleNumber, + \@rpgleString,rpgleConstant,rpgleError, + \rpgleCtlParanBalance + +syntax region rpgleCtlParanBalance matchgroup=xxx + \ start=/(/ + \ end=/)/ + \ contains=@rpgleCtlProps + +" Header Keywords +syntax keyword rpgleCtlKeywords contained + \ ALLOC ACTGRP ALTSEQ ALWNULL AUT BNDDIR CCSID + \ CCSIDCVT COPYNEST COPYRIGHT CURSYM CVTOPT + \ DATEDIT DATFMT DCLOPT DEBUG DECEDIT DECPREC + \ DFTACTGRP DFTNAME ENBPFRCOL EXPROPTS + \ EXTBININT FIXNBR FLYDIV FORMSALIGN FTRANS + \ GENLVL INDENT INTPREC LANGID MAIN NOMAIN + \ OPENOPT OPTIMIZE OPTION PGMINFO PRFDTA + \ SRTSEQ STGMDL TEXT THREAD TIMFMT TRUNCNBR + \ USERPRF VALIDATE REQPREXP + +" }}} +" Declaration Specs {{{ + +" Numbers and Strings + +syntax match rpgleNumber display + \ /\<-\=\%(\d\|\.\)\+\>/ + +syntax match rpgleError /\%(^\|\W\)\@1<='\_.\{-}'\W\@=/ +syntax match rpgleString /'\([+-]\n\|''\|[^']\)*'/ contains=rpgleStringProps +syntax cluster rpgleString contains=rpgleString + +if get(g:, 'rpgle_spellString', 1) + syntax cluster rpgleStringProps contains=@Spell +endif + +" Constants +syntax keyword rpgleConstant *ALL *BLANK *BLANKS *ENTRY *HIVAL *LOVAL *NULL + \ *OFF *ON *ZERO *ZEROS *LOCK *ISO0 *HMS0 *EUR *UTF8 + \ *SYS *OMIT *ALLOC *REQUIRE *WARN *PROC *DATA + +" *IN01 .. *IN99, *INH1 .. *INH9, *INL1 .. *INL9, *INLR, *INRT +syntax match rpgleSpecialKey display /\%(\*IN0[1-9]\|\*IN[1-9][0-9]\)/ +syntax match rpgleSpecialKey display /\*INH[1-9]/ +syntax match rpgleSpecialKey display /\*INL[1-9]/ +syntax match rpgleSpecialKey display /\*INU[1-8]/ +syntax keyword rpgleSpecialKey *INLR *INRT + +" Operators +syntax match rpgleOperator display /<>/ +syntax match rpgleOperator display />=/ +syntax match rpgleOperator display /<=/ +syntax match rpgleOperator display /\/ +syntax match rpgleOperator display /\/ +syntax match rpgleOperator display /\/ +syntax match rpgleOperator display /\/ +syntax match rpgleOperator display /\/ +syntax match rpgleOperator display /[*=><+]/ +syntax match rpgleOperator display /\<-\>/ + +" Standalone, Constant +syntax region rpgleDclSpec display matchgroup=rpgleDclKeywords + \ start=/\/ + \ end=/$/ + \ contains=rpgleDclProp + +" Procedure Interface +syntax keyword rpgleError END-PI +syntax region rpgleDclSpec matchgroup=rpgleDclKeywords + \ keepend + \ start=/\/ + \ end=/\/ + \ contains=rpgleDclProp,rpgleDclPiName + \ fold + +" Special PI Name +syntax keyword rpgleDclPiName *N + +" Prototype +syntax keyword rpgleError END-PR +syntax region rpgleDclSpec matchgroup=rpgleDclKeywords + \ keepend + \ start=/\/ + \ end=/\(\\|OVERLOAD\)/ + \ contains=rpgleDclProp + \ fold + +" Data Structure +syntax keyword rpgleError LIKEDS LIKEREC END-DS + +syntax keyword rpgleError ;; + +syntax region rpgleDclSpec matchgroup=rpgleDclKeywords + \ keepend + \ start=/\/ + \ end=/\/ + \ contains=rpgleDclProp + +syntax region rpgleDclSpec matchgroup=rpgleDclKeywords + \ keepend + \ start=/\/ + \ end=/\/ + \ contains=rpgleDclProp + +" These this syntax regions cannot be "display", even though it is on one line, +" as the rule above could be matched wrongly then. +syntax region rpgleDclSpec matchgroup=rpgleDclKeywords + \ start=/\\ze.*LIKEDS/ + \ start=/\\ze.*LIKEREC/ + \ end=/$/ + \ contains=rpgleDclProp + +" Declaration Types +syntax keyword rpgleDclTypes contained + \ BINDEC CHAR DATE DATE FLOAT GRAPH IND INT OBJECT + \ PACKED POINTER TIME TIMESTAMP UCS2 UCS2 UNS + \ VARCHAR VARGRAPH VARUCS2 ZONED + +" Declaration Keywords +syntax keyword rpgleDclKeywords contained + \ ALIAS ALIGN ALT ALTSEQ ASCEND BASED CCSID + \ CLASS CONST CTDATA DATFMT DESCEND DIM DTAARA + \ EXPORT EXT EXTFLD EXTFMT EXTNAME EXTPGM + \ EXTPROC FROMFILE IMPORT INZ LEN LIKE LIKEDS + \ LIKEFILE LIKEREC NOOPT NULLIND OCCURS OPDESC + \ OPTIONS OVERLAY PACKEVEN PERRCD POS PREFIX + \ PSDS QUALIFIED RTNPARM STATIC TEMPLATE TIMFMT + \ TOFILE VALUE PRINTER USROPN OFLIND INDDS WORKSTN + \ SFILE INFDS SQLTYPE OVERLOAD + + +" Declaration Constants +syntax keyword rpgleDclSpecialKeys contained + \ *NOPASS *OMIT *VARSIZE *STRING *RIGHTADJ *AUTO *VAR *DCLCASE *EXACT *NULLIND + \ *TRIM + +syntax keyword rpgleDclSqlTypes contained + \ CLOB CLOB_LOCATOR DBCLOB DBCLOB_LOCATOR + \ BLOB BLOB_LOCATOR + \ BINARY VARBINARY + \ XML_CLOB XML_DBCLOB XML_BLOB XML_LOCATOR + \ XML_BLOB_FILE XML_CLOB_FILE XML_DBCLOB_FILE + \ BLOB_FILE CLOB_FILE DBCLOB_FILE + \ ROW_ID RESULT_SET_LOCATOR + +syntax region rpgleDclParenBalance matchgroup=rpgleDclBrackets + \ start=/(/ + \ end=/)/ + \ contains=@rpgleComment,rpgleDclSpecialKeys,rpgleDclSqlTypes, + \rpgleNumber,@rpgleString, + \rpgleConstant,rpgleError, + \rpgleDclParenBalance,rpgleBIF + + +syntax match rpgleDclProp /\s*/ contained nextgroup=rpgleDclPropName +syntax match rpgleDclPropName /\k\+/ contained nextgroup=rpgleDclPropTail + \ contains=@rpgleComment +syntax match rpgleDclPropTail /.\+/ contained + \ contains=@rpgleComment,rpgleDclTypes, + \rpgleDclKeywords,rpgleError, + \rpgleDclParenBalance + +" }}} +" Calculation Specs {{{ + +" IF ... ENDIF +syntax keyword rpgleError ENDIF +syntax region rpgleIf matchgroup=rpgleConditional + \ start=/\/ + \ end=/\/ + \ contains=@rpgleNest,rpgleElse + \ fold + +" ELSE ELSEIF +syntax keyword rpgleError ELSE ELSEIF +syntax keyword rpgleElse contained ELSE ELSEIF + +" NOT, AND, OR +syntax keyword rpgleConditional NOT AND OR + +" DOW .. ENDDO, DOU .. ENDDO +syntax keyword rpgleError ENDDO +syntax region rpgleDo matchgroup=rpgleRepeat + \ start=/\/ + \ end=/\/ + \ contains=@rpgleNest + \ fold + +" FOR ... ENDFOR +syntax region rpgleFor matchgroup=rpgleRepeat + \ start=/\/ + \ end=/\/ + \ contains=@rpgleNest + \ fold +syntax keyword rpgleError ENDFOR + +syntax region rpgleForEach matchgroup=rpgleRepeat + \ start=/\/ + \ end=/\/ + \ contains=@rpgleNest + \ fold + +" ITER, LEAVE +syntax keyword rpgleRepeat contained ITER LEAVE + +" MONITOR ... ENDMON +syntax keyword rpgleError ENDMON +syntax region rpgleMonitor matchgroup=rpgleConditional + \ start=/\/ + \ end=/\/ + \ contains=@rpgleNest,rpgleOnError + \ fold + +" ON-ERROR +syntax keyword rpgleError ON-ERROR +syntax keyword rpgleOnError contained ON-ERROR + +" ON-EXIT +syntax keyword rpgleOnExit contained ON-EXIT + +" SELECT ... ENDSL +syntax keyword rpgleError ENDSL +syntax region rpgleSelect matchgroup=rpgleKeywords + \ start=/\/ + \ end=/\/ + \ contains=@rpgleNest,rpgleWhenOther + \ fold + +" WHEN, OTHER +syntax keyword rpgleError WHEN OTHER +syntax keyword rpgleWhenOther contained WHEN OTHER + +" Exec SQL +syntax region rpgleSql matchgroup=rpgleKeywords + \ start=/\/ + \ end=/;/ + \ contains=@esql,rpgleDsReferenceSql,rpgleSqlReference,db2SqlKeywords, + \ db2SqlValues + +" Build In Functions +syntax match rpgleError /%\w\+/ + +syntax keyword rpgleBIF %ABS + \ %ADDR + \ %ALLOC + \ %BITAND + \ %BITNOT + \ %BITOR + \ %BITXOR + \ %CHAR + \ %CHECK + \ %CHECKR + \ %DATA + \ %GEN + \ %OKEDOKE + \ %DATE + \ %DAYS + \ %DEC + \ %DECH + \ %DECPOS + \ %DIFF + \ %DIV + \ %EDITC + \ %EDITFLT + \ %EDITW + \ %ELEM + \ %EOF + \ %EQUAL + \ %ERROR + \ %FIELDS + \ %FLOAT + \ %FOUND + \ %GRAPH + \ %HANDLER + \ %HOURS + \ %INT + \ %INTH + \ %KDS + \ %LEN + \ %LOOKUP + \ %LOOKUPLT + \ %LOOKUPLE + \ %LOOKUPGT + \ %LOOKUPGE + \ %MAX + \ %MIN + \ %MINUTES + \ %MONTHS + \ %MSECONDS + \ %NULLIND + \ %OCCUR + \ %OPEN + \ %PADDR + \ %PARMS + \ %PARMNUM + \ %PARSER + \ %PROC + \ %REALLOC + \ %REM + \ %REPLACE + \ %SCAN + \ %SCANR + \ %SCANRPL + \ %SECONDS + \ %SHTDN + \ %SIZE + \ %SQRT + \ %STATUS + \ %STR + \ %SUBARR + \ %SUBDT + \ %SUBST + \ %THIS + \ %TIME + \ %TIMESTAMP + \ %TLOOKUPxx + \ %TRIM + \ %TRIML + \ %TRIMR + \ %UCS2 + \ %UNS + \ %UNSH + \ %XFOOT + \ %XLATE + \ %XML + \ %YEARS + \ %RANGE + \ %LIST + \ %UPPER + \ %LOWER + +" Procedures, the match group is to avoid infinite recursion as a +" ``rpgleProcCall'' can be within another ``rpgleProcCall'' +syntax match rpgleError /)/ +syntax region rpgleProcCall matchgroup=rpgleProcCallName + \ start=/%\@1/ + \ end=/\/ + \ contains=@rpgleNest + \ fold + +" EXSR +syntax keyword rpgleKeywords EXSR + +" }}} +" Procedure Specs {{{ + +syntax region rpgleDclProcBody matchgroup=rpgleDclProc + \ start=/\/ + \ end=/\/ + \ contains=@rpgleDclProcNest + \ fold +syntax cluster rpgleDclProcNest contains=@rpgleNest,rpgleSub,rpgleDclSpec, + \rpgleDclProcName,rpgleError,rpgleOnExit +syntax keyword rpgleError END-PROC + +" Procedure Name +syntax match rpgleDclProcName display contained skipwhite + \ /\%(DCL-PROC\s\+\)\@10<=\w\+/ + \ nextgroup=rpgleDclProcExport + +" Export +syntax keyword rpgleDclProcExport contained EXPORT + +" }}} + +syntax region rpgleParenBalance matchgroup=rpgleBIFBrackets + \ start=/(/ + \ end=/)/ + \ contains=@rpgleNest + +" All nestable groups, i.e. mostly Calculation Spec keywords: +syntax cluster rpgleNest contains=rpgleBIF,@rpgleComment,rpgleConditional, + \rpgleConstant,rpgleDo,rpgleFor,rpgleForEach,rpgleIf, + \rpgleKeywords,rpgleMonitor,rpgleNumber, + \rpgleOperator,rpglePreProc,rpgleProcCall, + \rpgleRepeat,rpgleSelect,rpgleSpecialKey, + \rpgleSql,@rpgleString,rpgleError, + \rpgleParenBalance,rpgleDsReference + +"syntax match rpgleDclProcName display skipwhite /\k*\ze\((.*)\)/ + +syntax sync fromstart + +highlight link rpgleProcCallName Function +highlight link rpgleError Error +highlight link rpglePreProc PreProc +highlight link rpgleProc Function +highlight link rpgleSpecialKey SpecialKey +highlight link rpgleNumber Number +highlight link rpgleString String +highlight link rpgleOperator Operator +highlight link rpgleComment Comment +highlight link rpgleSpecialComment SpecialComment +highlight link rpgleTodo Todo +highlight link rpgleConstant Constant +highlight link rpgleConditional Conditional +highlight link rpgleRepeat Repeat +highlight link rpgleKeywords Keyword +highlight link rpgleSpecial Special +highlight link rpgleTypes Type +highlight link rpgleDsReference Operator +highlight link rpgleDsPath PreProc +highlight link rpgleDsItem Identifier +highlight link rpgleSqlReference Identifier +highlight link db2SqlKeywords Conditional +highlight link db2SqlValues PreProc + +highlight link rpgleLineComment rpgleComment +highlight link rpgleBracketedComment rpgleComment + +highlight link rpgleCtlKeywords rpgleKeywords +highlight link rpgleDclTypes rpgleTypes +highlight link rpgleDclSqlTypes rpgleTypes +highlight link rpgleDclKeywords rpgleKeywords +highlight link rpgleDclProc rpgleKeywords +highlight link rpgleDclProcExport rpgleKeywords +highlight link rpgleDclProcName rpgleProc +highlight link rpgleDclPiName rpgleSpecial +highlight link rpgleDclSpecialKeys rpgleSpecialKey +highlight link rpgleElse rpgleConditional +highlight link rpgleOnError rpgleKeywords +highlight link rpgleOnExit rpgleKeywords +highlight link rpgleWhenOther rpgleKeywords +highlight link rpgleBIF rpgleSpecial +highlight link rpgleBIFBrackets rpgleSpecial +highlight link rpgleDclBrackets Comment + +highlight link rpgleDclPropName Constant + +" vim: foldmethod=marker