Re: Compile Time D Expression Parser?

2012-03-11 Thread d coder
> Pegged should have no problem parsing all of D, at least theoretically (I > don't know of any severe ambiguities in D). So IOW, it can probably do > what you need it to do. Oh. I realized that I had missed Pegged announcement by Philippe. I will have a look at it. Regards - Puneet

Re: Compile Time D Expression Parser?

2012-03-11 Thread Alex Rønne Petersen
On 11-03-2012 18:54, d coder wrote: Hello Philippe OK, doing a bit of thread necromancy here (3 weeks, still acceptable here?) You are more than welcome. I am still working on the stuff. Puneet, I might have something for you. IIUC, you want to parse expressions that are

Re: Compile Time D Expression Parser?

2012-03-11 Thread d coder
Hello Philippe > OK, doing a bit of thread necromancy here (3 weeks, still acceptable here?) > You are more than welcome. I am still working on the stuff. > Puneet, I might have something for you. IIUC, you want to parse > expressions that are > > - an association of boolean expressions (&&, ||

Re: Compile Time D Expression Parser?

2012-03-11 Thread Philippe Sigaud
dcoder: > I need to parse simple D expressions at compile time. I was wondering if somebody on the list has some example code that could be of help to me. > > I am working on an opensource constraint solver and expressions that I need to parse can be reasonably complex such as "x + y*n < 32 && x >

Re: Compile Time D Expression Parser?

2012-02-28 Thread Dmitry Olshansky
On 28.02.2012 9:19, Hisayuki Mima wrote: (2012/02/28 2:22), Dmitry Olshansky wrote: OK, does it check for Left recursive grammars? No, it doesn't. So currently left recursive grammar causes infinite loop. I know the way to deal with the left recursive grammar well which is using memoization, b

Re: Compile Time D Expression Parser?

2012-02-27 Thread Hisayuki Mima
(2012/02/28 2:22), Dmitry Olshansky wrote: OK, does it check for Left recursive grammars? No, it doesn't. So currently left recursive grammar causes infinite loop. I know the way to deal with the left recursive grammar well which is using memoization, but memoization causes very bad performanc

Re: Compile Time D Expression Parser?

2012-02-27 Thread Hisayuki Mima
(2012/02/28 2:24), d coder wrote: Is it possible to parse any EBNF of arbitrary complexity using your parser generator? Yes, but some rewrites is required. 1) If your EBNF have (indirect) left recursion, you have to eliminate it because the DSL which ctpg uses to generate parser is based on P

Re: Compile Time D Expression Parser?

2012-02-27 Thread d coder
> > > 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 mo

Re: Compile Time D Expression Parser?

2012-02-27 Thread Dmitry Olshansky
On 27.02.2012 20:36, Hisayuki Mima wrote: (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

Re: Compile Time D Expression Parser?

2012-02-27 Thread Hisayuki Mima
(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 parse

Re: Compile Time D Expression Parser?

2012-02-27 Thread Dmitry Olshansky
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

Re: Compile Time D Expression Parser?

2012-02-26 Thread Andrei Alexandrescu
On 2/26/12 5:07 AM, 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 This seems to be great work, but a 30-seconds skim did not reveal to me how exactly it works. Are there some e

Re: Compile Time D Expression Parser?

2012-02-26 Thread Philippe Sigaud
> Almost the complete language is available in CTFE, therefore classes could be used to implement the parse tree representation. However, a limitation that does exist is that classes that were created in CTFE cannot yet be stored in static variables or enums. How will the interface to your library

Re: Compile Time D Expression Parser?

2012-02-26 Thread Hisayuki Mima
(2012/02/26 20:56), d coder 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 Thanks Kenji This is very interesting. Also I think ctpg is being actively developed. I will try

Re: Compile Time D Expression Parser?

2012-02-26 Thread Timon Gehr
On 02/26/2012 02:07 PM, Timon Gehr wrote: On 02/26/2012 01:55 PM, d coder wrote: I know. CTFE is flexible enough and implementing this would be quite simple. However, if ctpg serves your needs well, just use that. Thanks Timon You mean I do not need to use function style when using CTFE? I w

Re: Compile Time D Expression Parser?

2012-02-26 Thread Timon Gehr
On 02/26/2012 01:55 PM, d coder wrote: I know. CTFE is flexible enough and implementing this would be quite simple. However, if ctpg serves your needs well, just use that. Thanks Timon You mean I do not need to use function style when using CTFE? I will try parsing myself as you

Re: Compile Time D Expression Parser?

2012-02-26 Thread d coder
> > > I know. CTFE is flexible enough and implementing this would be quite > simple. However, if ctpg serves your needs well, just use that. > Thanks Timon You mean I do not need to use function style when using CTFE? I will try parsing myself as you suggested. This approach would give me a b

Re: Compile Time D Expression Parser?

2012-02-26 Thread Timon Gehr
On 02/26/2012 01:00 PM, d coder wrote: Operator precedence parsers are simple to implement: http://effbot.org/zone/simple-__top-down-parsing.htm Timon I want to do all this parsing at compile time in D (using mixins). I have ju

Re: Compile Time D Expression Parser?

2012-02-26 Thread d coder
> > > Operator precedence parsers are simple to implement: > > http://effbot.org/zone/simple-**top-down-parsing.htm > Timon I want to do all this parsing at compile time in D (using mixins). I have just started working on this. I am not sure if

Re: Compile Time D Expression Parser?

2012-02-26 Thread d coder
> Hisayuki Mima's ctpg is compile-time parser generater, and the > generated parser works in compile time! > https://github.com/youkei/ctpg > > Kenji Hara > Thanks Kenji This is very interesting. Also I think ctpg is being actively developed. I will try to figure out how to make use of it. Regar

Re: Compile Time D Expression Parser?

2012-02-26 Thread Timon Gehr
On 02/26/2012 03:25 AM, d coder wrote: Greetings I need to parse simple D expressions at compile time. I was wondering if somebody on the list has some example code that could be of help to me. I am working on an opensource constraint solver and expressions that I need to parse can be reasonab

Re: Compile Time D Expression Parser?

2012-02-26 Thread kenji hara
Hisayuki Mima's ctpg is compile-time parser generater, and the generated parser works in compile time! https://github.com/youkei/ctpg Kenji Hara 2012/2/26 d coder : >> How different is what you want to do from CTFE? >> http://dlang.org/function.html > > > I do not want to evaluate the expression

Re: Compile Time D Expression Parser?

2012-02-26 Thread d coder
> > How different is what you want to do from CTFE? > http://dlang.org/function.html I do not want to evaluate the expression in the string at compile time. I want to parse it at compile time and later at run time, I am required to process the parse tree and evaluate it in a different fashion (us

Re: Compile Time D Expression Parser?

2012-02-25 Thread Paulo Pinto
Am 26.02.2012 03:25, schrieb d coder: Greetings I need to parse simple D expressions at compile time. I was wondering if somebody on the list has some example code that could be of help to me. I am working on an opensource constraint solver and expressions that I need to parse can be reasonabl

Compile Time D Expression Parser?

2012-02-25 Thread d coder
Greetings I need to parse simple D expressions at compile time. I was wondering if somebody on the list has some example code that could be of help to me. I am working on an opensource constraint solver and expressions that I need to parse can be reasonably complex such as "x + y*n < 32 && x > 4