Bonjour,

Je tente d'utiliser BOOST.Spirit, malheureusement, les types vitaux (style : space_p...) ne serait pas définis :

Voilà mes deux fichiers :

parser.h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <string>
#include <boost/spirit.hpp>
// Classe-interface des parseurs
class Parser : public boost::spirit::grammar<Parser> {
    public:
 
    virtual ~Parser(void);
 
    virtual Parser* Clone() = 0;
 
    virtual std::string parse(const std::string& code) = 0;
 
    virtual void reset() = 0;
 
    bool existe;
 
    private:
 
    std::string code_dormant;
 
};
Et lib/cpp.h

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#include <string>
#include <boost/spirit.hpp>
#include "..\parser.h"
#include "..\afficheur.h"
 
class CPP : public Parser{
    public:
 
    CPP();
 
    std::string parse(const std::string& code);
 
    void reset();
 
    Parser* Clone();
 
    ~CPP(void);
 
    bool existe;
 
    // Le parseur
    template <typename ScannerT>
    struct definition
    {
        definition(CPP const& self)
        {
            declarations actions = self.evenements;
 
            program
                =  *space_p >>
                    *(   preprocessor    [actions.preprocessor]
                    |   comment         [actions.comment]
                    |   keyword         [actions.keyword]
                    |   identifier      [actions.identifier]
                    |   special         [actions.special]
                    |   string          [actions.string]
                    |   literal         [actions.literal]
                    |   number          [actions.number]
                    |   anychar_p       [actions.unexpected]
                    |   type            [actions.type]
                    |   condition       [actions.condition]
                    |   boucle          [actions.boucle]
                    |   type            [actions.type]
                    |   objet           [actions.objet]
                    )
                ;
 
            preprocessor
                =   '#' >> *space_p >> identifier
                ;
 
            comment
                =   +((comment_p("//") | comment_p("/*", "*/"))
                    >> *space_p)
                ;
 
            keyword
                =   keywords >> (eps_p - (alnum_p | '_')) >> *space_p
                ;   // make sure we recognize whole words only
 
            keywords
                =   "and_eq", "and", "asm", "auto", "bitand", "bitor",
                    "catch", "compl", "default", "enum", "export", "false",
                    "inline", "mutable", "namespace", "not_eq", "not",
                    "or_eq", "or", "register", "reinterpret_cast", "return",
                    "sizeof", "template", "true", "try", "typedef", "typeid",
                    "typename", "union", "unsigned", "using", "volatile", "xor_eq", "xor"
                ;
 
            condition
                =   conditions >> (eps_p - (alnum_p | '_')) >> *space_p
                ;   // make sure we recognize whole words only
 
            conditions
                =   "if", "else", "elseif", "case", "switch"
                ;
 
            boucle
                =   boucles >> (eps_p - (alnum_p | '_')) >> *space_p
                ;   // make sure we recognize whole words only
 
            boucles
                =   "while", "for", "break", "continue", "goto", "do"
                ;
 
            objet
                =   objets >> (eps_p - (alnum_p | '_')) >> *space_p
                ;   // make sure we recognize whole words only
 
            objets
                =   "class", "struct", "private", "protected", "public", "throw", "this",
                    "new", "delete", "friend", "operator", "explicit"
                ;
 
            type
                =   types >> (eps_p - (alnum_p | '_')) >> *space_p
                ;   // make sure we recognize whole words only
 
            types
                =   "bool", "int", "signed", "unsigned", "char", "double", "long", "short",
                    "static", "virtual", "void", "wchart", "float", "static_cast", "dynamic_cast",
                    "const_cast", "const", "extern"
                ;
 
            special
                =   +chset_p("~!%^&*()+={[}]:;,<.>?/|\\-") >> *space_p
                ;
 
            string
                =   !as_lower_d['l'] >> confix_p('"', *c_escape_ch_p, '"')
                    >> *space_p
                ;
 
            literal
                =   !as_lower_d['l'] >> confix_p('\'', *c_escape_ch_p, '\'')
                    >> *space_p
                ;
 
            number
                =   (   real_p
                    |   as_lower_d["0x"] >> hex_p
                    |   '0' >> oct_p
                    )
                    >>  *as_lower_d[chset_p("ldfu")]
                    >>  *space_p
                ;
 
            identifier
                =   ((alpha_p | '_') >> *(alnum_p | '_'))
                    >> *space_p
                ;
        }
 
        boost::spirit::symbols<>
            keywords, types, conditions, boucles, objets;
 
        boost::spirit::rule<ScannerT>
            program, preprocessor, comment, special, string, literal,
            number, identifier, keyword, type, condition, boucle, objet;
 
        boost::spirit::rule<ScannerT> const&
        start() const
        {
            return program;
        }
    };
 
    class declarations {
        private:
        std::string dernier;
 
        public:
 
        declarations();
 
        afficheur preprocessor, comment, keyword, identifier, special, string, literal, number, condition, boucle, type, objet;
 
        unexpected_char unexpected;
 
    };
 
    declarations evenements;
 
    private:
    std::string code_dormant;
 
};
J'obitens les erreures suivantes :
\libs\cpp.h||In constructor `CPP::definition<ScannerT>::definition(const CPP&)'
\libs\cpp.h|57|error: `space_p' was not declared in this scope|
\libs\cpp.h|66|error: `anychar_p' was not declared in this scope|
\libs\cpp.h|80|error: there are no arguments to `comment_p' that depend on a template parameter, so a declaration of `comment_p' must be available|
\libs\cpp.h|80|error: (if you use `-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)|
\libs\cpp.h|80|error: there are no arguments to `comment_p' that depend on a template parameter, so a declaration of `comment_p' must be available|
\libs\cpp.h|85|error: `eps_p' was not declared in this scope|
\libs\cpp.h|85|error: `alnum_p' was not declared in this scope|
\libs\cpp.h|133|error: there are no arguments to `chset_p' that depend on a template parameter, so a declaration of `chset_p' must be available|
\libs\cpp.h|137|error: `as_lower_d' was not declared in this scope|
\libs\cpp.h|137|error: `c_escape_ch_p' was not declared in this scope|
\libs\cpp.h|137|error: there are no arguments to `confix_p' that depend on a template parameter, so a declaration of `confix_p' must be available|
\libs\cpp.h|142|error: there are no arguments to `confix_p' that depend on a template parameter, so a declaration of `confix_p' must be available|
\libs\cpp.h|148|error: `real_p' was not declared in this scope|
\libs\cpp.h|149|error: `hex_p' was not declared in this scope|
\libs\cpp.h|150|error: `oct_p' was not declared in this scope|
\cpp.h|151|error: there are no arguments to `chset_p' that depend on a template parameter, so a declaration of `chset_p' must be available|
\libs\cpp.h|156|error: `alpha_p' was not declared in this scope|
\libs\cpp.cpp||In constructor `CPP::CPP()'
\libs\cpp.cpp|32|error: type `class CPP::declarations' is not a direct base of `CPP'|
\libs\cpp.h||In constructor `CPP::declarations::declarations()'
\libs\cpp.h|183|warning: `CPP::declarations::type' will be initialized after|
\libs\cpp.h|183|warning: `afficheur CPP::declarations::condition'|
\libs\cpp.cpp|49|warning: when initialized here|
||=== Build finished: 18 errors, 3 warnings ===|
J'ai essayé de rajouter grammar en héritage directe rien n'y fait, je suis déspéré :/

Par avance merci de votre aide