digitalmars.D - Parser
- Michiel (5/5) Feb 06 2007 I want to write a parser in D. Is there a D library like lex/yacc/bison ...
- BCS (15/22) Feb 06 2007 you have several choices
- Justin C Calvarese (23/27) Feb 06 2007 One of the projects listed on this page
- Sam Phillips (4/11) Feb 06 2007 There is also The Ragel State Machine Compiler which has a D interface:
I want to write a parser in D. Is there a D library like lex/yacc/bison with which I can do syntax-directed translation? The digitalmars site said that the D parser has also been written in D. How did they build the parser? Thanks!
Feb 06 2007
Michiel wrote:I want to write a parser in D. Is there a D library like lex/yacc/bison with which I can do syntax-directed translation?you have several choices 1) use lax/yacc and call from D Not recommended 2) enki it's fairly mature and works well but requiters an extra build step http://www.dsource.org/projects/ddl/browser/trunk/enki 3) dparser New'n'cool, not vary mature and not well tested but it doesn't requirer anything but DMD to build. with the new import expression it will even support external BNF files. http://www.dsource.org/projects/scrapple/browser/trunk/dparser/dparse.d (Disclosure: It's also my project)The digitalmars site said that the D parser has also been written in D. How did they build the parser?The D parser for DMD is in C++. Classic bootstrapping problem. Then again Walter wrote oplink in ASM!Thanks!
Feb 06 2007
Michiel wrote:I want to write a parser in D. Is there a D library like lex/yacc/bison with which I can do syntax-directed translation?One of the projects listed on this page (http://www.prowiki.org/wiki4d/wiki.cgi?GrammarParsers) may be useful to you. Many of these projects are probably inactive, but Enki (http://www.dsource.org/projects/ddl/wiki/Enki) is one of the most recent options. As BCS mentioned, his Dparser (http://www.dsource.org/projects/scrapple/browser/trunk/dparser/dparse.d) is a recent effort in parsing. I've been interested in "The Language Machine" (http://languagemachine.sourceforge.net/), but I've never tried it myself and it might need some work to get it to compile with the latest version of D.The digitalmars site said that the D parser has also been written in D. How did they build the parser?I'm not sure which project you're referring to but they probably used a combination of automation and hand-editing to convert the C++ source into D (the front end of DMD has been open-sourced). Perhaps you're thinking of an effort that's in the Bindings project (http://www.dsource.org/projects/bindings)? Files: demangle.d, dfilter.d, dlexer.d, dparse.d, dsymextract.d, dtypes.d -- jcc7
Feb 06 2007
Michiel Wrote:I want to write a parser in D. Is there a D library like lex/yacc/bison with which I can do syntax-directed translation? The digitalmars site said that the D parser has also been written in D. How did they build the parser? Thanks!There is also The Ragel State Machine Compiler which has a D interface: http://www.cs.queensu.ca/~thurston/ragel/ More of a Lex++ than Yacc – but may be of interest to you
Feb 06 2007