Defining 'equals' and 'hashcode' on nodes

View: New views
3 Messages — Rating Filter:   Alert me  

Defining 'equals' and 'hashcode' on nodes

by Andrew Sweet :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi.

I'm using Sablecc for my dissertation work and I've found that I need to
be able to define the equals and hashCode operations on the Node classes
which forms the abstract syntax tree. Since child nodes are strongly
typed in Sablecc, this operation cannot be defined at a higher level.
Writing the algorithm itself is easy enough, but I'm having trouble
finding where in the Sablecc 3.2 source-code I need to be adding the
definitions. I need to know the class where node .java files are
generated, so I can add in the equals and hashcode functions based upon
the strongly typed children of that node. Could someone point me in the
right direction, please?

Thanks
Andrew

_______________________________________________
SableCC-Discussion mailing list
SableCC-Discussion@...
http://lists.sablecc.org/listinfo/sablecc-discussion

RE: Defining 'equals' and 'hashcode' on nodes

by Dehua Zhang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I would suggest NO modification of generated code directly.

You may try AspectJ to inject equals and hashcode to those classes.

Regards,
--
Dehua Zhang
Sable Research Group, McGill University
Montréal, Québec, Canada
http://www.cs.mcgill.ca/~dzhang25





-----Original Message-----
From: sablecc-discussion-bounces+dehua.zhang=mail.mcgill.ca@... on behalf of Andrew Sweet
Sent: Fri 2/1/2008 20:38
To: Discussion mailing list for the SableCC project.
Subject: Defining 'equals' and 'hashcode' on nodes
 
Hi.

I'm using Sablecc for my dissertation work and I've found that I need to
be able to define the equals and hashCode operations on the Node classes
which forms the abstract syntax tree. Since child nodes are strongly
typed in Sablecc, this operation cannot be defined at a higher level.
Writing the algorithm itself is easy enough, but I'm having trouble
finding where in the Sablecc 3.2 source-code I need to be adding the
definitions. I need to know the class where node .java files are
generated, so I can add in the equals and hashcode functions based upon
the strongly typed children of that node. Could someone point me in the
right direction, please?

Thanks
Andrew

_______________________________________________
SableCC-Discussion mailing list
SableCC-Discussion@...
http://lists.sablecc.org/listinfo/sablecc-discussion


_______________________________________________
SableCC-Discussion mailing list
SableCC-Discussion@...
http://lists.sablecc.org/listinfo/sablecc-discussion

Re: Defining 'equals' and 'hashcode' on nodes

by Etienne M. Gagnon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Andrew,

I agree with Dehua. Using aspects would be the cleanest solution.

Now, if you really want to go and modify SableCC itself, you will find
all the code generation patterns in src/org/sablecc/sablecc/*.txt files.
You most likely won't need to modify any source .java file.

Have fun!

Etienne

Dehua Zhang a écrit :

> I would suggest NO modification of generated code directly.
>
> You may try AspectJ to inject equals and hashcode to those classes.
>
> Regards,
> --
> Dehua Zhang
> Sable Research Group, McGill University
> Montréal, Québec, Canada
> http://www.cs.mcgill.ca/~dzhang25
>
>
>
>
>
> -----Original Message-----
> From: sablecc-discussion-bounces+dehua.zhang=mail.mcgill.ca@... on behalf of Andrew Sweet
> Sent: Fri 2/1/2008 20:38
> To: Discussion mailing list for the SableCC project.
> Subject: Defining 'equals' and 'hashcode' on nodes
>  
> Hi.
>
> I'm using Sablecc for my dissertation work and I've found that I need to
> be able to define the equals and hashCode operations on the Node classes
> which forms the abstract syntax tree. Since child nodes are strongly
> typed in Sablecc, this operation cannot be defined at a higher level.
> Writing the algorithm itself is easy enough, but I'm having trouble
> finding where in the Sablecc 3.2 source-code I need to be adding the
> definitions. I need to know the class where node .java files are
> generated, so I can add in the equals and hashcode functions based upon
> the strongly typed children of that node. Could someone point me in the
> right direction, please?
>
> Thanks
> Andrew
>
> _______________________________________________
> SableCC-Discussion mailing list
> SableCC-Discussion@...
> http://lists.sablecc.org/listinfo/sablecc-discussion
>
>
> _______________________________________________
> SableCC-Discussion mailing list
> SableCC-Discussion@...
> http://lists.sablecc.org/listinfo/sablecc-discussion
>
>  
--
Etienne M. Gagnon, Ph.D.
SableCC:                                            http://sablecc.org
SableVM:                                            http://sablevm.org




_______________________________________________
SableCC-Discussion mailing list
SableCC-Discussion@...
http://lists.sablecc.org/listinfo/sablecc-discussion

signature.asc (265 bytes) Download Attachment
LightInTheBox - Buy quality products at wholesale price