D Parser in D
Timon Gehr
timon.gehr at gmx.ch
Sat Nov 26 15:59:17 PST 2011
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.
More information about the Digitalmars-d
mailing list