Let's stop parser Hell

Jonathan M Davis jmdavisProg at gmx.com
Thu Jul 5 17:27:33 PDT 2012


On Friday, July 06, 2012 00:24:11 deadalnix wrote:
> Le 05/07/2012 18:28, Jonathan M Davis a écrit :
> > On Thursday, July 05, 2012 18:04:11 Roman D. Boiko wrote:
> >> On Thursday, 5 July 2012 at 15:40:53 UTC, Jacob Carlborg wrote:
> >>> On 2012-07-05 15:08, Roman D. Boiko wrote:
> >>>> Anyway I propose to enumerate major use cases first.
> >>> 
> >>> Haven't we already done that a couple of times.
> >> 
> >> Well, we did something like that for DCT... but I doubt that it
> >> would fit general needs.
> >> 
> >> If we had, why haven't they been analyzed, classified, discussed,
> >> etc.? Or have they?
> > 
> > It's been discussed before, but there are some obvious use cases such as
> > syntax highlighting, code formatting, and manipulation of D source files
> > (e.g. to strip out the unit tests).
> > 
> > We need to have a lexer in Phobos which parsers D code and generates a
> > range of tokens, and we need to have a parser in Phobos which operates on
> > a range of tokens. As discussed previously, there is desire to have the
> > lexer and parser ported from dmd's frontend to D for Phobos so that what
> > we get is easily maintainable alongside dmd's frontend and produces the
> > same results (and is fast).
> 
> You never looked at dmd frontend soure code don't you ? It is a horror
> museum, and if we want to have something in D, I certainly wouldn't copy
> that.

I have definitely looked at dmd's frontend's source code. The idea behind 
copying the lexer and parser from there is then that they'd match the 
compiler, which would make it much easier to keep them in sync with changes to 
the compiler. Whether that's what someone would have written had they done it 
purely in D initially is pretty much irrelevant.

- Jonathan M Davis


More information about the Digitalmars-d mailing list