Compile Time D Expression Parser?

Hisayuki Mima youxkei at gmail.com
Mon Feb 27 08:36:08 PST 2012


(2012/02/27 19:42), Dmitry Olshansky wrote:
> On 26.02.2012 15:07, kenji hara wrote:
>> Hisayuki Mima's ctpg is compile-time parser generater, and the
>> generated parser works in compile time!
>> https://github.com/youkei/ctpg
>>
>> Kenji Hara
>>
>
> Nice! I'm curious as to which parsing method the generated parser does
> employ (it isn't immediately obvious ;) ).
> Examples look good, but I don't seem to get how recursive sample
> fails match(?) e.g. "aaaaa" given the grammar:
> recursive -> A $
> A -> a A a | a
>
> I mean it's any odd-length sequence of a.
>

Parsing method which the generated parser employs is Recursive Descent 
Parsing.
And the behavior of the parsers recursive and A is a little bit complicated.
The parser recursive matches the sequence of 'a' whose length is 2^n-1 
such as 1, 3, 7 and 15.
Anyway, I'm going to write more documentation of ctpg within a few days.
I hope it'll help you.

Hisayuki Mima


More information about the Digitalmars-d mailing list