summaryrefslogtreecommitdiffstats
path: root/runtime/syntax/postscr.vim
blob: fddfe4c947598876c551b5e3a5f01472f654d39e (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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
" Vim syntax file
" Language:     PostScript - all Levels, selectable
" Maintainer:   Mike Williams <mrw@eandem.co.uk>
" Filenames:    *.ps,*.eps
" Last Change:  31st October 2007
" URL:          http://www.eandem.co.uk/mrw/vim
"
" Options Flags:
" postscr_level                 - language level to use for highligting (1, 2, or 3)
" postscr_display               - include display PS operators
" postscr_ghostscript           - include GS extensions
" postscr_fonts                 - highlight standard font names (a lot for PS 3)
" postscr_encodings             - highlight encoding names (there are a lot)
" postscr_andornot_binary       - highlight and, or, and not as binary operators (not logical)
"
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

" PostScript is case sensitive
syn case match

" Keyword characters - all 7-bit ASCII bar PS delimiters and ws
if version >= 600
  setlocal iskeyword=33-127,^(,^),^<,^>,^[,^],^{,^},^/,^%
else
  set iskeyword=33-127,^(,^),^<,^>,^[,^],^{,^},^/,^%
endif

" Yer trusty old TODO highlghter!
syn keyword postscrTodo contained  TODO

" Comment
syn match postscrComment        "%.*$" contains=postscrTodo,@Spell
" DSC comment start line (NB: defines DSC level, not PS level!)
syn match postscrDSCComment    	"^%!PS-Adobe-\d\+\.\d\+\s*.*$"
" DSC comment line (no check on possible comments - another language!)
syn match postscrDSCComment    	"^%%\u\+.*$" contains=@postscrString,@postscrNumber,@Spell
" DSC continuation line (no check that previous line is DSC comment)
syn match  postscrDSCComment    "^%%+ *.*$" contains=@postscrString,@postscrNumber,@Spell

" Names
syn match postscrName           "\k\+"

" Identifiers
syn match postscrIdentifierError "/\{1,2}[[:space:]\[\]{}]"me=e-1
syn match postscrIdentifier     "/\{1,2}\k\+" contains=postscrConstant,postscrBoolean,postscrCustConstant

" Numbers
syn case ignore
" In file hex data - usually complete lines
syn match postscrHex            "^[[:xdigit:]][[:xdigit:][:space:]]*$"
"syn match postscrHex            "\<\x\{2,}\>"
" Integers
syn match postscrInteger        "\<[+-]\=\d\+\>"
" Radix
syn match postscrRadix          "\d\+#\x\+\>"
" Reals - upper and lower case e is allowed
syn match postscrFloat          "[+-]\=\d\+\.\>"
syn match postscrFloat          "[+-]\=\d\+\.\d*\(e[+-]\=\d\+\)\=\>"
syn match postscrFloat          "[+-]\=\.\d\+\(e[+-]\=\d\+\)\=\>"
syn match postscrFloat          "[+-]\=\d\+e[+-]\=\d\+\>"
syn cluster postscrNumber       contains=postscrInteger,postscrRadix,postscrFloat
syn case match

" Escaped characters
syn match postscrSpecialChar    contained "\\[nrtbf\\()]"
syn match postscrSpecialCharError contained "\\[^nrtbf\\()]"he=e-1
" Escaped octal characters
syn match postscrSpecialChar    contained "\\\o\{1,3}"

" Strings
" ASCII strings
syn region postscrASCIIString   start=+(+ end=+)+ skip=+([^)]*)+ contains=postscrSpecialChar,postscrSpecialCharError,@Spell
syn match postscrASCIIStringError ")"
" Hex strings
syn match postscrHexCharError   contained "[^<>[:xdigit:][:space:]]"
syn region postscrHexString     start=+<\($\|[^<]\)+ end=+>+ contains=postscrHexCharError
syn match postscrHexString      "<>"
" ASCII85 strings
syn match postscrASCII85CharError contained "[^<>\~!-uz[:space:]]"
syn region postscrASCII85String start=+<\~+ end=+\~>+ contains=postscrASCII85CharError
syn cluster postscrString       contains=postscrASCIIString,postscrHexString,postscrASCII85String


