Boost logo

Boost :

From: hirner_at_[hidden]
Date: 2001-06-02 12:30:05


--- In boost_at_y..., "joel de guzman" <isis-tech_at_m...> wrote:
> From: "Alexander Hirner" :
> > Action<Symbol> looks like this:
> > void Process (const string &strSymbol, char const*
> > end)
> >
> > everything compiled fine.
> > but what would you think is strSymbol by passing
> > 'one + 3 * 3'
> > to the scanner/parser in Compile (/*...*/):
> > one
> > but it is
> > one + 3 * 3
> > , so the whole string?
> > but
> > 3 * 3 + one
> > works contrary?! (strSymbol = "one")
> >
> > what am i doing wrong?
> > thx in advance, ThaFacka
>
> OK now I got it. You are doing fine! Nothing wrong.
> strSymbol points to the first char in the matched string.
> what you should do is check out 'end'. this points to the
> last char of the matched string. So the length of the
> matched string is (end - strSymbol).
>
> Hope this helps,
> Joel de Guzman

I see, after changing my Process func decleration to:
void Process (const char *str, const char *end)
and creating strSymbol like that:
string strSymbol (str, end);
i get the right string, so:

pi*one
yields: doSym with "pi", doMult, doSym with "one"
*but*, if i feed it with:
pi * one + one, i get these tokens:
symbol with "pi ", mult, symbol with "one ", add and symbol with "one"

that means that trailing whitespaces are included in the passed
string (iterator + end)!?
why? i thought spaces are filterd with scanner (rule, space);
it would be very nasty to erase them by hand, is this a bug or what?
i also tried to define the symbol rule as:
symbol = doSym( +(alnum - space) );
which should further delete whitespaces in the parsed string, but
no change...

help appreciated,
ThaFacka

ps: i _really_ like spirit (and its syntax), stop whining because
 of use of some operators, at least this implementation is quite
 perfect, and every change will bring a disadvantage too...
 though im looking forward to further versions!


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk