www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D Parser in D

reply "NMS" <nathanmswan gmail.com> writes:
Is there a D parser written in D? - C strings kill me.

Thanks, NMS
Nov 25 2011
next sibling parent "Bernard Helyer" <b.helyer gmail.com> writes:
On Sat, 26 Nov 2011 07:58:19 +1300, NMS <nathanmswan gmail.com> wrote:

 Is there a D parser written in D? - C strings kill me.

 Thanks, NMS
SDC[1] has one, but it's being lazy loaded in -- that is, it's not complete. [1]:http://github.com/bhelyer/SDC
Nov 25 2011
prev sibling next sibling parent Trass3r <un known.com> writes:
 Is there a D parser written in D? - C strings kill me.
https://github.com/azizk/dil Most complete one I think.
Nov 26 2011
prev sibling parent reply "Martin Nowak" <dawg dawgfoto.de> writes:
On Fri, 25 Nov 2011 19:58:19 +0100, NMS <nathanmswan gmail.com> wrote:

 Is there a D parser written in D? - C strings kill me.

 Thanks, NMS
It's annoying to write one as long as the buffered input range with infinite lookahead problem is not solved by the std library.
Nov 26 2011
next sibling parent reply Trass3r <un known.com> writes:
 Is there a D parser written in D? - C strings kill me.
It's annoying to write one as long as the buffered input range with infinite lookahead problem is not solved by the std library.
What do you need infinite lookahead for?
Nov 26 2011
next sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
On 11/27/2011 12:05 AM, Trass3r wrote:
 Is there a D parser written in D? - C strings kill me.
It's annoying to write one as long as the buffered input range with infinite lookahead problem is not solved by the std library.
What do you need infinite lookahead for?
There are a few places in the grammar where it is useful, for example: void foo(A,B,C,...)(A,B,C,...){} vs void foo(A,B,C,...){} Without looking behind the first set of parentheses, it is harder to figure out whether or not foo is a function template. Another example: void main(){ a[][][][][]...[][][] b; } vs void main(){ a[][][][][]...[][][] = b[]; } Both of them could in theory be parsed without infinite lookahead, but that is more complicated than the solution using infinite lookahead. Also, if eg. you want to build a distinct AST representation for template parameters and function parameters, infinite lookahead is the only sensible option.
Nov 26 2011
prev sibling parent "Martin Nowak" <dawg dawgfoto.de> writes:
On Sun, 27 Nov 2011 00:05:31 +0100, Trass3r <un known.com> wrote:

 Is there a D parser written in D? - C strings kill me.
It's annoying to write one as long as the buffered input range with infinite lookahead problem is not solved by the std library.
What do you need infinite lookahead for?
No need to discuss this in detail, but IMHO the main benefit of infinite lookahead is that it allows to build a generic parser for forward ranges. If you have only input ranges you need to handle buffering within the parser. Of course it's opportune to simply read in a complete source file as string given their typically limited size. It also has the benefit of avoiding additional string copying.
Nov 26 2011
prev sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
On 11/26/2011 09:09 PM, Martin Nowak wrote:
 On Fri, 25 Nov 2011 19:58:19 +0100, NMS <nathanmswan gmail.com> wrote:

 Is there a D parser written in D? - C strings kill me.

 Thanks, NMS
It's annoying to write one as long as the buffered input range with infinite lookahead problem is not solved by the std library.
Have you filed an enhancement request?
Nov 26 2011