21 #include <boost/regex.hpp>
110 static std::string parent_begin = valid + block_begin
190 static std::string key_value = valid +
sub(
"[a-zA-z][a-zA-Z\\d_+-]*")
191 +
"\\s*&\\s*"+
sub(name_type)
192 +
"\\s*&\\s?"+
sub(
quote(
"[a-zA-Z._0-9+-]*"))
219 out.open(
output_.c_str(),std::ios::out|std::ios::trunc);
222 "\n Output would not be stored\n");
226 for (std::vector<std::string>::const_iterator
i=
forbidden_.begin ();
231 out <<
"[wml_schema]\n";
235 <<
" name=" <<
i->first <<
"\n"
236 <<
" value=\""<<
i->second <<
"\"\n"
240 out <<
"[/wml_schema]\n";
274 std::stack<std::string> error_cache ;
282 error_cache.push(tag.get_name());
291 error_cache.push(
current_.back().get_name());
297 for (std::vector<class_tag>::const_iterator ii =
current_.begin();
299 name_to_remove_from_cache += ii->get_name() +
"/";
301 while (! error_cache.empty()){
302 name_to_remove_from_cache += error_cache.top();
305 name_to_remove_from_cache +=
"/";
360 if (!
getline(line) ) {
return false; }
390 if (!
getline(line) ) {
return false; }
425 if (!
getline(line) ) {
return false; }
434 bool res = boost::regex_match(line,sub,value);
451 return boost::regex_search(s,valid);
456 return boost::regex_match(s,wiki);
463 bool res = boost::regex_match(s,sub,tag);
472 if (! link.empty() &&
484 bool res = boost::regex_match(s,sub,endtag);
492 int count_opened = 0;
495 if (ii->get_name() ==
name){
510 bool res = boost::regex_match(s,sub,allow_link);
515 if (static_cast<const class_tag>(
root_).find_tag(link,
root_) ==
nullptr){
526 bool res = boost::regex_match(s,sub,allow_global);
529 current_.back().add_link(
"global/"+sub[1]);
538 bool res = boost::regex_match(s,sub,parent);
552 bool res = boost::regex_match(s,sub,parent);
566 return boost::regex_match(s,keys);
572 bool res = boost::regex_match(s,endkeys);
579 bool res = boost::regex_match(s,sub,allow_type);
584 boost::regex tmp (value);
585 }
catch(std::exception ){
600 bool res = boost::regex_match(s,sub,remove_type);
612 bool res = boost::regex_match(s,sub,remove_key);
615 current_.back ().remove_key_by_name(sub[1]);
const std::string & get_parent_end()
Template to check closing of parent block.
void test_regex(std::ostream &f)
Writes to the file regex templates list.
void remove_keys_by_type(const std::string &type)
Removes all keys with this type.
const std::string parent_type
type of possible parent indentificator
const std::string & get_allow_global()
Template to check allow{global} block.
bool parse_source()
Parses file line-by-line, checking every line to open WIKI block Please, notice that main input work ...
static const std::string & get_allow_type()
bool check_valid(const std::string &s)
check the input line with a template check if the line is valid (still in block)
const std::string & get_table_key_begin()
Template to check begining of table{config} storing key values.
static const std::string & get_remove_type()
void remove_link_errors(const std::string &link)
Clears link cache.
std::vector< class_tag > current_
Stack of opened tags.
bool check_remove_key(const std::string &s)
Checks removed keys.
void add_orphan_error(const std::string &file, int line, const std::string &name)
Generate and put GCC-style error message about tag without parent.
bool check_wiki(const std::string &s)
Read tag form the line and add it to stack.
bool getline(std::string &s)
Gets a line from file and returns it.
const std::string block_end
end of block
const std::string & get_tag_begin()
Template to check if line contains opening of tag block.
const std::string & get_table_end()
Template to check if table is closed.
GLuint GLuint GLsizei GLenum type
bool check_keys_begin(const std::string &s)
Checks beginning of keys.
This file contains sourceparser object, collecting annotations and building a tag tree...
const std::string & get_valid()
A few regex templates.
bool parse_tag()
Parses lines inside tag block.
std::map< std::string, std::string > types_
Allowed types.
bool parse_keys()
Read key table and add keys to tag on the top of the stack.
bool check_tag_begin(const std::string &s)
Checks line for tag annotation.
void add_second_parent_error(const std::string &file, int line, const std::string &first, const std::string &second)
Generate and put GCC-style error message about opening parent block before before closing previous bl...
const std::string number
template to number regex
void set_name(const std::string &name)
const std::string & get_tag_end()
Template to check end of tag block.
class_key is used to save the information about one key.
std::string output_
name of output file to print schema
bool check_parent_begin(const std::string &s)
Opens parrent block.
bool save_schema()
Saves tag tree to schema file.
void close_opened_tags(int i)
Сhecks stack of opened tags.
const std::string & get_key_value()
Template to get key value.
const std::string sign
sign "-" - hyphen-minus used to set sign of signed integer
static std::string sub(const std::string &s)
Private function to surround an argument with brackets.
int line_
number of current read line.
std::vector< class_tag > orphan_tags_
List of tags without parents.
const std::string name_type
type of possible name identificator
std::vector< std::string > forbidden_
Types to remove.
bool check_tag_end(const std::string &s)
Puts closed tag to child list of previous tag.
static const std::string & get_remove_key()
GLsizei const GLfloat * value
void add_link_error(const std::string &file, int line, const std::string &link)
Generate and put GCC-style error message about failed link to link cache.
void add_opened_entity_error(const std::string &file, int line, const std::string &name)
Generate and put GCC-style error message about annotation block somebody missed to close...
void set_super(std::string const &s)
std::string parent_name_
Name of current parent.
const std::string block_begin
begining of the block.
bool check_allow_type(const std::string &s)
Checks allowed types.
bool check_keys_end(const std::string &s)
Checks end of keys.
const std::string eol
end of line + possible various character before.
const std::string equals
sigh "="
bool check_allow_link(const std::string &s)
Checks links.
void add_type_error(const std::string &file, int line, const std::string &type)
Generate and put GCC-style error message about unknown type to type cache.
void overriding_type_error(const std::string &file, int line, const std::string &type)
Generate and put GCC-style error message about overriding type Overriding means that that type was de...
void add_simple_error(const std::string &message)
Puts simple error message in container.
static std::string property(const std::string &name, const std::string &value="")
Creates a property template.
void remove_type_errors(const std::string &type)
Clears type cache.
const std::string & get_allow_link()
Template to check allow{link} block.
const std::string space
whitespace is possible
bool parse_block()
Parses WIKI block line-by-line, checking every line to open annotation block.
class_tag root_
Root of the schema tree.
const std::string quote_symbol
non-mandatory sign "
GLuint const GLchar * name
const std::string property_close
sign "}" - another curly bracket
void add_tag(const class_tag &new_tag)
static std::string quote(const std::string &s)
Private function to surround argument with not mandatory quotes.
void add_open_tag_error(int i)
Generates errors for each opened tag.
const std::string & get_wiki()
Template to check line is beginnnig of Wiki block.
const std::string allow
allow directive
void wrong_type_error(const std::string &file, int line, const std::string &name, const std::string &value)
Generate and put GCC-style error message about wrong type value.
const std::string link_type
type of possible link indentificator
const std::string & get_parent_begin()
Template to check begining of parent block.
const std::string wiki_begin
begining of wiki block
std::string input_
name of input file to be parsed
bool check_parent_end(const std::string &s)
Closes parent block.
void add_unopened_entity_error(const std::string &file, int line, const std::string &name)
Generate and put GCC-style error message about closing block that wasn't opened.
GLsizei const GLcharARB ** string
Stores information about tag.
void print(std::ostream &os)
Prints information about tag to outputstream, recursively is used to print tag info the format is nex...
bool check_remove_type(const std::string &s)
Checks removed types.
const std::string valid
Little parts of regex templates used to parse Wml annoations.
const std::string property_open
sign "{" - curly bracket
class_error_container errors_
used to store errors
void add_read_error(const std::string &file, int line)
Generate and put GCC-style error message about error read file error.
bool check_allow_global(const std::string &s)
Checks allowed global tags.