Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!apple!apple.com!Piersol From: Piersol@apple.com (Kurt Piersol) Newsgroups: comp.object Subject: Re: OOD applied to interpreters and compilers Message-ID: <4514@internal.Apple.COM> Date: 2 Oct 89 19:23:08 GMT References: <26873@genrad.UUCP> Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 51 In article <26873@genrad.UUCP> charlie@genrad.com (Charlie D. Havener) writes: > 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. Peter Deutsch at ParcPlace has built some very interesting parser generators using O-O techniques. He probably has some excellent thoughts on the matter. However, there are a few points to make which come to mind almost immediately. One of the characteristics of Smalltalk-like O-O systems is polymorphism, which when combined with standard message protocols form a concept of types for such languages. This characteristic can be exploited by clever compilation engines to provide easily replaced lexical analysers and parsers. While it is certainly possible to accomplish this in non-O-O languages, it appears much easier in an O-O style. Consider the concept of a token object, which has language specific contents but language independent properties. It contains an identifier in Kanji, yet has properties which identify it as an identifier with a certain identity. Or perhaps it is a binary operator, with the basic properties of such an operator but as yet undefined function. This object could be used by a language independent parser and code generator, which could be the back end for a language independent compiler. The analyzer, which has localized properties, producing a stream of these generalized tokens, which can be used to generate the code. However, the token still retains its full information content, and can be used to easily reconstruct the syntax for debugging purposes. The concept can be applied with greater levels of generalization, to larger and larger language constructions. Given time, it can serve as a basis for support of multiple syntax forms in a single language and programming environment. By using this sort of construction, O-O systems can naturally represent structures which have taken a great deal of work in the traditional compiler community. I'm interested in such concepts, having implemented a few compilers in ST80, and would love to talk offline with anyone interested. Kurt Piersol Senior Scientist Usenet: {sun,...}!apple!Piersol Internet: Piersol@apple.com AppleLink: Piersol.k Disclaimer: The opinions presented in this flame do not in any way represent the opinions of anyone, even myself whilst I was writing it.