www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - lexer/parser library for D

reply "Jonathan" <jdgall84 gmail.com> writes:
Are there any good lexer and parser libraries (like flex/bison) 
for D?  If not, how much work would be involved in using flex and 
bison and wrapping it to D?  How straightforward is it to pass a 
struct from C to D (the documentation 
http://dlang.org/struct.html just says that D structs go directly 
to C -- the other way holds too if the C side is written in a 
certain way, but gives no examples of what is needed on both 
sides)?
Dec 29 2013
next sibling parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Sunday, 29 December 2013 at 19:25:46 UTC, Jonathan wrote:
 Are there any good lexer and parser libraries (like flex/bison) 
 for D?  If not, how much work would be involved in using flex 
 and bison and wrapping it to D?  How straightforward is it to 
 pass a struct from C to D (the documentation 
 http://dlang.org/struct.html just says that D structs go 
 directly to C -- the other way holds too if the C side is 
 written in a certain way, but gives no examples of what is 
 needed on both sides)?
A POD struct in D is interchangeable with C structs, both ways. You just have to make the declaration of the struct in both languages. Lexers/Parsers: https://github.com/PhilippeSigaud/Pegged and https://github.com/Hackerpilot/Dscanner
Dec 29 2013
prev sibling next sibling parent reply "FreeSlave" <freeslave93 gmail.com> writes:
On Sunday, 29 December 2013 at 19:25:46 UTC, Jonathan wrote:
 Are there any good lexer and parser libraries (like flex/bison) 
 for D?  If not, how much work would be involved in using flex 
 and bison and wrapping it to D?  How straightforward is it to 
 pass a struct from C to D (the documentation 
 http://dlang.org/struct.html just says that D structs go 
 directly to C -- the other way holds too if the C side is 
 written in a certain way, but gives no examples of what is 
 needed on both sides)?
See http://dlang.org/htomodule.html Also you may read http://www.gamedev.net/blog/1140/entry-2254003-binding-d-to-c/
Dec 29 2013
parent Mike Parker <aldacron gmail.com> writes:
On 12/30/2013 5:36 AM, FreeSlave wrote:

 Also you may read
 http://www.gamedev.net/blog/1140/entry-2254003-binding-d-to-c/
Better to go to [1], where I combined that series of posts into a single article and updated a few things, too. [1] http://www.gamedev.net/page/resources/_/technical/game-programming/binding-d-to-c-r3122
Dec 29 2013
prev sibling next sibling parent "FreeSlave" <freeslave93 gmail.com> writes:
There is also http://www.semitwist.com/goldie/ but I did not use 
it.
Dec 29 2013
prev sibling parent "Casper =?UTF-8?B?RsOmcmdlbWFuZCI=?= <shorttail hotmail.com> writes:
If you like Parser Expression Grammar there's Pegged: 
https://github.com/PhilippeSigaud/Pegged
Dec 29 2013