[antlr-interest] V3 & tree Parsing Q:

Hill, Robert rhill03 at eds.com
Fri Sep 29 06:39:20 PDT 2006


I have a parser rule which creates nodes followed by data, - each child
is a TABLEMAPPING_ELEMENT

tableMapping
		: LBrace mappingElements+ RBrace ->
^(TABLEMAPPING_ELEMENT mappingElements)+
	;
Note the + at the end of the re-write rule.

As you'd expect the resulting tree has lots of TABLEMAPPING_ELEMENT
followed by its data.
But in the tree parser I have to put the + closure on the rule that
calls the mapping elements rather than just  thus..
Ie : 

declaration
	:	
	  ^(DATABASE_DECL Identifier)	{ System.out.println("Found
Database Decl"); }
	| ^(USERCLASS_DECL userClass)  	{ System.out.println("User class
Decl"); }
	| ^(TABLEMAPPING_DECL Identifier tableMapping+) 	{
System.out.println("Found Table Mapping"); }
	;

tableMapping
	: ^(TABLEMAPPING_ELEMENT mappingElements)
	;


Note that the + closure is now in the declaration rule. Im confused, Why
the difference in the placement of the + closure? Or rather why does the
Parser allow you to put the + outside the brackets on the rewrite rule
but not in the rule in the TreeWalker - it's a syntax error. ?

Cheers!




--
ROB HILL
DWP ACW
EDS Hallamshire Business Park
F1E/045
Sheffield	
T:	+44 (0) 114 291 1928
M:	+44 (0) 790 318 5516
E:	rhill03 at eds.com


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060929/1ef3dc18/attachment.html 


More information about the antlr-interest mailing list