|target language grammars. email@example.com (2004-11-06)|
|Re: target language grammars. firstname.lastname@example.org (Larry Evans) (2004-11-07)|
|Re: target language grammars. email@example.com (Dobes Vandermeer) (2004-11-07)|
|Re: target language grammars. firstname.lastname@example.org (Lujop) (2004-11-07)|
|Re: target language grammars. email@example.com (2004-11-07)|
|Re: target language grammars. firstname.lastname@example.org (2004-11-07)|
|Re: target language grammars. email@example.com (Ken Rose) (2004-11-14)|
|Re: target language grammars. firstname.lastname@example.org (Ira Baxter) (2004-11-14)|
|target language grammars. email@example.com (A.T. Hofkamp) (2004-11-14)|
|Re: target language grammars. firstname.lastname@example.org (Zbigniew Chamski) (2004-11-14)|
|From:||"Ira Baxter" <email@example.com>|
|Date:||14 Nov 2004 22:42:20 -0500|
|Posted-Date:||14 Nov 2004 22:42:20 EST|
"Ralph Boland" <firstname.lastname@example.org> wrote
> When translating/compiling from one language to another we normally
> have a source language grammar but don't (to my knowledge) make much
> use of any grammar for the target language.
> Does it make sence to make use of a grammar of the target language in
> any way? Can anyone point to applications where the target language
> grammar is made use of?
> Perhaps, in translating a program, we could generate a representation
> of the program as a parse tree in the target language and then
> de-parse the parse tree to get code in the target language.
The DMS Software Reengineering Toolkit is based on exactly this idea.
One defines a set of "grammars" to handle all the input and output
languges. Defining a grammar usually requires specifying BNF rules,
lexing rules, prettyprinting rules, and attribute evaluation rules for
checking context conditions and building symbol tables if needed.
Translation between languages is then stated primarily in terms of
source-to-source code transformations, with the left hand side
specifying an idiom in the source language, and the right hand side
specifying the corresponding idiom in target language. Using ASTs as
intermediate representatations allows transformed results to be
further transformed by more source-to-source transforms, or translated
to yet a 3rd langauge. This latter is useful when staging translation
from a very high level to very low levels; often it is more convenient
to do it in stages rather than to try to jump all the way at once.
DMS is relatively unique in being pure about this. There are other
systems that have tried this idea experimentally. TXL,
ASF+SDF/Stratego also follow this basic principle, but build so-called
"union grammars" to represent both sides of the translation, so they
technically only handle one grammar at a time.
Ira D. Baxter, Ph.D., CTO 512-250-1018
Semantic Designs, Inc. www.semdesigns.com
Return to the
Search the comp.compilers archives again.