Hi Sebastien,

There's an ANTLR wiki entry that shows how to do this:

> http://www.antlr.org/wiki/pages/viewpage.action?pageId=557057

It works by inserting tokens into your token stream which has the effect 
of generating an AST at the point of the require.

Cheers
./m

� wrote:
> Hi, 
> 
> This is my first post on this mailing list. so let's start by a little 
> presentation. I'm a French young researcher (aka 'postdoc'), working on the 
> definition of mechanisms to support separation of concerns approaches.
> 
> I'm currently using ANTLR & StringTemplate to implement a translator 
> associated to a prototype. By the way, these two tools are impressive (I 
> previously only work with ANTLR for another project). 
> 
> However, I'm encountering a (big) issue. The translator I'm designing must 
> support the definition of a "require" mechanism. A source file "x" must be 
> able to require the content of another source file "y".
> 
> The translator first start by building an AST, and then a tree grammar visit 
> the AST and use the appropriate templates. My first idea is to implement 
> something like the following snippet in the grammar:
> 
> require: 'require' fileName=STRING ';'        { 
>                                         build the AST associated to $fileName;
>                                         insert its content inside the current 
> one;
>                                       }
> 
> however, I have no idea on how to implement the second actions, that is, 
> including the content of another AST into this one. I'm not even sure this is 
> the right solution to my problem :'(. Is preprocessing a better solution?
> 
> Any ideas?
> 
> Cheers, 
> 
> --
>  S�bastien
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 

This email and any attachments are intended for the sole use of the named 
recipient(s) and contain(s) confidential information that may be proprietary, 
privileged or copyrighted under applicable law. If you are not the intended 
recipient, do not read, copy, or forward this email message or any attachments. 
Delete this email message and any attachments immediately.



List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to