[stringtemplate-interest] howto set separator in parallel list iteration
Terence Parr
parrt at cs.usfca.edu
Mon Jul 7 12:52:55 PDT 2008
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 stringtemplate-interest
mailing list