target language grammars.

"A.T. Hofkamp" <>
14 Nov 2004 22:43:39 -0500

          From comp.compilers

Related articles
[2 earlier articles]
Re: target language grammars. (Dobes Vandermeer) (2004-11-07)
Re: target language grammars. (Lujop) (2004-11-07)
Re: target language grammars. (2004-11-07)
Re: target language grammars. (2004-11-07)
Re: target language grammars. (Ken Rose) (2004-11-14)
Re: target language grammars. (Ira Baxter) (2004-11-14)
target language grammars. (A.T. Hofkamp) (2004-11-14)
Re: target language grammars. (Zbigniew Chamski) (2004-11-14)
| List of all articles for this month |

From: "A.T. Hofkamp" <>
Newsgroups: comp.compilers
Date: 14 Nov 2004 22:43:39 -0500
Organization: Compilers Central
References: 04-11-013
Keywords: syntax
Posted-Date: 14 Nov 2004 22:43:39 EST

Hello all,

> Can anyone point to applications where the target language
> grammar is made use of?

What about an interactive compiler construction environment where you
define a context-free source language, a context-free target language,
and a set of (functional-style) rewrite rules to rewrite input syntax
to output syntax (with the rewrite rules using both the input and the
output syntax)?

The language that does this is called ASF+SDF, and the implementation
of it is called Meta. You can find it (with many publications) at

I have been using it for almost 2 years now for writing my compiler.
At first having everything based on grammars feels weird, but now I
wouldn't want to go back to the 'old' way with eg lex/yacc.

> Perhaps, in translating a program, we could generate a representation
> of the program as a parse tree in the target language and then

No need to do anything yourselves, Meta does it all for you.

> Mostly here I am thinking of cases where the target language is
> something like postscript, pdf, or latex. (The Lyx program translates
> Lyx files to latex files.)

Since the grammar is context-free, you get context-free output, for
example without proper indentation.
The grammar simply does not contain this layout-information, so it
cannot do layouting of the output.

On the other hand, since the output is available in a tree, you can
quite easily write a formatter if you want.

> I am particularly interested in the case that a target language
> program represents how some data is to be displayed on a computer

If you have a context-free grammar, Meta can give you the output in


Post a followup to this message

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