Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!rutgers!bpa!temvax!stephen
From: stephen@temvax.UUCP (Stephen C. Arnold)
Newsgroups: comp.object
Subject: Re: OOD applied to interpreters and compilers
Keywords: OOD interpreters
Message-ID: <196@temvax.UUCP>
Date: 3 Oct 89 13:19:10 GMT
References: <26873@genrad.UUCP>
Reply-To: stephen@temvax.UUCP (Stephen C. Arnold)
Organization: Temple University, Institute for Survey Research
Lines: 43

In article <26873@genrad.UUCP> charlie@genrad.com (Charlie D. Havener) writes:
>The examples I have seen on Object Oriented Design apply 
>nicely to problems like graphic window systems and to problems
>in which there are real physical objects one can think about.
>It is not at all clear to me how to apply OOD or to use Object
>oriented programming style to the design of program language
>compilers or interpreters. 
>
>There seems to be a classic way to do these things, i.e. lexer-
>parser-code generator that is well established. 
>
>Can someone who is comfortable with OOD comment on its applicability
>to such problems? Is OOD a poor match to some problems? Will anyone
>admit it?
>
>Comments pro and con appreciated, thanks
>Charlie Havener GenRad Inc. (508-369-4400 x3302) charlie@genrad.com


I really don't count as someone confortable with OOD but I have considered
the problem.  The making of lexical analyser and parser generaters is well
studied and the techiques are quiet good.  My interest is in the extention
of these tools into attribute grammars.

From attempts to implement an attribute grammar in c (using lex and yacc), I
found the nodes of the parse tree acting very much like objects.  The active
attribute instances appear to be messages from one node to the next and
passive attribute instances appear to be the public data space.  Since each
node of the parse tree is so very similer in structure, it appears that a
super class of node, with specific sub-classes for each type of node, may be
an easy way of creating the "data structure" and many of the operations need
for each data structure.

If the node is considered of evaluate it passive attribute instances to
produce its active attribute instances, this could be internal behavior of the
object.  When all the messages come in containing the passive attribute
instances to evaluate an active attribute instance, the message containing the
active attribute instance could be generated and sent to the node in which
this attribute instance is passive.

I've never seen such an implementation, but it does seem a natural aplication
of OOD to attribute grammars and also a natural aplication of OOD to objects
that do not corrispond to some physical objects (such as window diplays).