aboutsummaryrefslogtreecommitdiff
path: root/gui/ThemeParser.cpp
diff options
context:
space:
mode:
authorVicent Marti2008-06-16 23:38:21 +0000
committerVicent Marti2008-06-16 23:38:21 +0000
commit6932c836cfb5f02565feb4700f42633ed5c84d68 (patch)
tree35129c9aa10cc31ccf52cf48707e5595f186a486 /gui/ThemeParser.cpp
parentcb6cb1361b742ae274c5cd6584ad69b0f3d61db8 (diff)
downloadscummvm-rg350-6932c836cfb5f02565feb4700f42633ed5c84d68.tar.gz
scummvm-rg350-6932c836cfb5f02565feb4700f42633ed5c84d68.tar.bz2
scummvm-rg350-6932c836cfb5f02565feb4700f42633ed5c84d68.zip
Added massive parser documentation.
Some parser changes. svn-id: r32726
Diffstat (limited to 'gui/ThemeParser.cpp')
-rw-r--r--gui/ThemeParser.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
index 498679c88f..267efba371 100644
--- a/gui/ThemeParser.cpp
+++ b/gui/ThemeParser.cpp
@@ -44,10 +44,10 @@ namespace GUI {
void ThemeParser::debug_testEval() {
static const char *debugConfigText =
- "</* lol this is just a moronic test */drawdata id = \"background_default\" cache = true>"
- "<draw func = \"roundedsq\" /*/fill = \"gradient\" gradient_start = \"255, 255, 128\" gradient_end = \"128, 128, 128\" size = \"auto\"/>"
- "<draw func = \"roundedsq\" fill = \"none\" color = /*\"0, 0, 0\"*/\"0, 1, 2\" size = \"auto\"/>"
- "</ drawdata>/* lol this is just a simple test*/";
+ "</* lol this is just a moronic test */drawdata id = \"background_default\" cache = true>\n"
+ "<drawstep func = \"roundedsq\" fill = \"gradient\" gradient_start = \"255, 255, 128\" gradient_end = \"128, 128, 128\" size = \"auto\"/>\n"
+ "//<drawstep func = \"roundedsq\" fill = \"none\" color = /*\"0, 0, 0\"*/\"0, 1, 2\" size = \"auto\"/>\n"
+ "</ drawdata>/* lol this is just a simple test*/\n";
_text = strdup(debugConfigText);
parse();
@@ -59,7 +59,7 @@ void ThemeParser::parserError(const char *error_string) {
printf("PARSER ERROR: %s\n", error_string);
}
-void ThemeParser::parserCallback_DRAW() {
+void ThemeParser::parserCallback_DRAWSTEP() {
printf("Draw callback!\n");
}
@@ -68,29 +68,28 @@ void ThemeParser::parserCallback_DRAWDATA() {
}
void ThemeParser::parseActiveKey(bool closed) {
- printf("Parsed key %s.\n", _activeKey.top().c_str());
+ printf("Parsed key %s.\n", _activeKey.top()->name.c_str());
- if (!_callbacks.contains(_activeKey.top())) {
+ if (!_callbacks.contains(_activeKey.top()->name)) {
parserError("Unhandled value inside key.");
return;
}
// Don't you just love C++ syntax? Water clear.
- (this->*(_callbacks[_activeKey.top()]))();
+ (this->*(_callbacks[_activeKey.top()->name]))();
- for (Common::StringMap::const_iterator t = _keyValues.top().begin(); t != _keyValues.top().end(); ++t)
+ for (Common::StringMap::const_iterator t = _activeKey.top()->values.begin(); t != _activeKey.top()->values.end(); ++t)
printf(" Key %s = %s\n", t->_key.c_str(), t->_value.c_str());
if (closed) {
- _keyValues.pop();
- _activeKey.pop();
+ delete _activeKey.pop();
}
}
bool ThemeParser::parseKeyValue(Common::String keyName) {
- assert(_keyValues.empty() == false);
+ assert(_activeKey.empty() == false);
- if (_keyValues.top().contains(keyName))
+ if (_activeKey.top()->values.contains(keyName))
return false;
_token.clear();
@@ -109,7 +108,7 @@ bool ThemeParser::parseKeyValue(Common::String keyName) {
return false;
}
- _keyValues.top()[keyName] = _token;
+ _activeKey.top()->values[keyName] = _token;
return true;
}
@@ -120,7 +119,6 @@ bool ThemeParser::parse() {
_state = kParserNeedKey;
_pos = 0;
- _keyValues.clear();
_activeKey.clear();
while (_text[_pos]) {
@@ -160,11 +158,12 @@ bool ThemeParser::parse() {
}
if (activeClosure) {
- if (_activeKey.empty() || _token != _activeKey.top())
+ if (_activeKey.empty() || _token != _activeKey.top()->name)
parserError("Unexpected closure.");
} else {
- _keyValues.push(Common::StringMap());
- _activeKey.push(_token);
+ ParserNode *node = new ParserNode;
+ node->name = _token;
+ _activeKey.push(node);
}
_state = kParserNeedPropertyName;
@@ -173,8 +172,7 @@ bool ThemeParser::parse() {
case kParserNeedPropertyName:
if (activeClosure) {
activeClosure = false;
- _activeKey.pop();
- _keyValues.pop();
+ delete _activeKey.pop();
if (_text[_pos++] != '>')
parserError("Invalid syntax in key closure.");
@@ -215,6 +213,9 @@ bool ThemeParser::parse() {
_state = kParserNeedPropertyName;
break;
+
+ default:
+ break;
}
}