|Interface between Parse Tree and translators email@example.com (1994-10-15)|
|Re: Interface between Parse Tree and translators firstname.lastname@example.org (1994-10-21)|
|Re: Interface between Parse Tree and translators email@example.com (1994-10-19)|
|Re: Interface between Parse Tree and translators firstname.lastname@example.org (1994-10-22)|
|From:||email@example.com (Mark Stavar)|
|Organization:||Mincom Pty. Ltd.|
|Date:||Wed, 19 Oct 1994 07:23:33 GMT|
Venkateswara Rao (firstname.lastname@example.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
If you are using C, then a structure that includes a union or
nested structures for information required by the specific language
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.
Return to the
Search the comp.compilers archives again.