" Set default highlighting to level 2 - most common at the moment
if !exists("postscr_level")
  let postscr_level = 2
endif


" PS level 1 operators - common to all levels (well ...)

" Stack operators
syn keyword postscrOperator     pop exch dup copy index roll clear count mark cleartomark counttomark

" Math operators
syn keyword postscrMathOperator add div idiv mod mul sub abs neg ceiling floor round truncate sqrt atan cos
syn keyword postscrMathOperator sin exp ln log rand srand rrand

" Array operators
syn match postscrOperator       "[\[\]{}]"
syn keyword postscrOperator     array length get put getinterval putinterval astore aload copy
syn keyword postscrRepeat       forall

" Dictionary operators
syn keyword postscrOperator     dict maxlength begin end def load store known where currentdict
syn keyword postscrOperator     countdictstack dictstack cleardictstack internaldict
syn keyword postscrConstant     $error systemdict userdict statusdict errordict

" String operators
syn keyword postscrOperator     string anchorsearch search token

" Logic operators
syn keyword postscrLogicalOperator eq ne ge gt le lt and not or
if exists("postscr_andornot_binaryop")
  syn keyword postscrBinaryOperator and or not
else
  syn keyword postscrLogicalOperator and not or
endif
syn keyword postscrBinaryOperator xor bitshift
syn keyword postscrBoolean      true false

" PS Type names
syn keyword postscrConstant     arraytype booleantype conditiontype dicttype filetype fonttype gstatetype
syn keyword postscrConstant     integertype locktype marktype nametype nulltype operatortype
syn keyword postscrConstant     packedarraytype realtype savetype stringtype

" Control operators
syn keyword postscrConditional  if ifelse
syn keyword postscrRepeat       for repeat loop
syn keyword postscrOperator     exec exit stop stopped countexecstack execstack quit
syn keyword postscrProcedure    start

" Object operators
syn keyword postscrOperator     type cvlit cvx xcheck executeonly noaccess readonly rcheck wcheck cvi cvn cvr
syn keyword postscrOperator     cvrs cvs

" File operators
syn keyword postscrOperator     file closefile read write readhexstring writehexstring readstring writestring
syn keyword postscrOperator     bytesavailable flush flushfile resetfile status run currentfile print
syn keyword postscrOperator     stack pstack readline deletefile setfileposition fileposition renamefile
syn keyword postscrRepeat       filenameforall
syn keyword postscrProcedure    = ==

" VM operators
syn keyword postscrOperator     save restore

" Misc operators
syn keyword postscrOperator     bind null usertime executive echo realtime
syn keyword postscrConstant     product revision serialnumber version
syn keyword postscrProcedure    prompt

" GState operators
syn keyword postscrOperator     gsave grestore grestoreall initgraphics setlinewidth setlinecap currentgray
syn keyword postscrOperator     currentlinejoin setmiterlimit currentmiterlimit setdash currentdash setgray
syn keyword postscrOperator     sethsbcolor currenthsbcolor setrgbcolor currentrgbcolor currentlinewidth
syn keyword postscrOperator     currentlinecap setlinejoin setcmykcolor currentcmykcolor

" Device gstate operators
syn keyword postscrOperator     setscreen currentscreen settransfer currenttransfer setflat currentflat
syn keyword postscrOperator     currentblackgeneration setblackgeneration setundercolorremoval
syn keyword postscrOperator     setcolorscreen currentcolorscreen setcolortransfer currentcolortransfer
syn keyword postscrOperator     currentundercolorremoval

