|
Boost Users : |
Subject: Re: [Boost-users] Spirit Newbie (balanced parentheses)
From: Joel de Guzman (joel_at_[hidden])
Date: 2010-04-20 20:25:55
On 4/20/2010 1:14 PM, OvermindDL1 wrote:
> 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
Spirit1 is always "raw" in the sense that it is basically a
transduction parser and returns the iterators to the matching
range in the input.
Regards,
-- Joel de Guzman http://www.boostpro.com http://spirit.sf.net http://www.facebook.com/djowel Meet me at BoostCon http://www.boostcon.com/home http://www.facebook.com/boostcon
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