summaryrefslogtreecommitdiff
path: root/server/src/macroparser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/macroparser.cc')
-rw-r--r--server/src/macroparser.cc65
1 files changed, 49 insertions, 16 deletions
diff --git a/server/src/macroparser.cc b/server/src/macroparser.cc
index fe7f6e3..2bd482e 100644
--- a/server/src/macroparser.cc
+++ b/server/src/macroparser.cc
@@ -84,6 +84,7 @@ MacroParser::MacroParser(std::string macrofile)
m = NULL;
current_map = NULL;
current_script = NULL;
+ current_resume_script = NULL;
file = macrofile;
@@ -101,9 +102,9 @@ MacroParser::~MacroParser()
void MacroParser::characterData(std::string &data)
{
- if(state == RESUME) {
- assert(m); // No macro present!
- m->resume.attributes["format"].append(data);
+ if(state == RESUME_SCRIPT) {
+ assert(current_resume_script); // No macro present!
+ current_resume_script->code.append(data);
}
if(state == MAP) {
@@ -117,7 +118,8 @@ void MacroParser::characterData(std::string &data)
}
}
-void MacroParser::startTag(std::string name, std::map< std::string, std::string> attributes)
+void MacroParser::startTag(std::string name,
+ std::map< std::string, std::string> attributes)
{
// Create macro and enable parsing of queries, maps and widgets
if(name == "macro") {
@@ -203,18 +205,36 @@ void MacroParser::startTag(std::string name, std::map< std::string, std::string>
return;
}
- // Create Query
+ // Create script
if(name == "script") {
- if(state != SCRIPTS) error("script found outside scripts.");
- state = SCRIPT;
-
- assert(m); // No macro is currently available, cannot create map!
-
- Script s;
- s.attributes = attributes;
- m->scripts.push_back(s);
- current_script = &(m->scripts.back());
+ assert(m); // No macro is currently available, cannot create script!
+
+ switch(state) {
+ case SCRIPTS:
+ {
+ state = SCRIPT;
+
+ Script s;
+ s.attributes = attributes;
+ m->scripts.push_back(s);
+ current_script = &(m->scripts.back());
+ }
+ break;
+ case RESUME:
+ {
+ state = RESUME_SCRIPT;
+
+ Script s;
+ s.attributes = attributes;
+ m->resume_scripts.push_back(s);
+ current_resume_script = &(m->resume_scripts.back());
+ }
+ break;
+ default:
+ error("<script> tag found outside <scripts> or <resume> tags.");
+ break;
+ }
return;
}
@@ -278,8 +298,21 @@ void MacroParser::endTag(std::string name)
}
if(name == "scripts") state = MACRO;
if(name == "script") {
- current_script = NULL;
- state = SCRIPTS;
+ switch(state) {
+ case SCRIPT:
+ current_script = NULL;
+ state = SCRIPTS;
+ break;
+
+ case RESUME_SCRIPT:
+ current_resume_script = NULL;
+ state = RESUME;
+ break;
+
+ default:
+ // tag mismatch?
+ break;
+ }
}
if(name == "widgets") state = MACRO;