[comp.lang.postscript] A PostScript Debugger

JEFF@pucc.Princeton.EDU (Jeffrey Perry) (01/24/89)

Does anyone know of a commercially-available program (or possibly
a piece of shareware) that debugs Adobe PostScript syntax?  What
I need is something to weed out my mistakes BEFORE I send a long
file to the Laserwriter.  (I am aware that Lasertalk, Laser Status &
similar products tell you, in a rather terse fashion, what has gone wrong
once you have sent your file.)  Such a program would make learning
PostScript much easier; I can't believe that someone hasn't come out
with one by now.

JEFF@pucc.Princeton.EDU (Jeffrey Perry) (01/26/89)

A clarification to my posting of yesterday.  I asked if anyone knew
of debugging software for PostScript files (i.e. something that would
allow me to find out what my syntax errors etc. were before sending my
program to the printer). I didn't mention that what I am interested
in is such a tool for the Macintosh.  My apologies for leaving off
this bit of information.  I still am interested in finding such a
product if anyone knows about one (perhaps posting a reply to comp.lang.mac
would be most appropriate, or sending mail to me directly).

rcd@ico.ISC.COM (Dick Dunn) (01/26/89)

In article <6967@pucc.Princeton.EDU>, JEFF@pucc.Princeton.EDU (Jeffrey Perry) writes:
> Does anyone know of a commercially-available program (or possibly
> a piece of shareware) that debugs Adobe PostScript syntax?  What
> I need is something to weed out my mistakes BEFORE I send a long
> file to the Laserwriter...

It wouldn't be hard to write a PostScript syntax checker--perhaps an
afternoon of C coding--but it wouldn't be very useful.  Because of the
postfix notation, the syntax is trivial, amounting to checking for tokens
being well-formed and brackets/braces matched.  In fact, I suspect that's
not the total of what you're after.  If you're looking to catch undefined
variables and procedures, mismatched types, etc., it's quite a different
matter.

In a typed, compiled language like C, this is the stuff we normally call
the "static semantics"--meaning semantic correctness which can be checked
statically.  The catch is that in PostScript it isn't static.  Names are
bound to objects dynamically, and there's nothing incorrect about having
the same name bound to a string, an integer, and a procedure in the same
dictionary at different points in execution.  (It may be bad style, but
it's not wrong.)  Names can even be manufactured by computation--a concept
which isn't meaningful in a language like C.

So how would you go about checking for the things that usually bite you (or
at least they usually bite me!:-) in developing new PostScript?  If you
explore the idea, you'll find that it eventually grows to the problem of
re-implementing a fair part of the PostScript interpreter!

What you might do, though (just an untested idea) is to build a prologue
which replaces some of the expensive operators (like show) plus the ones
that actually print (showpage, copypage) with innocuous ones.  Glue this on
to the front of your file and toss it at the printer; that will force it
through interpretation of the program, but faster than if you imaged and
printed everything.  (After all, the printer DOES contain a PostScript
interpreter.)
-- 
Dick Dunn      UUCP: {ncar,nbires}!ico!rcd           (303)449-2870
   ...A friend of the devil is a friend of mine.

mh@wlbr.EATON.COM (Mike Hoegeman) (01/26/89)

In article <6967@pucc.Princeton.EDU> JEFF@pucc.Princeton.EDU writes:
>Does anyone know of a commercially-available program (or possibly
>a piece of shareware) that debugs Adobe PostScript syntax?  What
>I need is something to weed out my mistakes BEFORE I send a long
>file to the Laserwriter.  (I am aware that Lasertalk, Laser Status &
>similar products tell you, in a rather terse fashion, what has gone wrong
>once you have sent your file.)  Such a program would make learning
>PostScript much easier; I can't believe that someone hasn't come out
>with one by now.

if you've got a machine that can run NeWS (silicon graphics, suns,
raster technologies, mac II / AUX, os2 machine using vga or ega, and
others......) i recommend buying the NeWS WIndow package and using it to debug
your PostScript.  It's got both a decent previewer available for it
(for free). as well as the best PostScript debugger i've seen yet.
(must admit i've only actually SEEN a couple at all).You get a GREAT
windowing system too boot.

I believe NeWS is the stock window system for Silicon graphics machines
these days.  NeWS for suns is around $150 in price(last time i looked)
for the mac it's like $500. these prices I've noted here are just
ballpark figures.  if anyone wants more specific info send me some mail
and I'll dig up more specifics.

if you do alot of Printer PostScript debugging, NeWS is worth it even if
you don't use it for anything else (which would be a shame).

-mike