flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gordon Smith <gsmit...@hotmail.com>
Subject Re: ActionScript AST
Date Tue, 01 Jul 2014 16:12:18 GMT
There are APIs in each node class that are used to build the AST (based on the token stream),
and you should be able to use them to modify an existing AST. But there is currently no way
to listen to changes. You can turn an AST into ABC byte code but not back into AS source code.
However, regenerating AS should be reasonably easy if you need to do that. But if you need
to maintain the same formatting that the original AS had, it will be hard because the current
AST represents the complete semantics of the AS but not the complete formatting of the AS.
For example, the AST does not represent any comments or any semicolons that terminate statements.

- Gordon

Sent from my iPad

> On Jun 30, 2014, at 9:59 AM, "Alex Harui" <aharui@adobe.com> wrote:
> 
> Hopefully Gordon will reply as he knows this code better.  I haven't had to do much AST
surgery.
> 
> I do want to point out that in the FalconJX project, the AST code generation is done
differently.  There is no ABC output for FalconJX but it would be interesting to have one
in order to compare performance against the BURM the regular Falcon project uses.  Output
hacking might be easier in FalconJX.
> 
> -Alex 
> ________________________________________
> From: Mariana Gheorghe [mariana.gheorghe@crispico.com]
> Sent: Monday, June 30, 2014 7:35 AM
> To: users@flex.apache.org
> Subject: Re: ActionScript AST
> 
> Thank you both for the suggestion, we've started using Falcon, and
> indeed, it seems that the AST is much easier to use, and the code is
> well documented.
> 
> So far, we have obtained the AST for an AS file, and now we are looking
> for a way to do rewriting. We want to be able to make modifications to
> the AST (e.g. change the return type of a function, add a parameter),
> and then generate the AS code to show these modifications (i.e. with the
> new return type or parameter etc). Is there any functionality already
> implemented in Falcon that would help us achieve this? E.g. listening to
> AST changes, generating AS code from an AST node.
> 
> Any hints would be appreciated!
> 
> Mariana
> 
> 
>> On 27.06.2014 22:44, Gordon Smith wrote:
>> I agree that you should investigate using Falcon. think you'll find that the classes
making up Falcon's AST are reasonably intuitive and have good Javadoc documentation.
>> 
>> If you get Falcon compiling in Eclipse and run a compile in Debug mode, you'll see
an indented tree-like representation of the AST whenever you inspect an AST node instance.
>> 
>> - Gordon
>> 
>>> From: aharui@adobe.com
>>> To: users@flex.apache.org
>>> Subject: Re: ActionScript AST
>>> Date: Fri, 27 Jun 2014 05:44:50 +0000
>>> 
>>> 
>>> 
>>> On 6/26/14 6:21 AM, "Mariana Gheorghe" <mariana.gheorghe@crispico.com>
>>> wrote:
>>> 
>>>> Hello,
>>>> 
>>>> We are looking for a way to obtain and rewrite the AST (abstract syntax
>>>> tree) for an AS file. Currently, we are using the compiler library that
>>>> comes with the SDK, and we've obtained the AST rooted at a ProgramNode.
>>>> We are now unsure on how to proceed to: a) make modifications to the
>>>> tree (e.g. add a variable, add a parameter to a function), and b)
>>>> generate the code from a (modified) tree. Any hints on how to do this
>>>> would be appreciated!
>>> I find the MXMLC code to be very difficult.
>>> 
>>>> Also, we were wondering about the status of Falcon, and if we should in
>>>> fact use Falcon to obtain/rewrite the AST, instead of the compiler from
>>>> the SDK.
>>> Falcon has released a 0.0.1 alpha, we'll ship a 0.0.2 soon.  I find the
>>> code base much easier to work with.
>>> 
>>> -Alex
>>> 
>> 
> 

Mime
View raw message