[antlr-interest] How to implement a "require" mechanism?

Michael Matera mike.matera at xilinx.com
Mon Nov 15 10:13:25 PST 2010


Hi Sebastien,

I think your visited file table is a perfectly good solution.  I'm 
pretty sure that my parser will go into an infinite loop when that 
happens.  I should fix that.

Cheers
./m


� wrote:
> Le 12 nov. 2010 � 18:36, Michael Matera a �crit :
> 
>> 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.
> 
> The last code snippet perfectly fits my need. It's a shame that I don't use the "include" keyword when I googled my problem.
> 
> 
> However, another simple question: How to handle properly cyclic inclusions?  I basically use a "visitedFile" table declared as a parser member. When I start the 'sub-parser', I set its visited table to the current one. And after the end of the sub-parse, I set mine to the one available in the sub-parser. 
> 
> Is there another solution? Mine looks like a hack :S
> 
> Cheers, 
> 
> --
>  S�bastien Mosser
>  http://sebastien-mosser.fr
> 
> 
> 
> 
> 

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.




More information about the antlr-interest mailing list