Boost logo

Boost :

Subject: [boost] [Spirit] Retrieve informations out of tokens
From: ... ... (bersac_1_at_[hidden])
Date: 2013-06-26 09:22:36


Hi,

I want to create a c++ syntax analysor (for creating auto-completion tools), and to help me, I want to use the boost.spirit library. In order to learn the basics of spirit, I executed this exercise. It is now working but I want to display the tokens' characters instead of counting tokens. The problem is I don't know the properties of the argument passed to my functor (the variable "t" in the code below). What is the type of this variable and what are the public method/attributes we can use on ?
This is the code of my functor :
struct counter{ counter() : j(0) {j = new int();}
        counter(const counter &model) : j(model.j) {}
        ~counter() {delete int;}
        template <typename Token> bool operator()(Token const& t){//I want to know the type of this variable t ++i; ++(*j); std::ostringstream oss; oss << "global : " << i << " membre : " << *j;//typeid(t).name(); printf("%s\n", oss.str().c_str()); return true; }
        int* j;};
The variable t will be relay to my functor by the following tokenize function :
counter* foncteur = new counter();lex::tokenize(first, last, word_count_functor, *foncteur);
I still have other questions :
I read a consistent part of the documentation but I have not been able to define the type of regex used by boost.spirit. Which type is it ?
What is the more appropriate function to use to analyse c++ synthax : tokenize or tokenize _and_parse ? You seems to describe tokenize_and_parse as a more powerful tool, but is it possible to define all the syntax of c++ using a parser ?
Could I find an example of c++ syntax analysor using boost.spirit ?
Any help would be appreciate,Cordialy,Guillaume Bersac237bis rue de Pessac33000 Bordeaux06.65.30.89.43


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