Meta / CTFE library
BCS
ao at pathlink.com
Mon Jun 23 10:32:55 PDT 2008
Reply to Matthias,
> Robert Fraser Wrote:
>
>> Matthias Walter wrote:
>>
>>> as I'm doing much stuff with CTFE / Template Metaprogramming, I
>>> thought about collecting important stuff in a library. I already
>>> found the following interesting:
>>>
>>> 1. parsing routines for compile-time; although every standard lib
>>> has their parsing routines, but sometimes they don't work at compile
>>> time (e.g. using some libc-stuff), or at least are not optimized for
>>> this use. This includes parsing / printing numbers as well, because
>>> at least for dumping some numbers, while debugging a CT-program, one
>>> needs these quiet often. Everyone, who read Dons BLADE library, will
>>> know his enquote() function. This one is very important if you like
>>> to do some recursive mixin programming, like he did there.
>>>
>> I'd love to see a compile-time language parser infrastructure.
>> There's already code (BCS's) that takes an EBNF grammar and generates
>> a runtime code parser, but what about something that can create a
>> (semi) efficient compile-time parser (that is, given an EBNF grammar
>> and a code string, create some compile-time structs of the syntax of
>> the code string, which can then be used to generate other
>> compile-time code).
>>
> This sounds crank - although interesting, but I guess, this won't be
> my main target for the library, cuz I didn't want to code a
> meta-meta-lib :) But it is possible: One could write templates / ctfe
> functions which generate the code for the compile-time parser and you
> must mix it in then... Why does one need a compile-time-parser, if I'm
> allowed to ask?!
>
dparse (my template lib to, at compile time, generated a runtime parser)
has in it a compile time parser. Being able to defined that from BNF rather
than hand codeing it would be handy. Linq like things also would be neet
struct Man
{
char[] name;
int age
Job job;
}
class Job
{
char[] name;
float pay;
}
Man[] men;
// You'll want a parser here ---v
foreach(guy; Query!("SELECT name,job.name WHERE job.pay < age").From(men))
{
writef("%s, %s\n", guy.name, guy.job.name;
}
More information about the Digitalmars-d
mailing list