" Matrix operators
syn keyword postscrOperator     matrix initmatrix identmatrix defaultmatrix currentmatrix setmatrix translate
syn keyword postscrOperator     concat concatmatrix transform dtransform itransform idtransform invertmatrix
syn keyword postscrOperator     scale rotate

" Path operators
syn keyword postscrOperator     newpath currentpoint moveto rmoveto lineto rlineto arc arcn arcto curveto
syn keyword postscrOperator     closepath flattenpath reversepath strokepath charpath clippath pathbbox
syn keyword postscrOperator     initclip clip eoclip rcurveto
syn keyword postscrRepeat       pathforall

" Painting operators
syn keyword postscrOperator     erasepage fill eofill stroke image imagemask colorimage

" Device operators
syn keyword postscrOperator     showpage copypage nulldevice

" Character operators
syn keyword postscrProcedure    findfont
syn keyword postscrConstant     FontDirectory ISOLatin1Encoding StandardEncoding
syn keyword postscrOperator     definefont scalefont makefont setfont currentfont show ashow
syn keyword postscrOperator     stringwidth kshow setcachedevice
syn keyword postscrOperator     setcharwidth widthshow awidthshow findencoding cshow rootfont setcachedevice2

" Interpreter operators
syn keyword postscrOperator     vmstatus cachestatus setcachelimit

" PS constants
syn keyword postscrConstant     contained Gray Red Green Blue All None DeviceGray DeviceRGB

" PS Filters
syn keyword postscrConstant     contained ASCIIHexDecode ASCIIHexEncode ASCII85Decode ASCII85Encode LZWDecode
syn keyword postscrConstant     contained RunLengthDecode RunLengthEncode SubFileDecode NullEncode
syn keyword postscrConstant     contained GIFDecode PNGDecode LZWEncode

" PS JPEG filter dictionary entries
syn keyword postscrConstant     contained DCTEncode DCTDecode Colors HSamples VSamples QuantTables QFactor
syn keyword postscrConstant     contained HuffTables ColorTransform

" PS CCITT filter dictionary entries
syn keyword postscrConstant     contained CCITTFaxEncode CCITTFaxDecode Uncompressed K EndOfLine
syn keyword postscrConstant     contained Columns Rows EndOfBlock Blacks1 DamagedRowsBeforeError
syn keyword postscrConstant     contained EncodedByteAlign

" PS Form dictionary entries
syn keyword postscrConstant     contained FormType XUID BBox Matrix PaintProc Implementation

" PS Errors
syn keyword postscrProcedure    handleerror
syn keyword postscrConstant     contained  configurationerror dictfull dictstackunderflow dictstackoverflow
syn keyword postscrConstant     contained  execstackoverflow interrupt invalidaccess
syn keyword postscrConstant     contained  invalidcontext invalidexit invalidfileaccess invalidfont
syn keyword postscrConstant     contained  invalidid invalidrestore ioerror limitcheck nocurrentpoint
syn keyword postscrConstant     contained  rangecheck stackoverflow stackunderflow syntaxerror timeout
syn keyword postscrConstant     contained  typecheck undefined undefinedfilename undefinedresource
syn keyword postscrConstant     contained  undefinedresult unmatchedmark unregistered VMerror

if exists("postscr_fonts")
" Font names
  syn keyword postscrConstant   contained Symbol Times-Roman Times-Italic Times-Bold Times-BoldItalic
  syn keyword postscrConstant   contained Helvetica Helvetica-Oblique Helvetica-Bold Helvetica-BoldOblique
  syn keyword postscrConstant   contained Courier Courier-Oblique Courier-Bold Courier-BoldOblique
endif


if exists("postscr_display")
" Display PS only operators
  syn keyword postscrOperator   currentcontext fork join detach lock monitor condition wait notify yield
  syn keyword postscrOperator   viewclip eoviewclip rectviewclip initviewclip viewclippath deviceinfo
  syn keyword postscrOperator   sethalftonephase currenthalftonephase wtranslation defineusername
