Boost logo

Boost :

Subject: Re: [boost] [Spirit] Retrieve informations out of tokens
From: ... ... (bersac_1_at_[hidden])
Date: 2013-06-26 19:47:58

> From: robertstewart_at_[hidden]> If you want Boost.Spirit support, I suggest the Spirit mailing list.That's a good idea, and I already did it, and no one is answering.
I investigated a lot since then and maybe you could help me :
I use the function tokenize with a functor I created myself. The code of the functor :struct counter{ template <typename Token> bool operator()(Token const& t){//what is the type of the variable t ??? return true; }};
And the code of my tokenize function call :counter* foncteur = new counter();char const* first = str.c_str();//char const* is the type Iteratorchar const* last = &first[str.size()];lex::tokenize(first, last, word_count_functor, *foncteur);
Now I am trying to figure out how to use the variable t, the token, relay to my functor.According to the source code, the type of the token is that :boost::spirit::lex::lexertl::token< Iterator, AttributeTypes, HasState, Idtype >
The token has one member function which is value(). This member function return a value of type :typedef detail::token_value_type < iterpair_type, AttributeTypes >::type token_value_type
iterpair_type being an alias of :typedef iterator_range<Iterator> iterpair_type
So, to sum up the informations, the type of token.value() is : detail::token_value_type < iterator_range<Iterator>, AttributeTypes >::type
Here is the definition of the template parameter of the token type Iterator The type of the iterator used to access the underlying character stream. AttributeTypes A mpl sequence containing the types of all required different token values to be supported by this token type. HasState A mpl::bool_ indicating, whether this token type should support lexer states. Idtype The type to use for the token id (defaults to std::size_t).
To define the type of token.value, I need to know what's the value of the template parameter : Iterator and attribute type.I already figured out that char const* is, in this case, the Iterator attribute, now I need to know what's the type of Attribute type.
Could you help me understand what's the type of AttributeTypes ? Then what are the member functions and attributes of this class so that I can use it ? What does namespace detail refer to ? What is a mpl sequence ?

Any help is welcomenCordialy,Guillaume Bersac237bis rue de Pessac33000 Bordeaux06.

Boost list run by bdawes at, gregod at, cpdaniel at, john at