Boost logo

Boost :

Subject: Re: [boost] [Tokenizer]Usage and documentation
From: Michael Caisse (boost_at_[hidden])
Date: 2011-02-09 14:43:36


<please don't top-post>
<http://www.boost.org/community/policy.html#quoting>

>> -----Original Message-----
>> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]]
>> On Behalf Of Michael Caisse
>> Sent: Wednesday, February 09, 2011 1:47 AM
>> To: boost_at_[hidden]
>> Subject: Re: [boost] [Tokenizer]Usage and documentation
>>
>> On 2/8/2011 5:13 AM, Max wrote:
>>> Hello,
>>>
>>>
>>>
>>> I'm using boost::tokenizer to do some simple parsing of data file in a
>>> format specified by the following rules:
>>>
>>>
>>>
>>> - One record of several fields in a single line
>>>
>>> - Adjacent data fields in a record separated by space
> char's(space
>>> or tab), with or without ","
>>>
>>> - String without space(s), with or without quotation marks
>>>
>>> - String with space(s), with quotation marks
>>>
>>>
>>>
>> Hi Max -
>>
>> I would use Spirit Qi for this task. You can find the documentation here:
>>
>> <http://www.boost.org/doc/libs/1_45_0/libs/spirit/doc/html/index.html>
>>
>> michael
>>
>> --
>>
>> ----------------------------------
>> Michael Caisse
>> Object Modeling Designs
>> www.objectmodelingdesigns.com
>>
On 2/9/2011 1:50 AM, Max wrote:
> Thank you Michael for your pointer.
>
> I did knew spirit before but not much. It seemed like a canon or much more
> while what I need is a gun.

This, unfortunately, seems to be a common mis-perception. If we were
talking about using lex, yacc, or bison I would understand. Spirit in a
DSEL and a simple include enables the functionality.

It can't be that the compiled result is 'canon' compared to the other
solutions you are looking at. The resulting code is tight and fast.

> Its power and elegance seems worth a try, even though the learning curve is
> a little bit steep.
>
> (To play with a simple toy program closely resembling those samples
> presented in the tutorial is not difficult,
> but having a full grasp, or nearly, is far from a easy task, especially when
> one comes across compile errors -
> the scenario that I believe everyone here can imagine, which is probably the
> biggest drawback of the
> powerful high order programming)
>
> B/Rgds
> Max

I think this hits the problem. The library can be intimidating at first.
Any DSEL can just look odd initially. I personally find Qi to be close
enough to EBNF that it reads nicely.

The compiler errors are definitely an issue, especially when you are
first beginning. Looks like you have found the tutorial. If you are
interested in a crash course you can find slides here:
<http://www.objectmodelingdesigns.com/boostcon10/> and the BoostCon
video here: <http://blip.tv/file/4143337>.

There is a Spirit ML and a bunch of hang out on the Boost IRC channel.
The community is friendly and always eager to help a new convert.
Regardless of the approach you take, I wish you luck!

designated benevolent spirit evangelist -
michael

-- 
----------------------------------
Michael Caisse
Object Modeling Designs
www.objectmodelingdesigns.com

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