17 std::cerr <<
"errorUnexpectedToken : '" << parser.getFileName() <<
"' line " << parser.getLine() << std::endl;
18 std::cerr <<
"unexpected token '" << token <<
"'" << std::endl;
26 PString name = parser.getStrComposedOf(
"_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
27 while(parser.isMatch(
"::")){
28 name +=
"::" + parser.getStrComposedOf(
"_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
39 if(parser.isMatch(
"//")){
40 if(currentComment !=
""){currentComment +=
"\n";}
41 currentComment +=
"//" + parser.getUntilKeyWithoutPatern(
"\n");
42 }
else if(parser.isMatch(
"/*")){
43 if(currentComment !=
""){currentComment +=
"\n";}
44 currentComment +=
"/*" + parser.getUntilKey(
"*/");
57 if(!parser.isMatch(
"template")){
return false;}
58 if(!parser.isMatch(
"<")){
return false;}
60 currentTemplate = parser.getUntilKeyWithoutPaternRecurse(
">",
"<").split(
',');
72 parser.skipWhiteSpace();
73 PString attribut(parser.getUntilKeyWithoutPatern(
";").eraseChar(
"\n"));
74 PVecString listToken(attribut.split(
" \n\t"));
75 PString attributName(listToken.back());
77 PString attributType(
"");
78 for(PVecString::iterator it(listToken.begin()); it != listToken.end(); ++it){
79 attributType += *it +
" ";
81 attributType = attributType.eraseFirstLastChar(
" \n\t");
93 if(!parser.isMatch(
"("))
return true;
95 while(!parser.isEndOfFile() && parser.isMatch(
")")){
101 if(parser.isMatch(
")")){
break;}
103 if(!parser.isMatch(
",")){
119 if(!parser.isMatch(
"=")){
120 value = parser.getStrComposedOf(
"0123456789xu");
136bool parseEnumConfig(std::vector<PClassConfig> & listClassConfig, PFileParser & parser, PString & currentComment){
137 if(!parser.isMatchToken(
"enum")){
return false;}
141 std::cout <<
"parseEnumConfig : find enum : '"<<enumName<<
"'" << std::endl;
145 parser.skipWhiteSpace();
146 if(!parser.isMatch(
"{")){
148 std::cerr <<
"\tExpect '{' after enum name '"<<enumName<<
"'" << std::endl;
151 bool searchingData(
true);
152 while(!parser.isEndOfFile() && searchingData && !parser.isMatch(
"}")){
161 listClassConfig.push_back(config);
172bool parsePClassConfig(std::vector<PClassConfig> & listClassConfig, PFileParser & parser, PString & currentComment, PVecString & listTemplate){
175 size_t separator = fullName.rfind(
"::");
176 PString className, namespaceName;
177 if(separator != PString::npos){
178 className = fullName.substr(separator + 2);
179 namespaceName = fullName.substr(0, separator);
180 std::cout <<
"parsePClassConfig : find namespaceName : '"<<namespaceName<<
"'" << std::endl;
182 className = fullName;
184 std::cout <<
"parsePClassConfig : find className : '"<<className<<
"'" << std::endl;
190 listTemplate.clear();
191 parser.skipWhiteSpace();
194 std::cerr <<
"parsePClassConfig : file '" << parser.getFileName() <<
"' line " << parser.getLine() << std::endl;
195 std::cerr <<
"\tmissing ')' : can't parse parents of the class '"<<config.
getName()<<
"'" << std::endl;
197 if(parser.isEndOfFile()){
198 std::cerr <<
"parsePClassConfig : file '" << parser.getFileName() <<
"' line " << parser.getLine() << std::endl;
199 std::cerr <<
"\tmissing '}'" << std::endl;
202 if(!parser.isMatch(
"{")){
204 std::cerr <<
"\tExpect '{' after class name '"<<className<<
"'" << std::endl;
208 bool searchingData(
true);
209 while(!parser.isEndOfFile() && searchingData && !parser.isMatch(
"}")){
218 listClassConfig.push_back(config);
228bool parserClassConfig(std::vector<PClassConfig> & listClassConfig, PVecPath & listInclude,
const PPath & fileName){
229 if(fileName ==
"")
return false;
231 parser.setWhiteSpace(
" \t\n");
232 parser.setSeparator(
"{};/*");
233 if(!parser.open(fileName))
return false;
234 PString currentComment(
"");
235 PVecString listTemplate;
236 while(!parser.isEndOfFile()){
237 if(parser.isMatch(
"#")){
238 if(parser.isMatch(
"include")){
239 listInclude.push_back(parser.getUntilKeyWithoutPatern(
"\n").eraseChar(
" \t\n"));
250 parser.skipWhiteSpace();
Describes a class attribute.
void setDefaultValue(const PString &defaultValue)
Sets the defaultValue of the PClassAttribute.
Class to describe a basic class.
void addAttribute(const PClassAttribute &attribute)
Adds an attribute to the class.
void setClassDocumentation(const PString &classDocumentation)
Sets the class documentation.
void setNamespace(const PString &value)
Sets the namespace of the class.
void setIsEnum(bool isEnum)
Set if the current PClassConfig is an enum.
const PString & getName() const
Returns the class name.
void setName(const PString &name)
Sets the class name.
void addParentClass(const PString &parentClass)
Add a parent class to the PClassConfig.
void setListTemplate(const PVecString &listTemplate)
Sets the list of template of the class.
PClassAttribute createClassAttribute(const PString &type, const PString &name, const PString &documentation)
Creates a PClassAttribute.
bool updateCurrentComment(PFileParser &parser, PString ¤tComment)
Fonction qui met à jour un commentaire.
bool parseEnumValue(PClassConfig &config, PFileParser &parser, PString ¤tComment)
Parse enum attribute value.
bool parseEnumConfig(std::vector< PClassConfig > &listClassConfig, PFileParser &parser, PString ¤tComment)
Parse an enum definition.
bool parseClassConfigAttribut(PClassConfig &config, PFileParser &parser, PString ¤tComment)
Parse a PClassConfig.
bool parsePClassConfig(std::vector< PClassConfig > &listClassConfig, PFileParser &parser, PString ¤tComment, PVecString &listTemplate)
Parse a PClassConfig.
bool parserClassConfig(std::vector< PClassConfig > &listClassConfig, PVecPath &listInclude, const PPath &fileName)
Parser list class config.
bool updateCurrentTemplate(PFileParser &parser, PVecString ¤tTemplate)
Update a template definition.
bool parseParentOfClassConfig(PClassConfig &config, PFileParser &parser)
Parse the parents of the PClassConfig.
PString getClassName(PFileParser &parser)
Get class name from parser.
void errorUnexpectedToken(const PFileParser &parser, const PString &token)
Affiche une erreur de token non attendu.