Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Pascal |
Bram Moolenaar | 009b259 | 2004-10-24 19:18:58 +0000 | [diff] [blame] | 3 | " Version: 2.8 |
| 4 | " Last Change: 2004/10/17 17:47:30 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5 | " Maintainer: Xavier Crégut <xavier.cregut@enseeiht.fr> |
| 6 | " Previous Maintainer: Mario Eusebio <bio@dq.fct.unl.pt> |
| 7 | |
Bram Moolenaar | 009b259 | 2004-10-24 19:18:58 +0000 | [diff] [blame] | 8 | " Contributors: Tim Chase <tchase@csc.com>, |
| 9 | " Stas Grabois <stsi@vtrails.com>, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 10 | " Mazen NEIFER <mazen.neifer.2001@supaero.fr>, |
Bram Moolenaar | 009b259 | 2004-10-24 19:18:58 +0000 | [diff] [blame] | 11 | " Klaus Hast <Klaus.Hast@arcor.net>, |
| 12 | " Austin Ziegler <austin@halostatue.ca>, |
| 13 | " Markus Koenig <markus@stber-koenig.de> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 14 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 15 | " quit when a syntax file was already loaded |
| 16 | if exists("b:current_syntax") |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 17 | finish |
| 18 | endif |
| 19 | |
| 20 | |
| 21 | syn case ignore |
| 22 | syn sync lines=250 |
| 23 | |
| 24 | syn keyword pascalBoolean true false |
| 25 | syn keyword pascalConditional if else then |
| 26 | syn keyword pascalConstant nil maxint |
| 27 | syn keyword pascalLabel case goto label |
| 28 | syn keyword pascalOperator and div downto in mod not of or packed with |
| 29 | syn keyword pascalRepeat do for do repeat while to until |
| 30 | syn keyword pascalStatement procedure function |
| 31 | syn keyword pascalStatement program begin end const var type |
| 32 | syn keyword pascalStruct record |
| 33 | syn keyword pascalType array boolean char integer file pointer real set |
| 34 | syn keyword pascalType string text variant |
| 35 | |
| 36 | |
Bram Moolenaar | 009b259 | 2004-10-24 19:18:58 +0000 | [diff] [blame] | 37 | " 20011222az: Added new items. |
| 38 | syn keyword pascalTodo contained TODO FIXME XXX DEBUG NOTE |
| 39 | |
| 40 | " 20010723az: When wanted, highlight the trailing whitespace -- this is |
| 41 | " based on c_space_errors; to enable, use "pascal_space_errors". |
| 42 | if exists("pascal_space_errors") |
| 43 | if !exists("pascal_no_trail_space_error") |
| 44 | syn match pascalSpaceError "\s\+$" |
| 45 | endif |
| 46 | if !exists("pascal_no_tab_space_error") |
| 47 | syn match pascalSpaceError " \+\t"me=e-1 |
| 48 | endif |
| 49 | endif |
| 50 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 51 | |
| 52 | |
| 53 | " String |
| 54 | if !exists("pascal_one_line_string") |
| 55 | syn region pascalString matchgroup=pascalString start=+'+ end=+'+ contains=pascalStringEscape |
| 56 | if exists("pascal_gpc") |
| 57 | syn region pascalString matchgroup=pascalString start=+"+ end=+"+ contains=pascalStringEscapeGPC |
| 58 | else |
| 59 | syn region pascalStringError matchgroup=pascalStringError start=+"+ end=+"+ contains=pascalStringEscape |
| 60 | endif |
| 61 | else |
| 62 | "wrong strings |
| 63 | syn region pascalStringError matchgroup=pascalStringError start=+'+ end=+'+ end=+$+ contains=pascalStringEscape |
| 64 | if exists("pascal_gpc") |
| 65 | syn region pascalStringError matchgroup=pascalStringError start=+"+ end=+"+ end=+$+ contains=pascalStringEscapeGPC |
| 66 | else |
| 67 | syn region pascalStringError matchgroup=pascalStringError start=+"+ end=+"+ end=+$+ contains=pascalStringEscape |
| 68 | endif |
| 69 | |
| 70 | "right strings |
| 71 | syn region pascalString matchgroup=pascalString start=+'+ end=+'+ oneline contains=pascalStringEscape |
| 72 | " To see the start and end of strings: |
| 73 | " syn region pascalString matchgroup=pascalStringError start=+'+ end=+'+ oneline contains=pascalStringEscape |
| 74 | if exists("pascal_gpc") |
| 75 | syn region pascalString matchgroup=pascalString start=+"+ end=+"+ oneline contains=pascalStringEscapeGPC |
| 76 | else |
| 77 | syn region pascalStringError matchgroup=pascalStringError start=+"+ end=+"+ oneline contains=pascalStringEscape |
| 78 | endif |
| 79 | end |
| 80 | syn match pascalStringEscape contained "''" |
| 81 | syn match pascalStringEscapeGPC contained '""' |
| 82 | |
| 83 | |
| 84 | " syn match pascalIdentifier "\<[a-zA-Z_][a-zA-Z0-9_]*\>" |
| 85 | |
| 86 | |
| 87 | if exists("pascal_symbol_operator") |
| 88 | syn match pascalSymbolOperator "[+\-/*=]" |
| 89 | syn match pascalSymbolOperator "[<>]=\=" |
| 90 | syn match pascalSymbolOperator "<>" |
| 91 | syn match pascalSymbolOperator ":=" |
| 92 | syn match pascalSymbolOperator "[()]" |
| 93 | syn match pascalSymbolOperator "\.\." |
| 94 | syn match pascalSymbolOperator "[\^.]" |
| 95 | syn match pascalMatrixDelimiter "[][]" |
| 96 | "if you prefer you can highlight the range |
| 97 | "syn match pascalMatrixDelimiter "[\d\+\.\.\d\+]" |
| 98 | endif |
| 99 | |
| 100 | syn match pascalNumber "-\=\<\d\+\>" |
| 101 | syn match pascalFloat "-\=\<\d\+\.\d\+\>" |
| 102 | syn match pascalFloat "-\=\<\d\+\.\d\+[eE]-\=\d\+\>" |
| 103 | syn match pascalHexNumber "\$[0-9a-fA-F]\+\>" |
| 104 | |
| 105 | if exists("pascal_no_tabs") |
| 106 | syn match pascalShowTab "\t" |
| 107 | endif |
| 108 | |
Bram Moolenaar | 009b259 | 2004-10-24 19:18:58 +0000 | [diff] [blame] | 109 | syn region pascalComment start="(\*\|{" end="\*)\|}" contains=pascalTodo,pascalSpaceError |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 110 | |
| 111 | |
| 112 | if !exists("pascal_no_functions") |
| 113 | " array functions |
| 114 | syn keyword pascalFunction pack unpack |
| 115 | |
| 116 | " memory function |
| 117 | syn keyword pascalFunction Dispose New |
| 118 | |
| 119 | " math functions |
| 120 | syn keyword pascalFunction Abs Arctan Cos Exp Ln Sin Sqr Sqrt |
| 121 | |
| 122 | " file functions |
| 123 | syn keyword pascalFunction Eof Eoln Write Writeln |
| 124 | syn keyword pascalPredefined Input Output |
| 125 | |
| 126 | if exists("pascal_traditional") |
| 127 | " These functions do not seem to be defined in Turbo Pascal |
Bram Moolenaar | 009b259 | 2004-10-24 19:18:58 +0000 | [diff] [blame] | 128 | syn keyword pascalFunction Get Page Put |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 129 | endif |
| 130 | |
| 131 | " ordinal functions |
| 132 | syn keyword pascalFunction Odd Pred Succ |
| 133 | |
| 134 | " transfert functions |
| 135 | syn keyword pascalFunction Chr Ord Round Trunc |
| 136 | endif |
| 137 | |
| 138 | |
| 139 | if !exists("pascal_traditional") |
| 140 | |
| 141 | syn keyword pascalStatement constructor destructor implementation inherited |
| 142 | syn keyword pascalStatement interface unit uses |
| 143 | syn keyword pascalModifier absolute assembler external far forward inline |
Bram Moolenaar | 009b259 | 2004-10-24 19:18:58 +0000 | [diff] [blame] | 144 | syn keyword pascalModifier interrupt near virtual |
| 145 | syn keyword pascalAcces private public |
| 146 | syn keyword pascalStruct object |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 147 | syn keyword pascalOperator shl shr xor |
| 148 | |
| 149 | syn region pascalPreProc start="(\*\$" end="\*)" contains=pascalTodo |
| 150 | syn region pascalPreProc start="{\$" end="}" |
| 151 | |
| 152 | syn region pascalAsm matchgroup=pascalAsmKey start="\<asm\>" end="\<end\>" contains=pascalComment,pascalPreProc |
| 153 | |
| 154 | syn keyword pascalType ShortInt LongInt Byte Word |
| 155 | syn keyword pascalType ByteBool WordBool LongBool |
| 156 | syn keyword pascalType Cardinal LongWord |
| 157 | syn keyword pascalType Single Double Extended Comp |
| 158 | syn keyword pascalType PChar |
| 159 | |
| 160 | |
| 161 | if !exists ("pascal_fpc") |
| 162 | syn keyword pascalPredefined Result |
| 163 | endif |
| 164 | |
| 165 | if exists("pascal_fpc") |
Bram Moolenaar | 009b259 | 2004-10-24 19:18:58 +0000 | [diff] [blame] | 166 | syn region pascalComment start="//" end="$" contains=pascalTodo,pascalSpaceError |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 167 | syn keyword pascalStatement fail otherwise operator |
| 168 | syn keyword pascalDirective popstack |
| 169 | syn keyword pascalPredefined self |
| 170 | syn keyword pascalType ShortString AnsiString WideString |
| 171 | endif |
| 172 | |
| 173 | if exists("pascal_gpc") |
| 174 | syn keyword pascalType SmallInt |
| 175 | syn keyword pascalType AnsiChar |
| 176 | syn keyword pascalType PAnsiChar |
| 177 | endif |
| 178 | |
| 179 | if exists("pascal_delphi") |
Bram Moolenaar | 009b259 | 2004-10-24 19:18:58 +0000 | [diff] [blame] | 180 | syn region pascalComment start="//" end="$" contains=pascalTodo,pascalSpaceError |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 181 | syn keyword pascalType SmallInt Int64 |
| 182 | syn keyword pascalType Real48 Currency |
| 183 | syn keyword pascalType AnsiChar WideChar |
| 184 | syn keyword pascalType ShortString AnsiString WideString |
| 185 | syn keyword pascalType PAnsiChar PWideChar |
| 186 | syn match pascalFloat "-\=\<\d\+\.\d\+[dD]-\=\d\+\>" |
| 187 | syn match pascalStringEscape contained "#[12][0-9]\=[0-9]\=" |
| 188 | syn keyword pascalStruct class dispinterface |
| 189 | syn keyword pascalException try except raise at on finally |
| 190 | syn keyword pascalStatement out |
Bram Moolenaar | 009b259 | 2004-10-24 19:18:58 +0000 | [diff] [blame] | 191 | syn keyword pascalStatement library package |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 192 | syn keyword pascalStatement initialization finalization uses exports |
| 193 | syn keyword pascalStatement property out resourcestring threadvar |
| 194 | syn keyword pascalModifier contains |
| 195 | syn keyword pascalModifier overridden reintroduce abstract |
| 196 | syn keyword pascalModifier override export dynamic name message |
| 197 | syn keyword pascalModifier dispid index stored default nodefault readonly |
| 198 | syn keyword pascalModifier writeonly implements overload requires resident |
| 199 | syn keyword pascalAcces protected published automated |
| 200 | syn keyword pascalDirective register pascal cvar cdecl stdcall safecall |
| 201 | syn keyword pascalOperator as is |
| 202 | endif |
| 203 | |
| 204 | if exists("pascal_no_functions") |
| 205 | "syn keyword pascalModifier read write |
| 206 | "may confuse with Read and Write functions. Not easy to handle. |
| 207 | else |
| 208 | " control flow functions |
| 209 | syn keyword pascalFunction Break Continue Exit Halt RunError |
| 210 | |
| 211 | " ordinal functions |
| 212 | syn keyword pascalFunction Dec Inc High Low |
| 213 | |
| 214 | " math functions |
| 215 | syn keyword pascalFunction Frac Int Pi |
| 216 | |
| 217 | " string functions |
| 218 | syn keyword pascalFunction Concat Copy Delete Insert Length Pos Str Val |
| 219 | |
| 220 | " memory function |
| 221 | syn keyword pascalFunction FreeMem GetMem MaxAvail MemAvail |
| 222 | |
| 223 | " pointer and address functions |
| 224 | syn keyword pascalFunction Addr Assigned CSeg DSeg Ofs Ptr Seg SPtr SSeg |
| 225 | |
| 226 | " misc functions |
| 227 | syn keyword pascalFunction Exclude FillChar Hi Include Lo Move ParamCount |
| 228 | syn keyword pascalFunction ParamStr Random Randomize SizeOf Swap TypeOf |
| 229 | syn keyword pascalFunction UpCase |
| 230 | |
| 231 | " predefined variables |
| 232 | syn keyword pascalPredefined ErrorAddr ExitCode ExitProc FileMode FreeList |
| 233 | syn keyword pascalPredefined FreeZero HeapEnd HeapError HeapOrg HeapPtr |
| 234 | syn keyword pascalPredefined InOutRes OvrCodeList OvrDebugPtr OvrDosHandle |
| 235 | syn keyword pascalPredefined OvrEmsHandle OvrHeapEnd OvrHeapOrg OvrHeapPtr |
| 236 | syn keyword pascalPredefined OvrHeapSize OvrLoadList PrefixSeg RandSeed |
| 237 | syn keyword pascalPredefined SaveInt00 SaveInt02 SaveInt1B SaveInt21 |
| 238 | syn keyword pascalPredefined SaveInt23 SaveInt24 SaveInt34 SaveInt35 |
| 239 | syn keyword pascalPredefined SaveInt36 SaveInt37 SaveInt38 SaveInt39 |
| 240 | syn keyword pascalPredefined SaveInt3A SaveInt3B SaveInt3C SaveInt3D |
| 241 | syn keyword pascalPredefined SaveInt3E SaveInt3F SaveInt75 SegA000 SegB000 |
| 242 | syn keyword pascalPredefined SegB800 SelectorInc StackLimit Test8087 |
| 243 | |
| 244 | " file functions |
| 245 | syn keyword pascalFunction Append Assign BlockRead BlockWrite ChDir Close |
| 246 | syn keyword pascalFunction Erase FilePos FileSize Flush GetDir IOResult |
| 247 | syn keyword pascalFunction MkDir Read Readln Rename Reset Rewrite RmDir |
| 248 | syn keyword pascalFunction Seek SeekEof SeekEoln SetTextBuf Truncate |
| 249 | |
| 250 | " crt unit |
| 251 | syn keyword pascalFunction AssignCrt ClrEol ClrScr Delay DelLine GotoXY |
| 252 | syn keyword pascalFunction HighVideo InsLine KeyPressed LowVideo NormVideo |
| 253 | syn keyword pascalFunction NoSound ReadKey Sound TextBackground TextColor |
| 254 | syn keyword pascalFunction TextMode WhereX WhereY Window |
| 255 | syn keyword pascalPredefined CheckBreak CheckEOF CheckSnow DirectVideo |
| 256 | syn keyword pascalPredefined LastMode TextAttr WindMin WindMax |
| 257 | syn keyword pascalFunction BigCursor CursorOff CursorOn |
| 258 | syn keyword pascalConstant Black Blue Green Cyan Red Magenta Brown |
| 259 | syn keyword pascalConstant LightGray DarkGray LightBlue LightGreen |
| 260 | syn keyword pascalConstant LightCyan LightRed LightMagenta Yellow White |
| 261 | syn keyword pascalConstant Blink ScreenWidth ScreenHeight bw40 |
| 262 | syn keyword pascalConstant co40 bw80 co80 mono |
Bram Moolenaar | 009b259 | 2004-10-24 19:18:58 +0000 | [diff] [blame] | 263 | syn keyword pascalPredefined TextChar |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 264 | |
| 265 | " DOS unit |
| 266 | syn keyword pascalFunction AddDisk DiskFree DiskSize DosExitCode DosVersion |
| 267 | syn keyword pascalFunction EnvCount EnvStr Exec Expand FindClose FindFirst |
| 268 | syn keyword pascalFunction FindNext FSearch FSplit GetCBreak GetDate |
| 269 | syn keyword pascalFunction GetEnv GetFAttr GetFTime GetIntVec GetTime |
| 270 | syn keyword pascalFunction GetVerify Intr Keep MSDos PackTime SetCBreak |
| 271 | syn keyword pascalFunction SetDate SetFAttr SetFTime SetIntVec SetTime |
| 272 | syn keyword pascalFunction SetVerify SwapVectors UnPackTime |
| 273 | syn keyword pascalConstant FCarry FParity FAuxiliary FZero FSign FOverflow |
| 274 | syn keyword pascalConstant Hidden Sysfile VolumeId Directory Archive |
| 275 | syn keyword pascalConstant AnyFile fmClosed fmInput fmOutput fmInout |
| 276 | syn keyword pascalConstant TextRecNameLength TextRecBufSize |
| 277 | syn keyword pascalType ComStr PathStr DirStr NameStr ExtStr SearchRec |
| 278 | syn keyword pascalType FileRec TextBuf TextRec Registers DateTime |
| 279 | syn keyword pascalPredefined DosError |
| 280 | |
| 281 | "Graph Unit |
| 282 | syn keyword pascalFunction Arc Bar Bar3D Circle ClearDevice ClearViewPort |
| 283 | syn keyword pascalFunction CloseGraph DetectGraph DrawPoly Ellipse |
| 284 | syn keyword pascalFunction FillEllipse FillPoly FloodFill GetArcCoords |
| 285 | syn keyword pascalFunction GetAspectRatio GetBkColor GetColor |
| 286 | syn keyword pascalFunction GetDefaultPalette GetDriverName GetFillPattern |
| 287 | syn keyword pascalFunction GetFillSettings GetGraphMode GetImage |
| 288 | syn keyword pascalFunction GetLineSettings GetMaxColor GetMaxMode GetMaxX |
| 289 | syn keyword pascalFunction GetMaxY GetModeName GetModeRange GetPalette |
| 290 | syn keyword pascalFunction GetPaletteSize GetPixel GetTextSettings |
| 291 | syn keyword pascalFunction GetViewSettings GetX GetY GraphDefaults |
| 292 | syn keyword pascalFunction GraphErrorMsg GraphResult ImageSize InitGraph |
| 293 | syn keyword pascalFunction InstallUserDriver InstallUserFont Line LineRel |
| 294 | syn keyword pascalFunction LineTo MoveRel MoveTo OutText OutTextXY |
| 295 | syn keyword pascalFunction PieSlice PutImage PutPixel Rectangle |
| 296 | syn keyword pascalFunction RegisterBGIDriver RegisterBGIFont |
| 297 | syn keyword pascalFunction RestoreCRTMode Sector SetActivePage |
| 298 | syn keyword pascalFunction SetAllPallette SetAspectRatio SetBkColor |
| 299 | syn keyword pascalFunction SetColor SetFillPattern SetFillStyle |
| 300 | syn keyword pascalFunction SetGraphBufSize SetGraphMode SetLineStyle |
| 301 | syn keyword pascalFunction SetPalette SetRGBPalette SetTextJustify |
| 302 | syn keyword pascalFunction SetTextStyle SetUserCharSize SetViewPort |
| 303 | syn keyword pascalFunction SetVisualPage SetWriteMode TextHeight TextWidth |
| 304 | syn keyword pascalType ArcCoordsType FillPatternType FillSettingsType |
| 305 | syn keyword pascalType LineSettingsType PaletteType PointType |
| 306 | syn keyword pascalType TextSettingsType ViewPortType |
| 307 | |
| 308 | " string functions |
| 309 | syn keyword pascalFunction StrAlloc StrBufSize StrCat StrComp StrCopy |
| 310 | syn keyword pascalFunction StrDispose StrECopy StrEnd StrFmt StrIComp |
| 311 | syn keyword pascalFunction StrLCat StrLComp StrLCopy StrLen StrLFmt |
| 312 | syn keyword pascalFunction StrLIComp StrLower StrMove StrNew StrPas |
| 313 | syn keyword pascalFunction StrPCopy StrPLCopy StrPos StrRScan StrScan |
| 314 | syn keyword pascalFunction StrUpper |
| 315 | endif |
| 316 | |
| 317 | endif |
| 318 | |
| 319 | " Define the default highlighting. |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 320 | " Only when an item doesn't have highlighting yet |
| 321 | command -nargs=+ HiLink hi def link <args> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 322 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 323 | HiLink pascalAcces pascalStatement |
| 324 | HiLink pascalBoolean Boolean |
| 325 | HiLink pascalComment Comment |
| 326 | HiLink pascalConditional Conditional |
| 327 | HiLink pascalConstant Constant |
| 328 | HiLink pascalDelimiter Identifier |
| 329 | HiLink pascalDirective pascalStatement |
| 330 | HiLink pascalException Exception |
| 331 | HiLink pascalFloat Float |
| 332 | HiLink pascalFunction Function |
| 333 | HiLink pascalLabel Label |
| 334 | HiLink pascalMatrixDelimiter Identifier |
| 335 | HiLink pascalModifier Type |
| 336 | HiLink pascalNumber Number |
| 337 | HiLink pascalOperator Operator |
| 338 | HiLink pascalPredefined pascalStatement |
| 339 | HiLink pascalPreProc PreProc |
| 340 | HiLink pascalRepeat Repeat |
| 341 | HiLink pascalSpaceError Error |
| 342 | HiLink pascalStatement Statement |
| 343 | HiLink pascalString String |
| 344 | HiLink pascalStringEscape Special |
| 345 | HiLink pascalStringEscapeGPC Special |
| 346 | HiLink pascalStringError Error |
| 347 | HiLink pascalStruct pascalStatement |
| 348 | HiLink pascalSymbolOperator pascalOperator |
| 349 | HiLink pascalTodo Todo |
| 350 | HiLink pascalType Type |
| 351 | HiLink pascalUnclassified pascalStatement |
| 352 | " HiLink pascalAsm Assembler |
| 353 | HiLink pascalError Error |
| 354 | HiLink pascalAsmKey pascalStatement |
| 355 | HiLink pascalShowTab Error |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 356 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 357 | delcommand HiLink |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 358 | |
| 359 | |
| 360 | let b:current_syntax = "pascal" |
| 361 | |
| 362 | " vim: ts=8 sw=2 |