#include <sourceparser.hpp>
Public Member Functions | |
class_source_parser () | |
~class_source_parser () | |
void | set_input (const std::string &s) |
void | set_output (const std::string &s) |
bool | parse_source () |
Parses file line-by-line, checking every line to open WIKI block Please, notice that main input work is made in check_*** methods. More... | |
bool | save_schema () |
Saves tag tree to schema file. More... | |
void | expand () |
Expands all tags. More... | |
const std::vector< class_tag > & | see_orphans () const |
const class_error_container & | see_errors () const |
Grants access to error container. More... | |
Private Member Functions | |
bool | parse_block () |
Parses WIKI block line-by-line, checking every line to open annotation block. More... | |
bool | parse_tag () |
Parses lines inside tag block. More... | |
bool | parse_keys () |
Read key table and add keys to tag on the top of the stack. More... | |
bool | check_valid (const std::string &s) |
check the input line with a template check if the line is valid (still in block) More... | |
bool | getline (std::string &s) |
Gets a line from file and returns it. More... | |
void | close_opened_tags (int i) |
Сhecks stack of opened tags. More... | |
void | add_open_tag_error (int i) |
Generates errors for each opened tag. More... | |
bool | check_wiki (const std::string &s) |
Read tag form the line and add it to stack. More... | |
bool | check_tag_begin (const std::string &s) |
Checks line for tag annotation. More... | |
bool | check_tag_end (const std::string &s) |
Puts closed tag to child list of previous tag. More... | |
bool | check_parent_begin (const std::string &s) |
Opens parrent block. More... | |
bool | check_parent_end (const std::string &s) |
Closes parent block. More... | |
bool | check_keys_begin (const std::string &s) |
Checks beginning of keys. More... | |
bool | check_keys_end (const std::string &s) |
Checks end of keys. More... | |
bool | check_allow_link (const std::string &s) |
Checks links. More... | |
bool | check_allow_global (const std::string &s) |
Checks allowed global tags. More... | |
bool | check_allow_type (const std::string &s) |
Checks allowed types. More... | |
bool | check_remove_type (const std::string &s) |
Checks removed types. More... | |
bool | check_remove_key (const std::string &s) |
Checks removed keys. More... | |
Private Attributes | |
std::string | input_ |
name of input file to be parsed More... | |
std::string | output_ |
name of output file to print schema More... | |
std::fstream | f_ |
int | line_ |
number of current read line. More... | |
std::vector< class_tag > | current_ |
Stack of opened tags. More... | |
class_tag | root_ |
Root of the schema tree. More... | |
std::string | parent_name_ |
Name of current parent. More... | |
std::vector< class_tag > | orphan_tags_ |
List of tags without parents. More... | |
class_error_container | errors_ |
used to store errors More... | |
std::map< std::string, std::string > | types_ |
Allowed types. More... | |
std::vector< std::string > | forbidden_ |
Types to remove. More... | |
Definition at line 69 of file sourceparser.hpp.
|
inline |
Definition at line 71 of file sourceparser.hpp.
|
inline |
Definition at line 86 of file sourceparser.hpp.
Generates errors for each opened tag.
i | number of tags in stack to complain. |
Definition at line 262 of file sourceparser.cpp.
References schema_validation::class_error_container::add_opened_entity_error(), current_, errors_, i, input_, and line_.
Referenced by check_tag_end(), parse_block(), parse_keys(), and parse_tag().
|
private |
Checks allowed global tags.
Definition at line 523 of file sourceparser.cpp.
References current_, schema_validation::get_allow_global(), and schema_validation::sub().
Referenced by parse_tag().
|
private |
Checks links.
Definition at line 507 of file sourceparser.cpp.
References schema_validation::class_error_container::add_link_error(), current_, errors_, schema_validation::get_allow_link(), input_, line_, root_, and schema_validation::sub().
Referenced by parse_tag().
|
private |
Checks allowed types.
Definition at line 576 of file sourceparser.cpp.
References errors_, schema_validation::get_allow_type(), input_, line_, schema_validation::class_error_container::overriding_type_error(), schema_validation::class_error_container::remove_type_errors(), schema_validation::sub(), types_, and schema_validation::class_error_container::wrong_type_error().
Referenced by parse_block().
|
private |
Checks beginning of keys.
Definition at line 564 of file sourceparser.cpp.
References schema_validation::get_table_key_begin().
Referenced by parse_tag().
|
private |
Checks end of keys.
Definition at line 570 of file sourceparser.cpp.
References schema_validation::get_table_end().
Referenced by parse_keys().
|
private |
Opens parrent block.
Definition at line 535 of file sourceparser.cpp.
References schema_validation::class_error_container::add_second_parent_error(), errors_, schema_validation::get_parent_begin(), input_, line_, parent_name_, and schema_validation::sub().
Referenced by parse_block().
|
private |
Closes parent block.
Definition at line 549 of file sourceparser.cpp.
References schema_validation::class_error_container::add_unopened_entity_error(), errors_, schema_validation::get_parent_end(), input_, line_, parent_name_, and schema_validation::sub().
Referenced by parse_block().
|
private |
Checks removed keys.
Definition at line 609 of file sourceparser.cpp.
References current_, schema_validation::get_remove_key(), and schema_validation::sub().
Referenced by parse_tag().
|
private |
Checks removed types.
Definition at line 597 of file sourceparser.cpp.
References errors_, forbidden_, schema_validation::get_remove_type(), schema_validation::class_error_container::remove_type_errors(), schema_validation::sub(), and types_.
Referenced by parse_block().
|
private |
Checks line for tag annotation.
Reads tag and puts in into stack.
Definition at line 459 of file sourceparser.cpp.
References schema_validation::class_error_container::add_link_error(), current_, errors_, schema_validation::get_tag_begin(), input_, line_, root_, schema_validation::class_tag::set_max(), schema_validation::class_tag::set_min(), schema_validation::class_tag::set_name(), schema_validation::class_tag::set_super(), and schema_validation::sub().
Referenced by parse_block(), and parse_tag().
|
private |
Puts closed tag to child list of previous tag.
Also closes all opened child tags, if they are, and generates warnings.
Definition at line 481 of file sourceparser.cpp.
References add_open_tag_error(), schema_validation::class_error_container::add_unopened_entity_error(), close_opened_tags(), current_, errors_, schema_validation::get_tag_end(), input_, line_, and schema_validation::sub().
Referenced by parse_tag().
|
private |
check the input line with a template check if the line is valid (still in block)
Definition at line 448 of file sourceparser.cpp.
References schema_validation::get_valid(), and schema_validation::valid.
Referenced by parse_block(), parse_keys(), and parse_tag().
|
private |
Read tag form the line and add it to stack.
Definition at line 454 of file sourceparser.cpp.
References schema_validation::get_wiki().
Referenced by parse_source().
Сhecks stack of opened tags.
If any tags is opened - closes it and adds to sublist of next tag in stack. Add last tag in stack to parent
i | number of tags in stack to close. |
Definition at line 270 of file sourceparser.cpp.
References schema_validation::class_error_container::add_orphan_error(), schema_validation::class_tag::add_tag(), current_, errors_, i, input_, line_, orphan_tags_, parent_name_, schema_validation::class_error_container::remove_link_errors(), and root_.
Referenced by check_tag_end(), parse_block(), parse_keys(), parse_source(), and parse_tag().
|
inline |
Expands all tags.
While expanding tag copies list of keys and links from super-tag And adds links to super-tag children to links list. Useful when debugging the schema_markup
Definition at line 115 of file sourceparser.hpp.
References schema_validation::class_tag::expand_all(), and root_.
Referenced by main().
|
private |
Gets a line from file and returns it.
Is used to manage exceptions while IO.
Definition at line 246 of file sourceparser.cpp.
References schema_validation::class_error_container::add_read_error(), errors_, f_, input_, and line_.
Referenced by parse_block(), parse_keys(), parse_source(), and parse_tag().
|
private |
Parses WIKI block line-by-line, checking every line to open annotation block.
Definition at line 357 of file sourceparser.cpp.
References add_open_tag_error(), check_allow_type(), check_parent_begin(), check_parent_end(), check_remove_type(), check_tag_begin(), check_valid(), close_opened_tags(), current_, f_, getline(), and parse_tag().
Referenced by parse_source().
|
private |
Read key table and add keys to tag on the top of the stack.
Definition at line 422 of file sourceparser.cpp.
References add_open_tag_error(), schema_validation::class_error_container::add_opened_entity_error(), schema_validation::class_error_container::add_type_error(), check_keys_end(), check_valid(), close_opened_tags(), current_, errors_, schema_validation::get_key_value(), getline(), input_, line_, schema_validation::sub(), and types_.
Referenced by parse_tag().
bool schema_validation::class_source_parser::parse_source | ( | ) |
Parses file line-by-line, checking every line to open WIKI block Please, notice that main input work is made in check_*** methods.
Methods parse_*** are used to organize alhoritm and set which regex template can be used in this context. The only exception is parse_keys, where table of keys is read and add to top of stack tags.
Definition at line 311 of file sourceparser.cpp.
References schema_validation::class_error_container::add_simple_error(), check_wiki(), close_opened_tags(), errors_, f_, getline(), input_, line_, parent_name_, and parse_block().
Referenced by main().
|
private |
Parses lines inside tag block.
Calls checkers that are allowed in tag block
Definition at line 387 of file sourceparser.cpp.
References add_open_tag_error(), check_allow_global(), check_allow_link(), check_keys_begin(), check_remove_key(), check_tag_begin(), check_tag_end(), check_valid(), close_opened_tags(), current_, f_, getline(), and parse_keys().
Referenced by parse_block().
bool schema_validation::class_source_parser::save_schema | ( | ) |
Saves tag tree to schema file.
Definition at line 213 of file sourceparser.cpp.
References schema_validation::class_error_container::add_simple_error(), errors_, forbidden_, i, output_, schema_validation::class_tag::print(), schema_validation::class_tag::remove_keys_by_type(), root_, and types_.
Referenced by main().
|
inline |
Grants access to error container.
Definition at line 124 of file sourceparser.hpp.
References errors_.
Referenced by main().
|
inline |
Definition at line 120 of file sourceparser.hpp.
References orphan_tags_.
|
inline |
|
inline |
|
private |
Stack of opened tags.
Definition at line 138 of file sourceparser.hpp.
Referenced by add_open_tag_error(), check_allow_global(), check_allow_link(), check_remove_key(), check_tag_begin(), check_tag_end(), close_opened_tags(), parse_block(), parse_keys(), and parse_tag().
|
private |
used to store errors
Definition at line 146 of file sourceparser.hpp.
Referenced by add_open_tag_error(), check_allow_link(), check_allow_type(), check_parent_begin(), check_parent_end(), check_remove_type(), check_tag_begin(), check_tag_end(), close_opened_tags(), getline(), parse_keys(), parse_source(), save_schema(), and see_errors().
|
private |
Definition at line 132 of file sourceparser.hpp.
Referenced by getline(), parse_block(), parse_source(), and parse_tag().
|
private |
Types to remove.
Definition at line 150 of file sourceparser.hpp.
Referenced by check_remove_type(), and save_schema().
|
private |
name of input file to be parsed
Definition at line 129 of file sourceparser.hpp.
Referenced by add_open_tag_error(), check_allow_link(), check_allow_type(), check_parent_begin(), check_parent_end(), check_tag_begin(), check_tag_end(), close_opened_tags(), getline(), parse_keys(), parse_source(), and set_input().
|
private |
number of current read line.
Is used when generating errors
Definition at line 135 of file sourceparser.hpp.
Referenced by add_open_tag_error(), check_allow_link(), check_allow_type(), check_parent_begin(), check_parent_end(), check_tag_begin(), check_tag_end(), close_opened_tags(), getline(), parse_keys(), and parse_source().
|
private |
List of tags without parents.
Definition at line 144 of file sourceparser.hpp.
Referenced by close_opened_tags(), and see_orphans().
|
private |
name of output file to print schema
Definition at line 131 of file sourceparser.hpp.
Referenced by save_schema(), and set_output().
|
private |
Name of current parent.
Definition at line 142 of file sourceparser.hpp.
Referenced by check_parent_begin(), check_parent_end(), close_opened_tags(), and parse_source().
|
private |
Root of the schema tree.
Definition at line 140 of file sourceparser.hpp.
Referenced by check_allow_link(), check_tag_begin(), close_opened_tags(), expand(), and save_schema().
|
private |
Allowed types.
Definition at line 148 of file sourceparser.hpp.
Referenced by check_allow_type(), check_remove_type(), parse_keys(), and save_schema().