View previous topic :: View next topic |
Author |
Message |
Remy Moueza
Joined: 08 Nov 2005 Posts: 7 Location: france
|
Posted: Tue Nov 08, 2005 3:08 am Post subject: C++ to D translator: problem with ambiguous constructor. |
|
|
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 |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Sun Nov 13, 2005 4:01 pm Post subject: |
|
|
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 |
|
|
Remy Moueza
Joined: 08 Nov 2005 Posts: 7 Location: france
|
Posted: Thu Nov 17, 2005 7:20 am Post subject: |
|
|
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 |
|
|
mpah
Joined: 18 Jul 2005 Posts: 29 Location: UK
|
Posted: Mon Nov 21, 2005 3:10 am Post subject: |
|
|
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 |
|
|
|