Re: target language grammars.

"Ira Baxter" <idbaxter@semdesigns.com>
14 Nov 2004 22:42:20 -0500

          From comp.compilers

Related articles
target language grammars. ralphpboland@yahoo.com (2004-11-06)
Re: target language grammars. cppljevans@cox-internet.com (Larry Evans) (2004-11-07)
Re: target language grammars. dobes@dobesland.com (Dobes Vandermeer) (2004-11-07)
Re: target language grammars. lujoplujop@gmail.com (Lujop) (2004-11-07)
Re: target language grammars. vbdis@aol.com (2004-11-07)
Re: target language grammars. cgweav@aol.com (2004-11-07)
Re: target language grammars. kenrose@tfb.com (Ken Rose) (2004-11-14)
Re: target language grammars. idbaxter@semdesigns.com (Ira Baxter) (2004-11-14)
target language grammars. a.t.hofkamp@tue.nl (A.T. Hofkamp) (2004-11-14)
Re: target language grammars. zbigniew@planet.nl (Zbigniew Chamski) (2004-11-14)
| List of all articles for this month |

From: "Ira Baxter" <idbaxter@semdesigns.com>
Newsgroups: comp.compilers
Date: 14 Nov 2004 22:42:20 -0500
Organization: http://extra.newsguy.com
References: 04-11-013
Keywords: parse, translator
Posted-Date: 14 Nov 2004 22:42:20 EST

"Ralph Boland" <ralphpboland@yahoo.com> 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.


See http://www.semanticdesigns.com/Products/DMS/DMSToolkit.html.


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


Post a followup to this message

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