Re: Postscript Parser

Tom Lane <tgl@netcom.com>
19 Oct 1997 00:53:25 -0400

          From comp.compilers

Related articles
Postscript Parser withers@cs.man.ac.uk (1997-10-17)
Re: Postscript Parser tgl@netcom.com (Tom Lane) (1997-10-19)
Re: Postscript Parser quite@dial.pipex.com (1997-10-19)
Re: Postscript Parser pd@world.std.com (1997-10-21)
Re: Postscript Parser Wolfgang.Glunz@mchp.siemens.de (Wolfgang Glunz) (1997-10-26)
| List of all articles for this month |

From: Tom Lane <tgl@netcom.com>
Newsgroups: comp.lang.postscript,comp.compilers
Date: 19 Oct 1997 00:53:25 -0400
Organization: Netcom Online Communications Services
References: 97-10-091
Keywords: parse

withers@cs.man.ac.uk (David Withers) writes:
> I'm trying to create a tool that recognises rectangles and text in
> PostScript diagrams and makes HTML image maps. Does anyone know of a
> PostScript parser that creates AST's or a grammar that I can use to
> make one?


> [Sounds impossible to do perfectly, but I suspect some heuristic pattern
> matching could catch a lot of common cases. Postscript has practially no
> syntax, parsing it is just turning RPN into a tree. -John]


More to the point, rectangles and other graphics are the *output*
of the execution of a Postscript program. Parsing is the least
of your worries; if you don't have a full Postscript interpreter,
your chances of getting the right answer are slim to none.


You might possibly be able to get away with pure parsing to understand
the output of certain applications that output very stylized subsets
of Postscript. But the robustness of your code will be nil.


I believe recent releases of Ghostscript can be used in a mode
where evaluated graphics primitives are passed to your output
driver (as opposed to passing a finished bitmap to your driver).
Check it out; that's the only approach that has any hope of
reliable success.


regards, tom lane
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.