endif

" PS Character encoding names
if exists("postscr_encodings")
" Common encoding names
  syn keyword postscrConstant   contained .notdef

" Standard and ISO encoding names
  syn keyword postscrConstant   contained space exclam quotedbl numbersign dollar percent ampersand quoteright
  syn keyword postscrConstant   contained parenleft parenright asterisk plus comma hyphen period slash zero
  syn keyword postscrConstant   contained one two three four five six seven eight nine colon semicolon less
  syn keyword postscrConstant   contained equal greater question at
  syn keyword postscrConstant   contained bracketleft backslash bracketright asciicircum underscore quoteleft
  syn keyword postscrConstant   contained braceleft bar braceright asciitilde
  syn keyword postscrConstant   contained exclamdown cent sterling fraction yen florin section currency
  syn keyword postscrConstant   contained quotesingle quotedblleft guillemotleft guilsinglleft guilsinglright
  syn keyword postscrConstant   contained fi fl endash dagger daggerdbl periodcentered paragraph bullet
  syn keyword postscrConstant   contained quotesinglbase quotedblbase quotedblright guillemotright ellipsis
  syn keyword postscrConstant   contained perthousand questiondown grave acute circumflex tilde macron breve
  syn keyword postscrConstant   contained dotaccent dieresis ring cedilla hungarumlaut ogonek caron emdash
  syn keyword postscrConstant   contained AE ordfeminine Lslash Oslash OE ordmasculine ae dotlessi lslash
  syn keyword postscrConstant   contained oslash oe germandbls
" The following are valid names, but are used as short procedure names in generated PS!
" a b c d e f g h i j k l m n o p q r s t u v w x y z
" A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

" Symbol encoding names
  syn keyword postscrConstant   contained universal existential suchthat asteriskmath minus
  syn keyword postscrConstant   contained congruent Alpha Beta Chi Delta Epsilon Phi Gamma Eta Iota theta1
  syn keyword postscrConstant   contained Kappa Lambda Mu Nu Omicron Pi Theta Rho Sigma Tau Upsilon sigma1
  syn keyword postscrConstant   contained Omega Xi Psi Zeta therefore perpendicular
  syn keyword postscrConstant   contained radicalex alpha beta chi delta epsilon phi gamma eta iota phi1
  syn keyword postscrConstant   contained kappa lambda mu nu omicron pi theta rho sigma tau upsilon omega1
  syn keyword postscrConstant   contained Upsilon1 minute lessequal infinity club diamond heart spade
  syn keyword postscrConstant   contained arrowboth arrowleft arrowup arrowright arrowdown degree plusminus
  syn keyword postscrConstant   contained second greaterequal multiply proportional partialdiff divide
  syn keyword postscrConstant   contained notequal equivalence approxequal arrowvertex arrowhorizex
  syn keyword postscrConstant   contained aleph Ifraktur Rfraktur weierstrass circlemultiply circleplus
  syn keyword postscrConstant   contained emptyset intersection union propersuperset reflexsuperset notsubset
  syn keyword postscrConstant   contained propersubset reflexsubset element notelement angle gradient
  syn keyword postscrConstant   contained registerserif copyrightserif trademarkserif radical dotmath
  syn keyword postscrConstant   contained logicalnot logicaland logicalor arrowdblboth arrowdblleft arrowdblup
  syn keyword postscrConstant   contained arrowdblright arrowdbldown omega xi psi zeta similar carriagereturn
  syn keyword postscrConstant   contained lozenge angleleft registersans copyrightsans trademarksans summation
  syn keyword postscrConstant   contained parenlefttp parenleftex parenleftbt bracketlefttp bracketleftex
  syn keyword postscrConstant   contained bracketleftbt bracelefttp braceleftmid braceleftbt braceex euro
  syn keyword postscrConstant   contained angleright integral integraltp integralex integralbt parenrighttp
  syn keyword postscrConstant   contained parenrightex parenrightbt bracketrighttp bracketrightex
  syn keyword postscrConstant   contained bracketrightbt bracerighttp bracerightmid bracerightbt

