Finished Language Generation Tool

This commit is contained in:
2023-02-15 18:02:49 -08:00
parent b8bab7ebed
commit 4cd417a8fc
4 changed files with 166 additions and 5 deletions

View File

@ -26,6 +26,8 @@ void Xml::load(Xml *xml, std::string data, size_t *j) {
bool_t insideTag = false;
std::string buffer = "";
std::string attrKey = "";
std::string bufferWhitespaces;
bool_t valueIsInWhitespace = false;
size_t i = *j;
while(c = data[i++]) {
@ -131,10 +133,29 @@ void Xml::load(Xml *xml, std::string data, size_t *j) {
// In HTML Spec there could be a child here but not in XML spec.
doing = XML_PARSE_STATE_PARSING_CLOSE;
xml->value = buffer;
buffer = "";
buffer.clear();
valueIsInWhitespace = false;
bufferWhitespaces.clear();
continue;
}
buffer += c;
if(Xml::isWhitespace(c)) {
if(!valueIsInWhitespace) {
bufferWhitespaces.clear();
bufferWhitespaces += c;
valueIsInWhitespace = true;
} else {
if(c != ' ') bufferWhitespaces += c;
}
// TODO: I can maybe consider indentation here
} else {
if(valueIsInWhitespace) {
buffer += bufferWhitespaces;
valueIsInWhitespace = false;
}
buffer += c;
}
break;
case XML_PARSE_STATE_PARSING_CHILD: