XMLParser: Implement support for short tag endings
This commit is contained in:
parent
84d93d21ea
commit
7b6ac65d6a
@ -25,17 +25,17 @@ SOFTWARE.
|
|||||||
<gui>
|
<gui>
|
||||||
<box x="right" y="bottom" width="250" height="200" right_margin="8" bottom_margin="8" tr_text="Main Menu" layout="horizontal">
|
<box x="right" y="bottom" width="250" height="200" right_margin="8" bottom_margin="8" tr_text="Main Menu" layout="horizontal">
|
||||||
<container width="50%" height="100%" layout="vertical">
|
<container width="50%" height="100%" layout="vertical">
|
||||||
<label width="100%" height="25" tr_text="Nickname"></label>
|
<label width="100%" height="25" tr_text="Nickname" />
|
||||||
<label width="100%" height="25" tr_text="Server"></label>
|
<label width="100%" height="25" tr_text="Server" />
|
||||||
<label width="100%" height="25" tr_text="Port"></label>
|
<label width="100%" height="25" tr_text="Port" />
|
||||||
<button width="50%" height="30" id="button_join" tr_text="Join"></button>
|
<button width="50%" height="30" id="button_join" tr_text="Join" />
|
||||||
<!-- Note: Caption of button_host is set in code -->
|
<!-- Note: Caption of button_host is set in code -->
|
||||||
<button width="50%" height="30" id="button_host"></button>
|
<button width="50%" height="30" id="button_host" />
|
||||||
</container>
|
</container>
|
||||||
<container width="45%" height="100%" layout="vertical">
|
<container width="45%" height="100%" layout="vertical">
|
||||||
<text_edit width="97%" height="25" id="text_edit_nickname"></text_edit>
|
<text_edit width="97%" height="25" id="text_edit_nickname" />
|
||||||
<text_edit width="97%" height="25" id="text_edit_server"></text_edit>
|
<text_edit width="97%" height="25" id="text_edit_server" />
|
||||||
<text_edit width="97%" height="25" id="text_edit_port"></text_edit>
|
<text_edit width="97%" height="25" id="text_edit_port" />
|
||||||
</container>
|
</container>
|
||||||
</box>
|
</box>
|
||||||
</gui>
|
</gui>
|
||||||
|
@ -48,13 +48,22 @@ bool polygun::xml::parse(std::istream& stream, XMLNode*& output) {
|
|||||||
node_stack.push_back(temp_node);
|
node_stack.push_back(temp_node);
|
||||||
node_stack.back()->set_name(tokens[offset].m_data);
|
node_stack.back()->set_name(tokens[offset].m_data);
|
||||||
while(++offset<tokens.size() && tokens[offset].m_type!=XMLToken::XML_TOKEN_TYPE_RBRACKET) {
|
while(++offset<tokens.size() && tokens[offset].m_type!=XMLToken::XML_TOKEN_TYPE_RBRACKET) {
|
||||||
const XMLToken& key = tokens[offset++];
|
const XMLToken& key_or_tag_end = tokens[offset++];
|
||||||
if(offset>=tokens.size()) {
|
if(offset>=tokens.size()) {
|
||||||
LOG_ERROR("Unexpected end of input after %s token at %zu:%zu", key.get_string_name().c_str(), key.m_line, key.m_column);
|
LOG_ERROR("Unexpected end of input after %s token at %zu:%zu", key_or_tag_end.get_string_name().c_str(), key_or_tag_end.m_line, key_or_tag_end.m_column);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(key.m_type!=XMLToken::XML_TOKEN_TYPE_IDENTIFIER){
|
if(key_or_tag_end.m_type==XMLToken::XML_TOKEN_TYPE_SLASH) {
|
||||||
LOG_ERROR("Expected IDENTIFIER at %zu:%zu", key.m_line, key.m_column);
|
const XMLToken& rbracket = tokens[offset];
|
||||||
|
if(rbracket.m_type!=XMLToken::XML_TOKEN_TYPE_RBRACKET) {
|
||||||
|
LOG_ERROR("Expected RBRACKET at %zu:%zu (found %s)", rbracket.m_line, rbracket.m_column, rbracket.get_string_name().c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
node_stack.pop_back();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(key_or_tag_end.m_type!=XMLToken::XML_TOKEN_TYPE_IDENTIFIER){
|
||||||
|
LOG_ERROR("Expected IDENTIFIER at %zu:%zu", key_or_tag_end.m_line, key_or_tag_end.m_column);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const XMLToken& equals = tokens[offset++];
|
const XMLToken& equals = tokens[offset++];
|
||||||
@ -75,7 +84,7 @@ bool polygun::xml::parse(std::istream& stream, XMLNode*& output) {
|
|||||||
LOG_ERROR("Expected STRING at %zu:%zu", str.m_line, str.m_column);
|
LOG_ERROR("Expected STRING at %zu:%zu", str.m_line, str.m_column);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
node_stack.back()->add_attribute(key.m_data, str.m_data);
|
node_stack.back()->add_attribute(key_or_tag_end.m_data, str.m_data);
|
||||||
}
|
}
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user