Fix schema validator ignoring toplevel keys

This commit is contained in:
Celtic Minstrel 2018-11-18 00:41:42 -05:00
parent 6936c59e17
commit 90d1aec2f2
2 changed files with 13 additions and 1 deletions

View File

@ -125,6 +125,10 @@ void parser::operator()()
cfg_.clear();
elements.emplace(&cfg_, "");
if(validator_) {
validator_->open_tag("", cfg_, tok_.get_start_line(), tok_.get_file());
}
do {
tok_.next_token();
@ -163,6 +167,12 @@ void parser::operator()()
// The main element should be there. If it is not, this is a parser error.
assert(!elements.empty());
if(validator_) {
element& el = elements.top();
validator_->validate(*el.cfg, el.name, el.start_line, el.file);
validator_->close_tag();
}
if(elements.size() != 1) {
utils::string_map i18n_symbols;
i18n_symbols["tag"] = elements.top().name;

View File

@ -205,7 +205,9 @@ bool schema_validator::read_config_file(const std::string& filename)
*/
void schema_validator::open_tag(const std::string& name, const config& parent, int start_line, const std::string& file, bool addittion)
{
if(!stack_.empty()) {
if(name.empty()) {
// Opened the root tag; nothing special to do here
} else if(!stack_.empty()) {
const wml_tag* tag = nullptr;
if(stack_.top()) {