Path: utzoo!attcan!uunet!lll-winken!ames!mailrus!ncar!ico!rcd From: rcd@ico.ISC.COM (Dick Dunn) Newsgroups: comp.lang.postscript Subject: Re: A PostScript Debugger Summary: syntax isn't the hard part Message-ID: <13958@ico.ISC.COM> Date: 26 Jan 89 04:44:56 GMT References: <6967@pucc.Princeton.EDU> Distribution: na Organization: Interactive Systems Corp, Boulder, CO Lines: 38 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.