Let's stop parser Hell

deadalnix deadalnix at gmail.com
Sat Jul 7 09:49:08 PDT 2012


On 07/07/2012 13:05, Jacob Carlborg wrote:
> On 2012-07-07 03:12, Jonathan M Davis wrote:
>
>> Now, the issue of a "strong, dependable formalization of D's syntax" is
>> another thing entirely. Porting dmd's lexer and parser to Phobos would
>> keep
>> the Phobos implementation in line with dmd much more easily and avoid
>> inconsistencies in the language definition and the like. However, if
>> we write a
>> new lexer and parser specifically for Phobos which _doesn't_ port the
>> lexer or
>> parser from dmd, then that _would_ help drive making the spec match the
>> compiler (or vice versa). So, I agree that could be a definite
>> argument for
>> writing a lexer and parser from scratch rather than porting the one
>> from dmd,
>> but I don't buy the bit about it smothering parser generators at all.
>> I think
>> that the use cases are completely different.
>
> I think the whole point of having a compiler as a library is that the
> compiler should use the library as well. Otherwise the two will get out
> of sync.
>
> Just look at Clang, LLVM, LLDB and Xcode, they took the correct
> approach. Clang and LLVM (and I think LLDB) are available as libraries.
> Then the compiler, debugger (lldb) and IDE uses these libraries as part
> of their implementation. They don't have their own implementation that
> is similar to the libraries, making it "easy" to stay in sync. They
> _use_ the libraries as libraries.
>
> This is what DMD and Phobos should do as well. If it's too complicated
> to port the lexer/parser to D then it would be better, at least as a
> first step, to modify DMD as needed.

I tried that. This is almost impossible, dmd's parser and AST are very 
tightly mixed with dmd's internals.


More information about the Digitalmars-d mailing list