[antlr-interest] About tree duplication ?

Mathieu Clabaut mathieu.clabaut at gmail.com
Thu Nov 17 01:48:58 PST 2005


 Hello,

  In a tree parser, I can not reference twice the same tree when
constructing a new tree. I have to call astFactory->create().
  Is there a way to only use antlr notation ? Is this a feature or a bug ?

 For example, the following creation rules
  	    ##= #([OR_SERVICE,"||"],
		     #([TWOWAY,"<>"],#s3,
			#([SOURCE,":<"], #f3),
			#([DESTINATION,":>"],#t3)
		     ),
		     #([TWOWAY,"<>"],#s3,
			#([SOURCE,":<"], #t3),
			#([DESTINATION,":>"],#f3)
		     )
gives the following tree :
||
 <>
  s3 :<f3 :> t3 :<t3 :>f3
 <>
  s3 :<f3 :> t3 :<t3 :>f3

Whereas the following creation rules:
	    ##= #([OR_SERVICE,"||"],
		     #([TWOWAY,"<>"],#s3,
			#([TWOCOLON,"::"] , #b3),
			#([SOURCE,":<"], #f3),
			#([DESTINATION,":>"],#t3)
		     ),
		     #([TWOWAY,"<>"],astFactory->create(#s3),
			#([TWOCOLON,"::"] , #b3),
			#([SOURCE,":<"], #t3),
			#([DESTINATION,":>"],#f3)
		     )
Gives the expected results :
||
 <>
  s3 :<f3 :> t3
 <>
  s3 :<t3 :>f3

-mathieu

--
____________http://www.gnu.org/philosophy/no-word-attachments.fr.html
Mathieu CLABAUT                         mailto:mathieu.clabaut at gmail.com
           F2F5 442F F2AC E1D5 9D31  3EFC 842A BC4A 123B 9A65


More information about the antlr-interest mailing list