Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!clyde!ima!johnl From: johnl@ima.UUCP Newsgroups: mod.compilers Subject: Translating high-level languages into each other. Message-ID: <541@ima.UUCP> Date: Tue, 14-Apr-87 16:04:32 EST Article-I.D.: ima.541 Posted: Tue Apr 14 16:04:32 1987 Date-Received: Sun, 19-Apr-87 04:40:26 EST Sender: johnl@ima.UUCP Lines: 48 Approved: compilers@ima.UUCP [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 -- Send compilers articles to ima!compilers or, in a pinch, to Levine@YALE.ARPA Plausible paths are { ihnp4 | decvax | cbosgd | harvard | yale | cca}!ima Please send responses to the originator of the message -- I cannot forward mail accidentally sent back to compilers. Meta-mail to ima!compilers-request