" ISO Latin1 encoding names
  syn keyword postscrConstant   contained brokenbar copyright registered twosuperior threesuperior
  syn keyword postscrConstant   contained onesuperior onequarter onehalf threequarters
  syn keyword postscrConstant   contained Agrave Aacute Acircumflex Atilde Adieresis Aring Ccedilla Egrave
  syn keyword postscrConstant   contained Eacute Ecircumflex Edieresis Igrave Iacute Icircumflex Idieresis
  syn keyword postscrConstant   contained Eth Ntilde Ograve Oacute Ocircumflex Otilde Odieresis Ugrave Uacute
  syn keyword postscrConstant   contained Ucircumflex Udieresis Yacute Thorn
  syn keyword postscrConstant   contained agrave aacute acircumflex atilde adieresis aring ccedilla egrave
  syn keyword postscrConstant   contained eacute ecircumflex edieresis igrave iacute icircumflex idieresis
  syn keyword postscrConstant   contained eth ntilde ograve oacute ocircumflex otilde odieresis ugrave uacute
  syn keyword postscrConstant   contained ucircumflex udieresis yacute thorn ydieresis
  syn keyword postscrConstant   contained zcaron exclamsmall Hungarumlautsmall dollaroldstyle dollarsuperior
  syn keyword postscrConstant   contained ampersandsmall Acutesmall parenleftsuperior parenrightsuperior
  syn keyword postscrConstant   contained twodotenleader onedotenleader zerooldstyle oneoldstyle twooldstyle
  syn keyword postscrConstant   contained threeoldstyle fouroldstyle fiveoldstyle sixoldstyle sevenoldstyle
  syn keyword postscrConstant   contained eightoldstyle nineoldstyle commasuperior
  syn keyword postscrConstant   contained threequartersemdash periodsuperior questionsmall asuperior bsuperior
  syn keyword postscrConstant   contained centsuperior dsuperior esuperior isuperior lsuperior msuperior
  syn keyword postscrConstant   contained nsuperior osuperior rsuperior ssuperior tsuperior ff ffi ffl
  syn keyword postscrConstant   contained parenleftinferior parenrightinferior Circumflexsmall hyphensuperior
  syn keyword postscrConstant   contained Gravesmall Asmall Bsmall Csmall Dsmall Esmall Fsmall Gsmall Hsmall
  syn keyword postscrConstant   contained Ismall Jsmall Ksmall Lsmall Msmall Nsmall Osmall Psmall Qsmall
  syn keyword postscrConstant   contained Rsmall Ssmall Tsmall Usmall Vsmall Wsmall Xsmall Ysmall Zsmall
  syn keyword postscrConstant   contained colonmonetary onefitted rupiah Tildesmall exclamdownsmall
  syn keyword postscrConstant   contained centoldstyle Lslashsmall Scaronsmall Zcaronsmall Dieresissmall
  syn keyword postscrConstant   contained Brevesmall Caronsmall Dotaccentsmall Macronsmall figuredash
  syn keyword postscrConstant   contained hypheninferior Ogoneksmall Ringsmall Cedillasmall questiondownsmall
  syn keyword postscrConstant   contained oneeighth threeeighths fiveeighths seveneighths onethird twothirds
  syn keyword postscrConstant   contained zerosuperior foursuperior fivesuperior sixsuperior sevensuperior
  syn keyword postscrConstant   contained eightsuperior ninesuperior zeroinferior oneinferior twoinferior
  syn keyword postscrConstant   contained threeinferior fourinferior fiveinferior sixinferior seveninferior
  syn keyword postscrConstant   contained eightinferior nineinferior centinferior dollarinferior periodinferior
  syn keyword postscrConstant   contained commainferior Agravesmall Aacutesmall Ac