D parser in tango or phobos

Alexander Panek alexander.panek at brainsware.org
Sat Sep 6 10:56:25 PDT 2008


Bruce Adams wrote:
> On Wed, 03 Sep 2008 16:33:11 +0100, davidl <davidl at 126.com> wrote:
> 
>> 在 Wed, 03 Sep 2008 21:51:47 +0800,Knud Soerensen 
>> <4tuu4k002 at sneakemail.com> 写道:
>>
>>> davidl wrote:
>>>> 在 Tue, 02 Sep 2008 15:37:38 +0800,Knud Soerensen
>>>> <4tuu4k002 at sneakemail.com> 写道:
>>>>
>>>>> Hi
>>>>>
>>>>> When building tools for manipulating d code, you practical always 
>>>>> need a
>>>>> parser.
>>>>>
>>>>> So, why not include a d parser as part of the runtime library,
>>>>> in that way the it is much easy to write code tools.
>>>>>
>>>>> dmd itself might even use the same parser, which
>>>>> will insure that the parser support the latest version of d and it 
>>>>> will
>>>>> be a nice start for a incremental d compiler.
>>>>>
>>>>>
>>>>
>>>> It's not easy to have a complete working bug free parser.
>>>> dsource.org/projects/dparser
>>>>
>>> I know this is why I made the suggestion.
>>>
>>> The idea is that tool developer should have a stable platform
>>> base his tool upon.
>>>
>>> Such he doesn't have to patch the parser every time a new version of dmd
>>> hits the web.
>>>
>>>
>>
>> What you're asking is simply impossible. It's equivalent to why we 
>> don't have a bug-free
>> frontend.
>>
> Its not impossible just difficult.
> One of the first questions some people ask when
> told about a new language is "what is it written in?"
> If its not written in itself they ask why. If the answer is not 
> compelling they
> may walk away.
> If D ever intends to supplant C as the main systems programming language
> it will have to get over this hurdle.
> A problem is that the language is itself not that stable. You could 
> write a D
> compiler in D1.0 but why bother when it will soon be obsolete. Writing a 
> D compiler in
> D2.0 is a moving target which makes it harder to hit but to quote full 
> metal jacket
> "you've just got to lead them a bit".
> 
> Python has a python parser written in python. The main interpreter is 
> written in C for portability.
> That is a good reason and the same reason applies for D. Why in this day 
> and age C++ isn't considered
> portable by most such project is beyond me.
> I particularly like gcc's approach of bootstraping itself to full 
> functionality. Its a shame the insides
> are so gnarly.

I completely agree. Aside from the sheer prestige of having a D compiler 
written in D, I think the language and especially the compiler & 
toolchain quality itself would benefit from Walter excessively using his 
  own language. After all, he has to walk around the same traps 
everybody else does when using D/DMD. I also think D should provide a 
whole toolchain written in D1, namely frontend, backend, testing, 
documentation and building (we have the last one already with DSSS, 
fortunately). Another benefit of this would include the possibility to 
actually use the D frontend for third party tools, since it's written in 
D. Of course, we have an open source frontend already, but it's written 
in C and poorly documented - no offense intended -, thus actually not 
really usable unless you spend quite some time digging through the 
source and writing D wrappers for it.

Frankly said, I would have thought of D1 written in D1 as the next step 
in  language development, instead of a "forked" experimental D2 
compiler. But that's just me.

Kind regards,
Alex



More information about the Digitalmars-d mailing list