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