diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-12-14 13:20:04 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-12-14 13:20:04 (GMT) |
commit | 330576fcb4d97504e0d6951067b753499d91b541 (patch) | |
tree | 9c583dd3e13ff574295f559a7b92dfe9a1dafd2d /src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp | |
parent | 9608216597fd17021d38e80689644beb3c85abb9 (diff) | |
download | uscxml-330576fcb4d97504e0d6951067b753499d91b541.zip uscxml-330576fcb4d97504e0d6951067b753499d91b541.tar.gz uscxml-330576fcb4d97504e0d6951067b753499d91b541.tar.bz2 |
Renamed URI to URL
Some fixes for Xincludes
Diffstat (limited to 'src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp')
-rw-r--r-- | src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp | 64 |
1 files changed, 28 insertions, 36 deletions
diff --git a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp index 5b3c79c..9edd505 100644 --- a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp +++ b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp @@ -276,7 +276,6 @@ std::string PromelaDataModel::evalAsString(const std::string& expr) { void PromelaDataModel::assign(const Element<std::string>& assignElem, const Node<std::string>& node, const std::string& content) { - std::string expr; std::string key; std::string value; @@ -299,32 +298,18 @@ void PromelaDataModel::assign(const Element<std::string>& assignElem, value = content; } - if (key.length() > 0) { - PromelaParser parser(key); - - // declaration is an array? - if (parser.ast->operands.size() > 0 && - parser.ast->operands.back()->operands.size() > 0 && - parser.ast->operands.back()->operands.back()->type == PML_VAR_ARRAY) { - evaluateDecl(parser.ast); - expr = content; - } else if (value.length() > 0) { - expr = key + " = " + value + ";"; - } else { - // declaration - expr = key + ";"; - } + if (value.length() == 0) + return; + + Data json = Data::fromJSON(value); + if (!json.empty()) { + // simply assign from json to key + assign(key, json); } else { - expr = content; - } - - PromelaParser parser(expr, 2, PromelaParser::PROMELA_DECL, PromelaParser::PROMELA_STMNT); - if (parser.type == PromelaParser::PROMELA_DECL) - evaluateDecl(parser.ast); - if (parser.type == PromelaParser::PROMELA_STMNT) + std::string expr = key + " = " + value; + PromelaParser parser(expr, 1, PromelaParser::PROMELA_STMNT); evaluateStmnt(parser.ast); -// parser.dump(); -// std::cout << Data::toJSON(_variables) << std::endl; + } } void PromelaDataModel::evaluateDecl(const std::string& expr) { @@ -510,9 +495,9 @@ Data PromelaDataModel::evaluateExpr(void* ast) { PromelaParserNode* lhs = *opIter++; PromelaParserNode* rhs = *opIter++; - std::cout << "-----" << std::endl; - lhs->dump(); - rhs->dump(); +// std::cout << "-----" << std::endl; +// lhs->dump(); +// rhs->dump(); Data left = evaluateExpr(lhs); Data right = evaluateExpr(rhs); @@ -548,7 +533,18 @@ void PromelaDataModel::evaluateStmnt(void* ast) { } break; } + case PML_INCR: { + PromelaParserNode* name = *opIter++; + setVariable(name, strTo<long>(getVariable(name)) + 1); + break; + } + case PML_DECR: { + PromelaParserNode* name = *opIter++; + setVariable(name, strTo<long>(getVariable(name)) - 1); + break; + } default: + node->dump(); ERROR_EXECUTION_THROW("No support for " + PromelaParserNode::typeToDesc(node->type) + " statement implemented"); } } @@ -714,7 +710,6 @@ void PromelaDataModel::init(const Element<std::string>& dataElem, const std::string& content) { // from <datamodel> if (HAS_ATTR(dataElem, "id")) { - Element<std::string> dataElemCopy = dataElem; std::string identifier = ATTR(dataElem, "id"); std::string type = (HAS_ATTR(dataElem, "type") ? ATTR(dataElem, "type") : "int"); std::string arrSize; @@ -725,14 +720,11 @@ void PromelaDataModel::init(const Element<std::string>& dataElem, type = type.substr(0, bracketPos); } - dataElemCopy.setAttribute("id", type + " " + identifier + arrSize); - - assign(dataElemCopy, node, content); - dataElemCopy.setAttribute("id", identifier); - - return; + std::string expr = type + " " + identifier + arrSize; + PromelaParser parser(expr, 1, PromelaParser::PROMELA_DECL); + evaluateDecl(parser.ast); + } - assign(dataElem, node, content); } void PromelaDataModel::init(const std::string& location, const Data& data) { |