🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #8674

Re: Compiled PostScript

#8674
From: Dick Dunn
Date: Sun, 31 Dec 1989 05:38
34 lines
1988 bytes
woody@rpp386.cactus.org (Woodrow Baker) writes:
[deleted 14 included lines of my comments about how simple a PostScript
grammar would be]

> Amen.  Being that we are dealing with a language that is not a context-free
> grammer, It does not make much sense to compile it...

Woody, if you're going to agree with me, could you at least agree with
something I said (instead of the exact opposite)?!?

It's trivial to write a context-free grammar for PostScript.  And that's
not the reason for not compiling it.

Assume a lexer which will recognize the tokens (identifiers, names,
strings, numbers, etc.) of PostScript.  The grammar, in some typical eBNF,
probably looks about like this:

<PostScript-program> = <chunk>*
<chunk> = <token> | '{' <chunk>* '}'

I was profligate of rules, using two where one would suffice, in order to
show the likely two-state character of the parser (which corresponds to the
interpreter) and make things look nicer.

Not that no attempt is made to identify or parse operators, since in the
general case none can be made.  Also note that the grammar only matches
braces, not brackets, since brackets need not match in the textual
structure of the program...their matching is dynamic.

[Noted in passing: Probably the "bind" operator does the most useful part
of what a PostScript compiler might do.]
-- 
Dick Dunn     rcd@ico.isc.com    uucp: {ncar,nbires}!ico!rcd     (303)449-2870
   ...Mr. Natural says, "Use the right tool for the job."
Technical Details
Message-ID: <1989Dec31.053812.3410@ico.isc.com>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!rex!ames!ncar!ico!rcd
References: <POLLACK.89Dec4133944@toto.cis.ohio-state.edu> <28@macuni.mqcc.mq.oz> <17503@rpp386.cactus.org>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!rex!ames!ncar!ico!rcd
From: rcd@ico.isc.com (Dick Dunn)
Newsgroups: comp.lang.postscript
Subject: Re: Compiled PostScript
Summary: context-free PostScript grammar
Message-ID: <1989Dec31.053812.3410@ico.isc.com>
Date: 31 Dec 89 05:38:12 GMT
References: <POLLACK.89Dec4133944@toto.cis.ohio-state.edu> <28@macuni.mqcc.mq.oz> <17503@rpp386.cactus.org>
Distribution: comp
Organization: Interactive Systems Corporation, Boulder, CO
Lines: 34