Boost logo

Boost Users :

Subject: Re: [Boost-users] Spirit Newbie (balanced parentheses)
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2010-04-20 01:14:14


On Mon, Apr 19, 2010 at 8:22 AM, Lars Rohwedder <L.Rohwedder_at_[hidden]> wrote:
> EricB schrieb:
>> is there any way to manage this with 1.6.4
>
> If only need to checked whether the string contains the same number of
> '(' and ')' what about
>
> int counter=0;
>
> rule<> r = ch_p('(')[increment_a(counter)] >> ~ch_p(')') >>
> ch_p(')')[decrement_a(counter)]
>
> if(counter!=0)
> {
>        // unbalanced!
> }

Unnecessary, slower, and error-prone. There is still a 'raw'
equivalent in Spirit1 as I recall, but I do not know the syntax, you
might be better off to ask on the Spirit mailing list (just be sure to
mention that you are using a broken compiler, else you will be
inundated with posts saying to stop using the ancient and slow Spirit1
:) ).


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net