Using SmaCC to transform AST?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Using SmaCC to transform AST?

Jean-Christophe Bach
Hi,

We are trying to transform programs (from Delphi to Java). We already
have source and target ASTs and we would like to write the
transformation itself. We are wondering if we could use SmaCC to do that
but we are not able to figure out how. The documentation is not clear
on the fact that it is possible or not to use any AST as input. Does
anyone know if it is possible?

Then, in the tutorial, the example seems to be a string-based
transformation while we would like to transform ASTs. Are we wrong? What
have we missed?
In Python tests, there are ASTs but we did not find any transformation.

Has someone a clear and concise example to help us to start?

Thank you in advance,

Jean-Christophe

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Using SmaCC to transform AST?

Thierry Goubier
Hi Jean-Christophe,

Yes, SmaCC has the infrastructure for doing that, in text form (match an ast subtree, produce a string) and linked to SmaCC produced ASTs (I believe by using a GLR parser to generate multiple matches on an input pattern). Using text is a deliberate design decision [1], as far as I know, and I can understand why ;) But under some conditions, you can easily move from text replacement to AST subtrees injection; ask me for more details.

For a system that transform ASTs, you want want to look at DMS [2]. Just significantly more expensive. Another idea would be a derivative of the RB engine you have in Pharo (after all, RB is from the same guys as SmaCC).

At the moment, the rewritting part of SmaCC is not that tested (or not working, for the master/slave client/serveur rewritting engine part), so I'd be really interested to have some feedback if you decide to use it.

Thierry

[1]John Brant, Don Roberts, Bill Plendl, Jeff Prince, "Extreme maintenance: Transforming Delphi into C#," 2013 IEEE International Conference on Software Maintenance, pp. 1-8, 2010 IEEE International Conference on Software Maintenance, 2010

[2] http://www.semdesigns.com/Products/DMS/DMSToolkit.html

2015-02-04 15:57 GMT+01:00 Jean-Christophe Bach <[hidden email]>:
Hi,

We are trying to transform programs (from Delphi to Java). We already
have source and target ASTs and we would like to write the
transformation itself. We are wondering if we could use SmaCC to do that
but we are not able to figure out how. The documentation is not clear
on the fact that it is possible or not to use any AST as input. Does
anyone know if it is possible?

Then, in the tutorial, the example seems to be a string-based
transformation while we would like to transform ASTs. Are we wrong? What
have we missed?
In Python tests, there are ASTs but we did not find any transformation.

Has someone a clear and concise example to help us to start?

Thank you in advance,

Jean-Christophe