7#include "parse_generic_string.h"
48 varName = parser.getStrComposedOf(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_");
59 if(parser.isMatch(
"[")){
63 var.getVecChild().push_back(subValue);
65 if(!parser.isMatch(
",") && !parser.isMatchRewind(
"]")){
66 std::cerr <<
"parse_toml_varValue : expect ',' or ']' forunclosed list of values at " << parser.getLocation() << std::endl;
71 if(!parser.isMatch(
"]")){
72 std::cerr <<
"parse_toml_varBase : missing ']' token to close empty list of value at " << parser.getLocation() << std::endl;
80 if(parse_generic_string(strValue, parser)){
81 var.setValue(strValue);
82 }
else if(parser.isMatch(
"true")){
84 }
else if(parser.isMatch(
"false")){
85 var.setValue(
"false");
87 PString valueNumber(parser.getStrComposedOf(
"0123456789.-+e"));
88 if(valueNumber !=
""){
89 var.setValue(valueNumber);
91 std::cerr <<
"parse_toml_varValue : missing value of variable '"<<var.getKey()<<
"' at " << parser.getLocation() << std::endl;
107 if(!parser.isMatch(
"{")){
return false;}
109 if(parser.isMatch(
"#")){parser.getUntilKeyWithoutPatern(
"\n");}
111 if(!parser.isMatch(
",") && !parser.isMatchRewind(
"}")){
112 std::cerr <<
"parse_tomlCompactDico : expect ',' or '}' for unclosed dictionary of values at " << parser.getLocation() << std::endl;
117 if(!parser.isMatch(
"}")){
118 std::cerr <<
"parse_tomlCompactDico : missing '}' token to close empty dictionary of value at " << parser.getLocation() << std::endl;
136 if(!parser.isMatch(
"=")){
137 std::cerr <<
"parse_toml_varBase : missing '=' token to define value of variable '"<<varName<<
"' at " << parser.getLocation() << std::endl;
158 dico.getMapChild()[var.getKey()] = var;
171 dico.getVecChild().push_back(var);
181 DicoValue * output = &parent;
182 for(PVecString::const_iterator it(vecDicoName.begin()); it != vecDicoName.end(); ++it){
183 output = &(output->getMapChild()[*it]);
196 if(!parser.isMatch(
"[")){
return false;}
197 PString dicoName(parser.getUntilKeyWithoutPatern(
"]"));
198 PVecString vecDicoName = dicoName.split(
'.');
202 while(!parser.isEndOfFile() &&
parse_toml_isParse(data) && !parser.isMatchRewind(
"[")){
203 if(parser.isMatch(
"#")){parser.getUntilKeyWithoutPatern(
"\n");}
224 if(!parser.isMatch(
"[[")){
return false;}
225 PString dicoName(parser.getUntilKeyWithoutPatern(
"]]"));
226 PVecString vecDicoName = dicoName.split(
'.');
231 while(!parser.isEndOfFile() &&
parse_toml_isParse(data) && !parser.isMatchRewind(
"[")){
232 if(parser.isMatch(
"#")){parser.getUntilKeyWithoutPatern(
"\n");}
243 dicoDef->getVecChild().push_back(table);
254 parser.getStrComposedOf(
" \t\n");
256 if(parser.isMatch(
"#")){parser.getUntilKeyWithoutPatern(
"\n");}
260 PString nextToken(parser.getNextToken());
261 if(nextToken.size() != 0lu){
262 std::cerr <<
"parser_toml_fileParser : error at " << parser.getLocation() << std::endl;
263 std::cerr <<
"\tunexpected token '"<<nextToken<<
"'" << std::endl;
278 parser.setWhiteSpace(
" \n\t");
279 parser.setSeparator(
":-'\",{}[]>|");
280 parser.setEscapeChar(
'\\');
281 if(!parser.open(fileName)){
282 std::cerr <<
"parser_toml : cannot open file '"<<fileName<<
"'" << std::endl;
void parse_toml_stopParsing(PTomlParserData &data)
Stop the file parsing.
DicoValue * parse_get_parent_dico(DicoValue &parent, const PVecString &vecDicoName)
Get the parent dictionary by respect to the vecDicoName.
bool parse_toml_dico_def(DicoValue &parent, PFileParser &parser, PTomlParserData &data)
Parse a dico definition.
bool parse_toml_varBase(DicoValue &var, PFileParser &parser, PTomlParserData &data)
Parse a toml var name.
bool parse_toml_isParse(const PTomlParserData &data)
Say if the file parsing is enable.
bool parser_toml_fileParser(DicoValue &dico, PFileParser &parser)
Parse a yml file and update the given VecValue.
bool parse_toml_varName(PString &varName, PFileParser &parser)
Parse a toml var name.
bool parse_toml_varValue(DicoValue &var, PFileParser &parser, PTomlParserData &data)
Parse a toml var name.
bool parse_toml_varTable(DicoValue &dico, PFileParser &parser, PTomlParserData &data)
Parse a toml var name.
bool parse_toml_table_def(DicoValue &parent, PFileParser &parser, PTomlParserData &data)
Parse a dico definition.
bool parse_tomlCompactDico(DicoValue &parent, PFileParser &parser, PTomlParserData &data)
Parse a compact dico definition.
PTomlParserData default_PTomlParserData()
Default value of PTomlParserData.
bool parser_toml(DicoValue &dico, const PPath &fileName)
Parse a toml file and update the given DicoValue.
bool parse_toml_all(DicoValue &parent, PFileParser &parser, PTomlParserData &data)
bool parse_toml_var(DicoValue &dico, PFileParser &parser, PTomlParserData &data)
Parse a toml var name.
Data used to parse a toml file.
bool isRun
True to continue the parsing, false to stop.