|Source to source compiling firstname.lastname@example.org (Casper Gripenberg) (1994-09-11)|
|Re: Source to source compiling eanders+@CMU.EDU (Eric A. Anderson) (1994-09-12)|
|Re: Source to source compiling email@example.com (1994-09-14)|
|Re: Source to source compiling firstname.lastname@example.org (1994-09-13)|
|Re: Source to source compiling email@example.com (1994-09-13)|
|Re: source to source compiling firstname.lastname@example.org (1994-09-18)|
|Re: Source to source compiling email@example.com (Robert Bernecky) (1994-09-18)|
|[5 later articles]|
|From:||Casper Gripenberg <firstname.lastname@example.org>|
|Date:||Sun, 11 Sep 1994 23:44:09 GMT|
I am currently working on a source to source compiler. The source
language is a kind of state langage. A program containes 1-n states. All
states have the same kind of structure, ie. in the beginning you initilaze
variables, then comes some code to execute and at last a bunch of
conditional jumps to other states.
if (a) goto STATE3;
if (b) goto STATE2;
The destination langage is very c-like. With while loops and if-then-else
Now the problem is that I don't know how to convert these conditional goto
statements in the source language to while/if-then-else constructs in the
destination language. How do I check for eg. loops, and presumably some of
the goto statements just cannot be translated into if-them-else statements.
One kludgy solution would be to model every state as a function in the
destination language. Then every goto statement in the source language
would simply convert to a function call in the destination language.
I have made compilers that convert loops & if-then-else statements into
goto statements, ie. using short-circuit code (from the dragon book :)),
but I have no idea how to do it the other way.
Are there any books on the subject or any ready-made similar compilers
that I could check out.
Return to the
Search the comp.compilers archives again.