[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Java 1.5
It might be more complicated since every instance should be from class A_Validate rather from A.
Declaration should be OK since class A_Validate is kind of A.
You might consider doing it dynamically using AOP.
On 29 juin 2010, at 17:49, Duarte Martins wrote:
> Hey there!
>
> I'm working with Java 1.5 Grammar provided by SableCC in its web page. My goal in this step is kind of duplicating each class which appears in a Java File, changing it's name and inheriting from the class itself.
>
> For example
>
> class A { }
> class B { }
>
> would generate the following classes:
>
> class A_Validate extends A { }
> class B_Validate extends B { }
>
> I am creating a ANormalClassDeclaration node, to represent each of this new classes, and setting it's parameters equals to each main class. The problem is that when I make "newClass.setClassBody( mainClass.getClassBody() )" , the main class will no more have this class body. I mean, I don't want to remove main classes, only to add the new ones to the tree. I want to keep the same body in each pair of classes (main and generated one), but I think I must clone somehow the classes' bodies. Is there any easy way to solve my problem?
>
> (for each class, final result in my program is now: class A class A_Validate extends A { } )
>
>
>
>
> Thanks for the attention.
>
> Best Regards,
> Duarte Martins
> _______________________________________________
> SableCC-Discussion mailing list
> SableCC-Discussion@xxxxxxxxxxxxxxxxx
> http://lists.sablecc.org/listinfo/sablecc-discussion