FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

C++ to D translator: problem with ambiguous constructor.

 
Post new topic   Reply to topic     Forum Index -> The Language Machine
View previous topic :: View next topic  
Author Message
Remy Moueza



Joined: 08 Nov 2005
Posts: 7
Location: france

PostPosted: Tue Nov 08, 2005 3:08 am    Post subject: C++ to D translator: problem with ambiguous constructor. Reply with quote

I have modified the d2d front-end to make it accept an set of input close to C++. I encountered problems with C++ constructors since there is no keyword "this" like in D.
I have tried several ideas but I am afraid I am not skilled enough to realized them: I think I need to record the classname in a variable and to compare it against an identifer when it comes before parenthesis using an "if" condition. I currently don't manage to use the subset of javascript appropriately thus I ask for a little help.
Back to top
View user's profile Send private message
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Sun Nov 13, 2005 4:01 pm    Post subject: Reply with quote

Check if the current function name is the same as the class name, and if so it is a constructor? And the destructor is the only function that starts with a ~.
Back to top
View user's profile Send private message AIM Address
Remy Moueza



Joined: 08 Nov 2005
Posts: 7
Location: france

PostPosted: Thu Nov 17, 2005 7:20 am    Post subject: Reply with quote

Thanks for the help.
I finally manage to recognize a constructor without checking its name. In fact the constructor's prototype begins as a kind of prefix for the pattern that recognizes types. I've added a few rules that recognize a type declaration followed by arguments surrounded by parenthesis. To make it really work I changed the priority and set it a little bit higher.
It seems to work well.
Back to top
View user's profile Send private message
mpah



Joined: 18 Jul 2005
Posts: 29
Location: UK

PostPosted: Mon Nov 21, 2005 3:10 am    Post subject: Reply with quote

Good stuff!. I thought I was being notified by email of posts to this forum, and so I hadn't been monitoring it closely. So I'm very pleased to find that Remy has modified the d2d front end so that it accepts (a subset of?) C++, and would be happy to post the results on the main language machine site at sourceforge. I would of course give Remy full credit for the modifications and the initiative.
_________________
The Language Machine - a toolkit for language and grammar
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> The Language Machine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group