Re: Interface between Parse Tree and translators

marks@orb.mincom.oz.au (Mark Stavar)
Wed, 19 Oct 1994 07:23:33 GMT

          From comp.compilers

Related articles
Interface between Parse Tree and translators kvrao@m-net.arbornet.org (1994-10-15)
Re: Interface between Parse Tree and translators danhicks@aol.com (1994-10-21)
Re: Interface between Parse Tree and translators marks@orb.mincom.oz.au (1994-10-19)
Re: Interface between Parse Tree and translators kvrao@m-net.arbornet.org (1994-10-22)
| List of all articles for this month |

Newsgroups: comp.compilers
From: marks@orb.mincom.oz.au (Mark Stavar)
Keywords: OOP, design
Organization: Mincom Pty. Ltd.
References: 94-10-119
Date: Wed, 19 Oct 1994 07:23:33 GMT

Venkateswara Rao (kvrao@m-net.arbornet.org) wrote:
: Hi every body,


: I am involved in a compiler project using OO methodology. I am facing the
: following problem :


: The parser reads a language and creates the parse tree. Now I need to
: call translators of 4 other languages each of which has their CodeGen
: functions which expect data in some form. So the xlators have to create
: the required data structures out of parse tree and call codegen function
: of the respective language. As the parse tree can not have any thing
: specific to any language, how can I design the interface to all xlators
: in "truly" object-oriented way?


: Can anybody suggest a solution to cleanly define an interface between parse
: tree and the translators?


A couple of questions come to mind initially:




1. What language are you going to use for implementation?


      Does the implementation language support constructs such as
      multiple-inheritance? This could have a significant influence on
      the design you end up with.




2. Do know what language is to be generated at the time of parsing?


      If using C++, then you might be able to use the inheritance
      mechanism to good effect. A base class which stores generic
      information would then be built on to cover those language specific
      elements.


      If you are using C, then a structure that includes a union or
      nested structures for information required by the specific language
      generators.


3. What language are the CodeGen modules developed in?


      How easily can you communicate with them? What exactly do they
      expect to receive? A C struct, an class pointer, a text string,...?




Some initial thoughts.


Ciao,


mark
--


Post a followup to this message

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