Re: [abc-users] Obtaining a program AST using abc

From: Eric Bodden <eric.bodden_at_mail.mcgill.ca>
Date: Fri, 3 Oct 2008 13:16:02 -0400

For polyglot-based ASTs the principal way of accessing these ASTs is
to use a visitor (any subtype of polyglot.visit.NodeVisitor). Examples
of those, and how those visitor passes are scheduled can be seen in
the different ExtensionInfo classes, e.g. abc.aspectj.ExtensionInfo
(for plain AspectJ) or abc.eaj.ExtensionInfo (for the EAJ language
extension).

If by "store" you mean "store on disk" that may be tricky because you
would need to somehow serialize the entire AST. If you just mean
"store as a reference" that should be easily possible I suppose.

Eric

2008/10/3 Luca Cavallaro <cavallaro_at_elet.polimi.it>:
> Dear Eric,
> thank you for your reply. My question was quite generic, so I am trying to
> sharpen it.
> I am using polyglot and what I want to do is to compare the ASTs of two
> different versions of the same program. My idea is to store somewhere the
> first version AST and to compare the second one with the stored one.
> May I ask you some further hints on my problem?
> Thanks
> Luca
>
> Eric Bodden wrote:
>>
>> Hi Luca.
>>
>> The way in which to access and transform the AST depends on whether or
>> not you are using the JastAdd-based frontend for your abc extension.
>> So are you using polyglot or JastAdd?
>>
>> In cases where you are using polyglot, the extension abc.eaj is a good
>> entry-level tutorial (although it does not show anything in terms of
>> AST transformations IIRC), in cases where you are using JastAdd you
>> should rather have a look at abc.ja.eaj.
>>
>> Hope that helps.
>>
>> Eric
>>
>> 2008/10/3 Luca Cavallaro <cavallaro_at_elet.polimi.it>:
>>
>>>
>>> Dear all,
>>> I am quite new to abc and I was trying to programmatically access and
>>> manipulate an aAspectJ program Abstract Syntax Tree using abc.
>>> Anybody can suggest me a solution please?
>>> Best regards
>>> Luca Cavallaro
>>>
>>> --
>>> Luca Cavallaro
>>> Ph.D. student
>>> DEI, Politecnico di Milano,
>>> Via Golgi 40
>>> 200133 Milan,
>>> Italy
>>> /------------------------------------------------------------/
>>> Aphasia is the loss of speech in computer scientists when asked:
>>> "But of what use is your research?"
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
>
> --
> Luca Cavallaro
> Ph.D. student
> DEI, Politecnico di Milano,
> Via Golgi 40
> 200133 Milan,
> Italy
> /------------------------------------------------------------/
> Aphasia is the loss of speech in computer scientists when asked:
> "But of what use is your research?"
>
>
>
>

-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada
Received on Fri Oct 03 2008 - 18:16:06 BST

This archive was generated by hypermail 2.2.0 : Tue Oct 07 2008 - 17:40:12 BST