Compile-Time parser

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Compile-Time parser

Felipe Magno de Almeida
I've readed in this mail list about an idea of a compile-time parser.
Turned out the idea wasnt exactly what I was starting to find a good
I'm not so sure about where would someone need a compile-time parser,
but anyway, it seems to be possible, and interesting,
I think it could use the preprocessor(boost.preprocessor), mpl and
BOOST_TYPEOF for that.

I think it could be possible to write almost exactly like an spirit
grammar and have it work on compile-time.

I was thinking something like this:

template <typename T>
T helper(T)

// define some operators that uses "expression templates"(but, no need
to have state in the classes at all...

#define PARSER(x) BOOST_TYPEOF(helper(x))::type

typedef PARSER(( numbers >> ch_p<'a'> )) parser;

And have this parser matches(or not) an C-string using a macro to
convert the C-string in an mpl::vector_c that could be traversed in
this way it could be possible to create compile-time bools that could
be used in SFINAE and etc like this:

MATCHPARSER(parser, "asd")

Opinions? Is it really possible or am I missing something? Is it useful?
Worth the trouble?

Thanks in advance,

   Felipe Magno de Almeida
Developer from synergy and Computer Science student from State
University of Campinas(UNICAMP).
"There is no dark side of the moon really. Matter of fact it's all dark."

SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement *
Spirit-general mailing list
[hidden email]