Translating high-level languages into each other.

"Charles C. Merriam" <seismo!RELAY.CS.NET!merriam@hub.umb.edu>
Tue, 14 Apr 87 16:04:32 EST

          From comp.compilers

Related articles
Translating high-level languages into each other. seismo!RELAY.CS.NET!merriam@hub.umb.edu (Charles C. Merriam) (1987-04-14)
Re: Translating high-level languages into each other. rocksanne!z@CS.ROCHESTER.EDU (1987-04-18)
| List of all articles for this month |

Date: Tue, 14 Apr 87 16:04:32 EST
From: "Charles C. Merriam" <seismo!RELAY.CS.NET!merriam@hub.umb.edu>

[This exchange of messages started when Charles asked if there was a
standard way to translate his source programs when he changed the syntax
of his language a little. Both the language and the programs are invented
for educational purposes. I opined that such a translator is unlikely
to be much easier than any other compiler. -John]


          If there isn't such a thing as an easy translator (since there is
no such thing as an easy parser), how about an easy to use translator
generator? Obviously, for almost all translations, the complete specification
of the language, in BNF or CFG or such, would need to be available and the
specific translation would be initmately related to the specification of the
language. The concepts and routines used in editor generators would be
applicable.


          I honestly don't know if it is fruitful. I am sure that some have
done some work on it and I would like to know the results. Even using
the tools avaiable here (YACC/lex :-( ). It is still better than writing
translators by hand.


Charles Merriam, Computer Scientist in Training
merriam@hub.umb.edu, or merriam%hub.umb.edu@csnet-relay


[My response.]


I guess I don't think there is a lot of difference between a translator and
any other kind of compiler. The lexical and syntactic analysis are the same
either way, except that in a compiler you usually throw away things like
comments and white space and in a translator you probably want to pass
them through, usually with a hack like hanging a comment onto the
preceding token.


Once you've done that, generating "object code" in C or Pascal is not that
different from generating it in assember. You can usually get by without a
synbol table, but I never found that maintaining the symbol table was all
that hard.


I suppose you could take a very different approach and use something like
Snobol4, and have a bunch of patterns and matching translations that you
apply to the entire body of the program.


I'll post these to mod.compilers to see if anybody has other ideas.


John
--


Post a followup to this message

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