|
Boost : |
From: joel de guzman (joel_at_[hidden])
Date: 2001-05-22 06:10:20
----- Original Message -----
From: "Vesa Karvonen" :
> // Generates the parser from the grammar expression
> Parser parser = re
> | '(' + re + ')'
> | '(' + re + ',' + im + ')'
> ;
[snip]
> > I would like to see working implementation that can handle syntax that
> you've
> > given a few lines above.
>
> Me, too!
>
[snip]
Consider it done. I'll add that capability or a variation
into the framework. The open-ended nature of
spirit makes that trivial to do:
Something like:
FloatVar re, im;
Rule<> r = re | '(' >> re >> ')' | '(' >> re >> ',' >> im >> ')';
or perhaps (better yet?):
Rule<> r = re | '(' >> re !(',' >> im) >> ')';
where !a means a is optional.
now you can:
if (r.Parse(iter))
{
float f1 = re;
float f2 = im;
}
** Rule is paramaterized by the character type, defaults to char.
** one (but not both) literal is OK in a binary expression. I used
clpar, minus etc. just to make things clear.
I quote:
For binary operators, one of the operands (but not both [N7])
may be a char, wchar_t, char const* or wchar_t const*. Examples:
a | 'x';
a - "Hello World";
Thanks for your comments....
Later,
Joel de Guzman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk