[antlr-interest] [stringtemplate-interest] howto set separator in parallel list iteration

Jens Boeykens jens.boeykens at gmail.com
Mon Jul 7 14:28:28 PDT 2008


Hm I've writed a lot of unit tests and no exceptions occured even when 
no rewrites were used.
Can you give me an example input where you get exceptions?

What I am working on now is to build a generator which generates an 
antlrv3 grammar from a tree. This gives a grammar which is equivalent to 
the original grammar used to build that tree but can be tweaked by doing 
stuff with the tree like sorting rules.
I'll post it to the community when it is sort of finished.

Greetz

Terence Parr schreef:
>
> On Jul 7, 2008, at 1:50 AM, Jens Boeykens wrote:
>
>> I think I solved the bug. In ANTLRv3.g I changed the rule "altList" 
>> as follows:
>>
>> altList
>> @init {
>>     // must create root manually as it's used by invoked rules in 
>> real antlr tool.
>>     // leave here to demonstrate use of {...} in rewrite rule
>>     // it's really BLOCK[firstToken,"BLOCK"]; set line/col to 
>> previous ( or : token.
>>     CommonTree blkRoot = 
>> (CommonTree)adaptor.create(BLOCK,input.LT(-1),"BLOCK");
>> }
>>     :   a1=alternative rewrite ( '|' a2=alternative rewrite )*
>>         -> ^( {blkRoot} (alternative rewrite)+ EOB["EOB"] )
>>     ;
>>
>> I deleted the question mark after rewrite in the tree rewrite rule.
>
> Actually, that rewrite ? is necessary... if there is no rewrite, you 
> will get an exception.
> Ter
>



More information about the antlr-interest mailing list