[antlr-interest] Problem to build AST (kind of reverse AST)
Aurelien Thiriet
thiriet.aurelien at gmail.com
Fri Aug 24 02:41:47 PDT 2012
Hi,
I'm new to ANTLR (I've read the books by the way ;)).
I'd like to parse and build AST for this kind of file :
"
package1 data11;
package1 data12;
package2 data21;
package2 data22;
"
Which means data11 and data12 belongs to package1, data21 and data22
belongs to package2.
Its very easy to build this kind of AST :
(DOCUMENT (DATA ( PACKAGE(package1) data11) DATA ( PACKAGE(package1)
data12) DATA ( PACKAGE(package2) data21) DATA ( PACKAGE(package1) data22)))
But my point is to reverse it like this :
(DOCUMENT ( PACKAGE (package1 DATA(data11) DATA(data12))) ( PACKAGE
(package2 DATA(data21) DATA(data22))) )
How would you write the grammar to perform this AST ?
I've almost succed using many java code into grammar file, but I'd like to
use grammar only if possible.
Thanks a lot
Aurélien
More information about the antlr-interest
mailing list