D parser in tango or phobos

Alexander Panek alexander.panek at brainsware.org
Sat Sep 6 15:48:13 PDT 2008


Fawzi Mohamed wrote:
> On 2008-09-06 19:56:25 +0200, Alexander Panek 
> <alexander.panek at brainsware.org> said:
> 
>> 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
> 
> I think that having a compiler of a language written in itself is 
> certainly nice from the intellectual point of view, but not immediately 
> useful in any sense, and frankly unimportant for most people, even if it 
> gives some real benefits to the language development.

There might not be an immediate impact of glory, but still, my point 
about third party tools still stands. The DMD frontend as it is now is 
not easily usable as such. Thus, it's not only "certainly nice from the 
intellectual point of view", but also from a practical point of view - 
i.e. the view of any developer that might want to interact with the 
semantics of D code that is not compiled with the program.

> Anyway if for you it is so important go and help out
>     http://code.google.com/p/dil/
> :)

I know about dil, and I neither have the qualification nor the time to 
work on a compiler. I'm already involved in too many projects around D. ;)

Kind regards,
Alex



More information about the Digitalmars-d mailing list