A gentle critque..

Ben Cooley Ben_member at pathlink.com
Mon May 15 21:34:14 PDT 2006


In article <e4bjhk$tr8$1 at digitaldaemon.com>, Walter Bright says...
>
>Ben Cooley wrote:
>> In article <e4an5r$2reb$1 at digitaldaemon.com>, Walter Bright says...
>>> Ben Cooley wrote:
>>>> I would suggest that a standard C and C plus plus compiler and parser be
>>>> integrated into D, and that it not "convert" files, but just parse them directly
>>>> without modification.  If the equivalent C or C plus plus construct is not
>>>> available in D, D should provide a way of accessing that construct as a foreign
>>>> object.  
>>> That is a good idea, and I've toyed with it. The problem with it is that 
>>> it pulls the rug out from other implementations of D. People won't want 
>>> to use them because they'll expect the dmd 'extension' of being able to 
>>> parse .h files directly.
>> 
>> Hmmm... well I can certainly sympathize because I don't want to use DMD without
>> that capability either. ;-)  Truth is I can't. 
>> 
>> But my advice to those other implementations would be to just get cracking.  The
>> GCC implementation wouldn't have too much trouble  For the others there are a
>> variety of free versions of full CPP compilers out there.
>
>g++ is the only free full C++ compiler out there.
>
>> An alternative would be to compile C and CPP headers to a C/CPP pcode format
>> which could be accessed by the D cpp interface.  Part of the D compiler would
>> comprehend certain foreign cpp constructs as part of the basic D compiler, while
>> a simpler external parsing tool would actually generate a cpp pcode file.
>
>There is no such thing as a simple C++ parsing tool. That's one of the 
>huge problems C++ has - you need a full compiler just to parse it. It 
>took 10 years for the various vendors just to get the preprocessor to be 
>standard compliant.

Elsa seems to do a pretty good job for us.. and we've got some pretty
complicated template usage.  But you really need little more than the sort of
parser used to create documentation, or to view the class hierarchy.  You don't
need to parse any actual code, just definitions.  Swig is a good example.

As for the preprocessor, all C compilers come with their own already, so that's
really not a major problem.  A D pass to extract macros first, then a
preprocessing pass by the real Cpp compiler, then a declaration parsing pass.







More information about the Digitalmars-d mailing list