[antlr-interest] Language Refactoring??

mzukowski at yci.com mzukowski at yci.com
Wed Mar 5 08:48:23 PST 2003


See my description of translating a 4GL to Visual Basic at
www.codetransform.com/fun_with_antlr.html.  Tools like Eclipse would make it
possible to have some manual supervision of each pass if needed.  My belief
is that the transformation process is best automated and the focus should be
on the user altering either the original 4GL code, the resulting Java code,
or the translation process itself.  I'm not sure how adept a normal
programmer would be at modifying the translations, but it would be much
easier than them trying to modify the parser directly.

In general though, a translation pass is much like a refactoring.  You might
be moving variables around, factoring into other functions, etc.  But you
also do some global stuff like data flow and control flow analysis.  

My concept was to have Eclipse or something show the original code side by
side with the translated code.  If needed you could see how each step of the
translation munged the code, but more importantly you could modify a pass
and see the effect on the code you are inspecting, as well as see how it
affects your unit tests.  In fact you want two sets of tests.  Tests of the
transformation to make sure this program is transformed into this java.  And
then you need real unit tests of the old and new code to make sure they are
doing the same thing.  If you can't test it you'll never know that it is
really working....

It would be a lot of fun to have such an interactive way to develop a
translator.  

On my translation project above the best way to describe what the translator
should do was to have them give me a code fragment and then what they would
have translated it to by hand, explaining to me why.  These turn into tests
quite easily.

In fact there are plenty of refactorings which you would want to run either
before or after the translation, and it would be nice to specify them so
they would be automatic instead of manual.  Manual is for exploration,
refining the strategy.  Automatic is for consistency once the strategy is in
place.

I guess I'm calling refactoring a manual process and translation an
automatic one.

The thing is you don't know the right strategy until you are done.  You
don't want to have refactored half of your code only to discover a better
way to do it all and be faced with starting again from scratch.

My ramblometer is pegging now so I better throttle back.  I hope my
explanation is clear.

Monty

-----Original Message-----
From: yuvaraj_a_r [mailto:yuva at excite.com]
Sent: Wednesday, March 05, 2003 2:19 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Language Refactoring??


Hello,
With the idea of refactoring showing up in other areas of software - 
we have code refactoring, data refactoring etc - I was wondering if 
we can think of Language Refactoring. 

Lets take an example. Assume I have a 4GL Language X which I want to 
transform to Java. However, I face the problem that X has been 
delivered to a whole load of customers and there is a HUGE amount of 
code written in X. So, I would like to provide a sequence 
of "computer language refactoring" steps to move from language X to 
Java. This would mean that there might be an intermediate stage where 
the language is not recognizable as X or Java but is essentially a 
mixture of the two.

Question : Is such a language transformation from one programming 
language to another possible by small reversible (refactoring) steps?

However the problem does not end there. Due to the fact that X has 
survived in the market for some years, supporting libraries and 
semantic constructs peculiar to X have evolved. 

Question : How to take the whole system from X based to Java based?

In this respect, I appreciate the MS .NET strategy of a CLR 
specification. Instead of fighting the problem after it hits us, the 
CLR strategy builds such transformation possibilities directly into 
the language definition....

So, what do you think?

Regards,
yuva




 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list