(file) Return to postscript.st CVS log (file) (dir) Up to [RizwankCVS] / testProject / share / enscript / hl

  1 rizwank 1.1 /**
  2              * Name: postscript
  3              * Description: PostScript programming language.
  4              *
  5              * Author: Dave Hylands (DHylands@creo.com)
  6              */
  7             
  8             state ps_string extends Highlight
  9             {
 10               /\\\\./ {
 11                 language_print ($0);
 12               }
 13               /[\)]/ {
 14                 language_print ($0);
 15                 return;
 16               }
 17               /[\(]/ {
 18                 /* Balanced ()'s in a string */
 19                 language_print ($0);
 20                 call (ps_string);
 21               }
 22 rizwank 1.1 }
 23             
 24             state ps_encoded_string extends Highlight
 25             {
 26               /[\>]/ {
 27                 language_print ($0);
 28                 return;
 29               }
 30             }
 31             
 32             state postscript extends HighlightEntry
 33             {
 34               /* Comments. */
 35               /%/ {
 36                 comment_face (true);
 37                 language_print ($0);
 38                 call (eat_one_line);
 39                 comment_face (false);
 40               }
 41             
 42               /* String constants. */
 43 rizwank 1.1   /[\(]/ {
 44                 string_face (true);
 45                 language_print ($0);
 46                 call (ps_string);
 47                 string_face (false);
 48               }
 49             
 50               /[\<]/ {
 51                 string_face (true);
 52                 language_print ($0);
 53                 call (ps_encoded_string);
 54                 string_face (false);
 55               }
 56             
 57               /* Keywords.
 58             
 59                  I built the keyword list using the following PostScript program
 60             
 61             	/str 128 string def
 62             	/outFile \(ps.txt)(w)file def
 63             	/proc
 64 rizwank 1.1 	{
 65             	    pop //str cvs outFile exch writestring outFile (\n) writestring
 66             	} bind def
 67             
 68             	systemdict /proc load forall
 69             	statusdict /proc load forall
 70             	errordict  /proc load forall
 71             
 72                 I then ran:
 73             
 74             	sort ps.txt | uniq | fmt > ps.key
 75             
 76                 I then went through the list and removed << >> [ ] and obvious Harlequin
 77                 extensions. Many of the keywords remaining are not documented in the Red
 78                 Book but are implemented in some Adobe implementations (especially the
 79                 ones from statusdict). I decided to leave them in.
 80             
 81                 And since I don't have emacs (gasp), I wrote a program which takes the
 82                 ps.key file and generates the regular expression. This was faster than
 83                 trying to install emacs and figure out how it works.
 84             
 85 rizwank 1.1     Also note that PostScript doesn't require whitespace in front of keywords.
 86                 In particular, text can follow immediately after any of the following
 87                 characters:
 88             
 89             	> { } ) [ ] /
 90             
 91                 and can be followed immediately by the following:
 92             
 93             	< { } ( [ ] /
 94             
 95                 in addition to white space.
 96             
 97                 Contents of ps.key:
 98             
 99                 $error .error 11x17tray 12x24tray 15x24tray = == =print =scratch =string
100                 FontDirectory GlobalFontDirectory ISOLatin1Encoding
101                 Run SharedFontDirectory SpecialRun StandardEncoding
102                 VMerror a2tray a3tray a4tray a5tray abs add aload
103                 anchorsearch and appletalktype arc arcn arct arcto array ashow astore
104                 atan authors awidthshow b5tray begin bind bitshift blackoverprint blink
105                 broadsheettray buildtime bytesavailable cachestatus ceiling cexec
106 rizwank 1.1     charpath checkpassword checkscreen clear cleardictstack clearinterrupt
107                 cleartomark clip clippath closefile closepath closescc colorimage concat
108                 concatmatrix configurationerror copy copypage cos count countdictstack
109                 countexecstack counttomark cshow currentblackgeneration
110                 currentcacheparams currentcmykcolor currentcolor currentcolorrendering
111                 currentcolorrenderingintent currentcolorscreen currentcolorspace
112                 currentcolortransfer currentdash currentdevparams currentdict
113                 currentdlhooks currentfile currentflat currentfont currentglobal
114                 currentgray currentgstate currenthalftone currenthalftonephase
115                 currenthsbcolor currentinterceptcolorspace currentlinecap
116                 currentlinejoin currentlinewidth currentmatrix currentmiterlimit
117                 currentobjectformat currentoverprint currentpacking currentpagedevice
118                 currentpoint currentrelativeneutrals currentreproductioncriteria
119                 currentrgbcolor currentscreen currentseparationcolornames
120                 currentseparationorder currentshared currentstrokeadjust
121                 currentsystemparams currenttransfer currenttrapintent
122                 currentundercolorremoval currentuserparams curveto cvi cvlit cvn cvr
123                 cvrs cvs cvx daytime def defaultblackoverprint
124                 defaulthandleerror defaultmatrix defaultmirrorprint defaultpagemargin
125                 defaultpageparams defaultprocesscolors defaulttimeouts definefont
126                 defineresource defineuserobject deletefile devdismount devforall
127 rizwank 1.1     devformat deviceinfo devmount devstatus dict dictfull dictstack
128                 dictstackoverflow dictstackunderflow disableinterrupt diskonline
129                 diskstatus div dlclearcaches dostartpage dosysstart dtransform dup echo
130                 eerom eescratch eexec enableinterrupt end endofjob eoclip eofill eq
131                 erasepage errorbeep errordict exch exec execdict execform execstack
132                 execstackoverflow execuserobject executeonly executive exit exp exposure
133                 false file filekind filelinenumber filename filenameforall fileposition
134                 fill filter findcharstrings findcolorrenderingintent findencoding
135                 findfont findpgfont findresource flattenpath floor flush flushcache
136                 flushfile for forall gcheck ge genericpaper get getinterval getknown
137                 getsccconfig gettopfile gettoprealfile globaldict glyphshow grestore
138                 grestoreall gsave gstate gt handleerror hardwareiomode
139                 identmatrix idiv idlefonts idtransform if ifelse
140                 image imagemask index ineofill infill initclip initgraphics initialized
141                 initializedisk initmatrix instroke internaldict interrupt
142                 interruptenabled inueofill inufill inustroke invalidaccess invalidexit
143                 invalidfileaccess invalidfont invalidrestore invertmatrix ioerror
144                 ismanualfeed itransform jobname jobsource jobstate jobstring jobtimeout
145                 known kshow languagelevel lastmode le ledgertray legaltray length
146                 lettertray limitcheck lineto listfilesinestack ln load
147                 loadcurrentpagedevice loadsetpagedevice log loop lt makefont makepattern
148 rizwank 1.1     manualfeedtimeout margins mark matchtemplate matrix maxlength
149                 medialength mediasize mediawidth mirrorprint mod moveto mul ne neg
150                 negativeprint newpath noaccess nocurrentpoint not null nulldevice
151                 openscc or packedarray pagecount pagemargin pageparams pagestackorder
152                 pagetype pathbbox pathforall pop print printererror printermessage
153                 printername printerstatus printerupset printobject processcolors product
154                 prompt pstack put putinterval quit ramsize rand rangecheck rcheck
155                 rcurveto read readhexstring readline readonly readstring realtime
156                 rectclip rectfill rectstroke renamefile repeat resetfile resetprinter
157                 resolution resourceforall resourcestatus restore reversepath revision
158                 rlineto rmoveto roll rootfont rotate round rrand run save scale
159                 scalefont sccbatch sccfiles sccinteractive scheck screenforall search
160                 selectfont sendctrld sendpcmd sendprinterstate serialnumber serverdict
161                 setaccuratescreens setbbox setblackgeneration setblackoverprint setblink
162                 setcachedevice setcachedevice2 setcachelimit setcacheparams setcharwidth
163                 setcmykcolor setcolor setcolorrendering setcolorrenderingintent
164                 setcolorscreen setcolorspace setcolortransfer setdash
165                 setdefaultblackoverprint setdefaultmirrorprint setdefaultpagemargin
166                 setdefaultpageparams setdefaultprocesscolors setdefaulttimeouts
167                 setdevparams setdlhooks setdostartpage setdosysstart seteescratch
168                 setexposure setfileposition setflat setfont setglobal setgray setgstate
169 rizwank 1.1     sethalftone sethalftonephase sethardwareiomode sethsbcolor setidlefonts
170                 setinterceptcolorspace setjobtimeout setlinecap setlinejoin setlinewidth
171                 setmargins setmatrix setmirrorprint setmiterlimit setnegativeprint
172                 setobjectformat setoverprint setpacking setpage setpagedevice
173                 setpagemargin setpageparams setpageseen setpagestackorder setpagetype
174                 setpassword setpattern setprintername setprocesscolors
175                 setrelativeneutrals setreproductioncriteria setresolution setrgbcolor
176                 setsccbatch setsccconfig setsccinteractive setscreen setshared
177                 setsoftwareiomode setstderr setstdio setstrokeadjust setsystemparams
178                 settransfer settrapintent setucacheparams setundercolorremoval
179                 setuserdiskpercent setuserparams setvmthreshold shareddict show showpage
180                 sin softwareiomode sqrt srand stack stackoverflow stackunderflow start
181                 startjob startpage status statuscommand statusdict stop stopped store
182                 string stringwidth stroke strokepath sub superstop superstopped
183                 switchsetting syntaxerror system systemdict tabloidtray timeout token
184                 transform translate true truncate type typecheck uappend ucache
185                 ucachestatus ueofill ufill undef undefined undefinedfilename
186                 undefinedresource undefinedresult undefinefont undefineresource
187                 undefineuserobject unmatchedmark unregistered upath userdict
188                 userdiskpercent usertime ustroke ustrokepath validatefont version
189                 vmreclaim vmstatus waittimeout wcheck where widthshow write
190 rizwank 1.1     writehexstring writeobject writestring xcheck xor xshow xyshow yshow
191               */
192               /(\b|[\>\{\}\)\[\]\/])\
193             (\$error|\.error|1(1x17tray|2x24tray|5x24tray)|=(|=|print|s(cratch|tring))\
194             |FontDirectory|GlobalFontDirectory|ISOLatin1Encoding|Run|S\
195             (haredFontDirectory|pecialRun|tandardEncoding)|VMerror|a(2tray|3tray\
196             |4tray|5tray|bs|dd|load|n(chorsearch|d)|ppletalktype|r(c(|n|t(|o))|ray)|s\
197             (how|tore)|tan|uthors|widthshow)|b(5tray|egin|i(nd|tshift)|l\
198             (ackoverprint|ink)|roadsheettray|uildtime|ytesavailable)|c(achestatus|e\
199             (iling|xec)|h(arpath|eck(password|screen))|l(ear(|dictstack|interrupt\
200             |tomark)|ip(|path)|ose(file|path|scc))|o(lorimage|n(cat(|matrix)\
201             |figurationerror)|py(|page)|s|unt(|dictstack|execstack|tomark))|show|ur\
202             (rent(blackgeneration|c(acheparams|mykcolor|olor(|rendering(|intent)|s\
203             (creen|pace)|transfer))|d(ash|evparams|ict|lhooks)|f(ile|lat|ont)|g(lobal\
204             |ray|state)|h(alftone(|phase)|sbcolor)|interceptcolorspace|line(cap|join\
205             |width)|m(atrix|iterlimit)|o(bjectformat|verprint)|p(a(cking|gedevice)\
206             |oint)|r(e(lativeneutrals|productioncriteria)|gbcolor)|s(creen|eparation\
207             (colornames|order)|hared|trokeadjust|ystemparams)|tra(nsfer|pintent)|u\
208             (ndercolorremoval|serparams))|veto)|v(i|lit|n|r(|s)|s|x))|d(aytime|e(f(\
209             |ault(blackoverprint|handleerror|m(atrix|irrorprint)|p(age(margin\
210             |params)|rocesscolors)|timeouts)|ine(font|resource|userobject))|letefile|v\
211 rizwank 1.1 (dismount|for(all|mat)|iceinfo|mount|status))|i(ct(|full|stack(|overflow\
212             |underflow))|s(ableinterrupt|k(online|status))|v)|lclearcaches|os(tartpage\
213             |ysstart)|transform|up)|e(cho|e(rom|scratch|xec)|n(ableinterrupt|d(\
214             |ofjob))|o(clip|fill)|q|r(asepage|ror(beep|dict))|x(ch|ec(|dict|form|stack\
215             (|overflow)|u(serobject|t(eonly|ive)))|it|p(|osure)))|f(alse|i(l(e(|kind\
216             |linenumber|name(|forall)|position)|l|ter)|nd(c(harstrings\
217             |olorrenderingintent)|encoding|font|pgfont|resource))|l(attenpath|oor\
218             |ush(|cache|file))|or(|all))|g(check|e(|nericpaper|t(|interval|known\
219             |sccconfig|top(file|realfile)))|l(obaldict|yphshow)|restore(|all)|s(ave\
220             |tate)|t)|ha(ndleerror|rdwareiomode)|i(d(entmatrix|iv|lefonts|transform)\
221             |f(|else)|mage(|mask)|n(dex|eofill|fill|it(clip|graphics|ialized(|isk)\
222             |matrix)|stroke|ter(naldict|rupt(|enabled))|u(eofill|fill|stroke)|v(alid\
223             (access|exit|f(ileaccess|ont)|restore)|ertmatrix))|oerror|smanualfeed\
224             |transform)|job(name|s(ource|t(ate|ring))|timeout)|k(nown|show)|l(a\
225             (nguagelevel|stmode)|e(|dgertray|galtray|ngth|ttertray)|i(mitcheck|neto\
226             |stfilesinestack)|n|o(ad(|currentpagedevice|setpagedevice)|g|op)|t)|m(a\
227             (ke(font|pattern)|nualfeedtimeout|r(gins|k)|t(chtemplate|rix)|xlength)\
228             |edia(length|size|width)|irrorprint|o(d|veto)|ul)|n(e(|g(|ativeprint)\
229             |wpath)|o(access|currentpoint|t)|ull(|device))|o(penscc|r)|p(a(ckedarray\
230             |ge(count|margin|params|stackorder|type)|th(bbox|forall))|op|r(int(|er\
231             (error|message|name|status|upset)|object)|o(cesscolors|duct|mpt))|stack\
232 rizwank 1.1 |ut(|interval))|quit|r(a(msize|n(d|gecheck))|c(heck|urveto)|e(a(d(\
233             |hexstring|line|only|string)|ltime)|ct(clip|fill|stroke)|namefile|peat|s\
234             (et(file|printer)|o(lution|urce(forall|status))|tore)|v(ersepath|ision))\
235             |lineto|moveto|o(ll|otfont|tate|und)|rand|un)|s(ave|c(ale(|font)|c(batch\
236             |files|interactive)|heck|reenforall)|e(arch|lectfont|nd(ctrld|p(cmd\
237             |rinterstate))|r(ialnumber|verdict)|t(accuratescreens|b(box|l(ack\
238             (generation|overprint)|ink))|c(ache(device(|2)|limit|params)|harwidth\
239             |mykcolor|olor(|rendering(|intent)|s(creen|pace)|transfer))|d(ash|e(fault\
240             (blackoverprint|mirrorprint|p(age(margin|params)|rocesscolors)|timeouts)\
241             |vparams)|lhooks|os(tartpage|ysstart))|e(escratch|xposure)|f(ileposition\
242             |lat|ont)|g(lobal|ray|state)|h(a(lftone(|phase)|rdwareiomode)|sbcolor)|i\
243             (dlefonts|nterceptcolorspace)|jobtimeout|line(cap|join|width)|m(a(rgins\
244             |trix)|i(rrorprint|terlimit))|negativeprint|o(bjectformat|verprint)|p(a\
245             (cking|ge(|device|margin|params|s(een|tackorder)|type)|ssword|ttern)|r\
246             (intername|ocesscolors))|r(e(lativeneutrals|productioncriteria|solution)\
247             |gbcolor)|s(c(c(batch|config|interactive)|reen)|hared|oftwareiomode|t(d\
248             (err|io)|rokeadjust)|ystemparams)|tra(nsfer|pintent)|u(cacheparams\
249             |ndercolorremoval|ser(diskpercent|params))|vmthreshold))|h(areddict|ow(\
250             |page))|in|oftwareiomode|qrt|rand|t(a(ck(|overflow|underflow)|rt(|job\
251             |page)|tus(|command|dict))|o(p(|ped)|re)|r(ing(|width)|oke(|path)))|u(b\
252             |perstop(|ped))|witchsetting|y(ntaxerror|stem(|dict)))|t(abloidtray|imeout\
253 rizwank 1.1 |oken|r(ans(form|late)|u(e|ncate))|ype(|check))|u(append|cache(|status)\
254             |eofill|fill|n(def(|ine(d(|filename|res(ource|ult))|font|resource\
255             |userobject))|matchedmark|registered)|path|s(er(di(ct|skpercent)|time)\
256             |troke(|path)))|v(alidatefont|ersion|m(reclaim|status))|w(aittimeout|check\
257             |here|idthshow|rite(|hexstring|object|string))|x(check|or|show|yshow)\
258             |yshow)\
259             (\b|[\<\{\}\(\[\]\/])/ {
260                 keyword_face (true);
261                 language_print ($0);
262                 keyword_face (false);
263               }
264             }
265             
266             
267             /*
268             Local variables:
269             mode: c
270             End:
271             */

Rizwan Kassim
Powered by
ViewCVS 0.9.2