diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-10-12 11:11:06 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-10-12 11:11:06 (GMT) |
commit | fa90b5749693d9f5817ad1f106334a0877171fd3 (patch) | |
tree | 8d53b5c820590cad54893bc575ef55df38f55d23 /src/uscxml/plugins/datamodel/promela | |
parent | c36b123a60278caef5d06e8a7d0b3d338d669c75 (diff) | |
download | uscxml-fa90b5749693d9f5817ad1f106334a0877171fd3.zip uscxml-fa90b5749693d9f5817ad1f106334a0877171fd3.tar.gz uscxml-fa90b5749693d9f5817ad1f106334a0877171fd3.tar.bz2 |
Major work on PROMELA datamodel
Diffstat (limited to 'src/uscxml/plugins/datamodel/promela')
9 files changed, 1069 insertions, 587 deletions
diff --git a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp index f83d0c8..d63c354 100644 --- a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp +++ b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp @@ -34,6 +34,12 @@ #include <Pluma/Connector.hpp> #endif +#define INVALID_ASSIGNMENT(name) \ +name.compare("_sessionid") == 0 || \ +name.compare("_name") == 0 || \ +name.compare("_ioprocessors") == 0 || \ +name.compare("_event") == 0 + namespace uscxml { using namespace Arabica::XPath; @@ -56,6 +62,29 @@ PromelaDataModel::~PromelaDataModel() { boost::shared_ptr<DataModelImpl> PromelaDataModel::create(InterpreterImpl* interpreter) { boost::shared_ptr<PromelaDataModel> dm = boost::shared_ptr<PromelaDataModel>(new PromelaDataModel()); dm->_interpreter = interpreter; + + // session id + Data sessionId; + sessionId.compound["type"] = Data("string", Data::VERBATIM); + sessionId.compound["value"] = Data(interpreter->getSessionId(), Data::VERBATIM); + dm->_variables["_sessionid"] = sessionId; + + // name + Data name; + name.compound["type"] = Data("string", Data::VERBATIM); + name.compound["value"] = Data(interpreter->getName(), Data::VERBATIM); + dm->_variables["_name"] = name; + + // ioprocessors + Data ioProcs; + ioProcs.compound["type"] = Data("compound", Data::VERBATIM); + + std::map<std::string, IOProcessor> ioProcessors = interpreter->getIOProcessors(); + for (std::map<std::string, IOProcessor>::iterator iter = ioProcessors.begin(); iter != ioProcessors.end(); iter++) { + ioProcs.compound["value"].compound[iter->first] = iter->second.getDataModelVariables(); + } + dm->_variables["_ioprocessors"] = ioProcs; + dm->_lastMType = 0; return dm; } @@ -63,14 +92,6 @@ boost::shared_ptr<DataModelImpl> PromelaDataModel::create(InterpreterImpl* inter void PromelaDataModel::registerIOProcessor(const std::string& name, const IOProcessor& ioprocessor) { } -void PromelaDataModel::setSessionId(const std::string& sessionId) { - _sessionId = sessionId; -} - -void PromelaDataModel::setName(const std::string& name) { - _name = name; -} - void PromelaDataModel::pushContext() { // std::cout << "PromelaDataModel::pushContext" << std::endl; } @@ -79,17 +100,105 @@ void PromelaDataModel::popContext() { // std::cout << "PromelaDataModel::popContext" << std::endl; } -void PromelaDataModel::initialize() { -// std::cout << "PromelaDataModel::initialize" << std::endl; +void PromelaDataModel::setEvent(const Event& event) { + Data variable; + variable.compound["type"] = Data("compound", Data::VERBATIM); + variable.compound["value"].compound["name"] = Data(event.name, Data::VERBATIM); + variable.compound["value"].compound["origin"] = Data(event.origin, Data::VERBATIM); + variable.compound["value"].compound["origintype"] = Data(event.origintype, Data::VERBATIM); + variable.compound["value"].compound["invokeid"] = Data(event.invokeid, Data::VERBATIM); + if (event.hideSendId) { + variable.compound["value"].compound["sendid"] = Data("", Data::VERBATIM); + } else { + variable.compound["value"].compound["sendid"] = Data(event.sendid, Data::VERBATIM); + } + switch (event.eventType) { + case Event::PLATFORM: + variable.compound["value"].compound["type"] = Data("platform", Data::VERBATIM); + break; + case Event::INTERNAL: + variable.compound["value"].compound["type"] = Data("internal", Data::VERBATIM); + break; + case Event::EXTERNAL: + variable.compound["value"].compound["type"] = Data("external", Data::VERBATIM); + break; + default: + variable.compound["value"].compound["type"] = Data("invalid", Data::VERBATIM); + break; + } + + if (event.dom) { + // no support + } else if (event.content.length() > 0) { + // _event.data is a string or JSON + Data json = Data::fromJSON(event.content); + if (!json.empty()) { + variable.compound["value"].compound["data"] = json; + } else { + if (isNumeric(event.content.c_str(), 10)) { + variable.compound["value"].compound["data"] = Data(event.content, Data::INTERPRETED); + } else { + variable.compound["value"].compound["data"] = Data(InterpreterImpl::spaceNormalize(event.content), Data::VERBATIM); + } + } + } else { + // _event.data is KVP + if (!event.data.empty()) { + variable.compound["value"].compound["data"] = event.data; + } else { + // test 343 / test 488 + variable.compound["value"].compound["data"]; + } + + for (Event::params_t::const_iterator start = event.params.begin(), end = event.params.end(); + start != end; start = event.params.upper_bound(start->first)) { + // only set first param key + if (isNumeric(start->second.atom.c_str(), 10)) { + variable.compound["value"].compound["data"].compound[start->first] = strTo<int>(start->second.atom); + } else { + variable.compound["value"].compound["data"].compound[start->first] = start->second; + } + } + + for (Event::namelist_t::const_iterator iter = event.namelist.begin(); iter != event.namelist.end(); iter++) { + if (isNumeric(iter->second.atom.c_str(), 10)) { + variable.compound["value"].compound["data"].compound[iter->first] = strTo<int>(iter->second.atom); + } else { + variable.compound["value"].compound["data"].compound[iter->first] = iter->second; + } + } + } + + // iterate all data elements and adapt type for int if atom is integer + adaptType(variable.compound["value"].compound["data"]); + + _variables["_event"] = variable; } -void PromelaDataModel::setEvent(const Event& event) { - _event = event; +void PromelaDataModel::adaptType(Data& data) { + if (data.atom.length() > 0 && isInteger(data.atom.c_str(), 10)) { + data.type = Data::INTERPRETED; + return; + } + + if (data.array.size() > 0) { + for (std::list<Data>::iterator iter = data.array.begin(); iter != data.array.end(); iter++) { + adaptType(*iter); + } + return; + } + + if (data.compound.size() > 0) { + for (std::map<std::string, Data>::iterator iter = data.compound.begin(); iter != data.compound.end(); iter++) { + adaptType(iter->second); + } + return; + } + } Data PromelaDataModel::getStringAsData(const std::string& content) { - Data data(content, Data::VERBATIM); - return data; + return evaluateExpr(content); } @@ -122,20 +231,23 @@ void PromelaDataModel::setForeach(const std::string& item, std::stringstream ss; ss << array << "[" << iteration << "]"; - PromelaParser itemParser(item, PromelaParser::PROMELA_EXPR); - PromelaParser arrayParser(ss.str(), PromelaParser::PROMELA_EXPR); + PromelaParser itemParser(item, 1, PromelaParser::PROMELA_EXPR); + if (itemParser.ast->type != PML_NAME) + ERROR_EXECUTION_THROW("Expression '" + item + "' is no valid item"); + + PromelaParser arrayParser(ss.str(), 1, PromelaParser::PROMELA_EXPR); setVariable(itemParser.ast, getVariable(arrayParser.ast)); if (index.length() > 0) { - PromelaParser indexParser(index, PromelaParser::PROMELA_EXPR); + PromelaParser indexParser(index, 1, PromelaParser::PROMELA_EXPR); setVariable(indexParser.ast, iteration); } } void PromelaDataModel::eval(const Element<std::string>& scriptElem, const std::string& expr) { - PromelaParser parser(expr, PromelaParser::PROMELA_STMNT); + PromelaParser parser(expr, 1, PromelaParser::PROMELA_STMNT); evaluateStmnt(parser.ast); // parser.dump(); } @@ -145,27 +257,91 @@ bool PromelaDataModel::evalAsBool(const std::string& expr) { } bool PromelaDataModel::evalAsBool(const Arabica::DOM::Element<std::string>& node, const std::string& expr) { - PromelaParser parser(expr, PromelaParser::PROMELA_EXPR); + PromelaParser parser(expr, 1, PromelaParser::PROMELA_EXPR); // parser.dump(); - return evaluateExpr(parser.ast) > 0; + Data tmp = evaluateExpr(parser.ast); + + if (tmp.atom.compare("false") == 0) + return false; + if (tmp.atom.compare("0") == 0) + return false; + return true; } std::string PromelaDataModel::evalAsString(const std::string& expr) { - if (isDeclared(expr)) { - return Data::toJSON(_variables[expr]); - } - return expr; + PromelaParser parser(expr); + return evaluateExpr(parser.ast); } void PromelaDataModel::assign(const Element<std::string>& assignElem, const Node<std::string>& node, const std::string& content) { - PromelaParser parser(content, PromelaParser::PROMELA_DECL); - evaluateDecl(parser.ast); + std::string expr; + std::string key; + std::string value; + + if (node) { + ERROR_EXECUTION_THROW("Assigning DOM node to variable is not supported"); + } + + if (HAS_ATTR(assignElem, "id")) { + key = ATTR(assignElem, "id"); + } else if (HAS_ATTR(assignElem, "location")) { + key = ATTR(assignElem, "location"); + } + + if (HAS_ATTR(assignElem, "expr")) { + if (key.length() == 0) { + ERROR_EXECUTION_THROW("Assign element has neither id nor location"); + } + value = ATTR(assignElem, "expr"); + } else { + 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 + ";"; + } + } 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) + evaluateStmnt(parser.ast); // parser.dump(); // std::cout << Data::toJSON(_variables) << std::endl; } +void PromelaDataModel::evaluateDecl(const std::string& expr) { + PromelaParser parser(expr, 1, PromelaParser::PROMELA_DECL); + evaluateDecl(parser.ast); +} + +Data PromelaDataModel::evaluateExpr(const std::string& expr) { + PromelaParser parser(expr, 1, PromelaParser::PROMELA_EXPR); + return evaluateExpr(parser.ast); +} + +void PromelaDataModel::evaluateStmnt(const std::string& expr) { + PromelaParser parser(expr, 1, PromelaParser::PROMELA_STMNT); + evaluateStmnt(parser.ast); +} + void PromelaDataModel::evaluateDecl(void* ast) { PromelaParserNode* node = (PromelaParserNode*)ast; if (false) { @@ -209,7 +385,7 @@ void PromelaDataModel::evaluateDecl(void* ast) { std::list<PromelaParserNode*>::iterator opIterAsgn = (*nameIter)->operands.begin(); PromelaParserNode* name = *opIterAsgn++; - int size = evaluateExpr(*opIterAsgn++); + int size = dataToInt(evaluateExpr(*opIterAsgn++)); variable.compound["size"] = size; for (int i = 0; i < size; i++) { @@ -235,43 +411,115 @@ void PromelaDataModel::evaluateDecl(void* ast) { } } -int PromelaDataModel::evaluateExpr(void* ast) { +int PromelaDataModel::dataToInt(const Data& data) { + if (data.type != Data::INTERPRETED) + ERROR_EXECUTION_THROW("Operand is not integer"); + int value = strTo<int>(data.atom); + if (data.atom.compare(toStr(value)) != 0) + ERROR_EXECUTION_THROW("Operand is not integer"); + return value; +} + +bool PromelaDataModel::dataToBool(const Data& data) { + if (data.atom.size() == 0) // empty string or undefined + return false; + + if (data.type == Data::VERBATIM) { + // non-empty string is true + return true; + } else { + if (data.atom.compare("true") == 0) { + // boolean true is true + return true; + } else if (data.atom.compare("false") == 0) { + return false; + } else if (dataToInt(data) != 0) { + return true; // non zero values are true + } + } + return false; +} + +Data PromelaDataModel::evaluateExpr(void* ast) { PromelaParserNode* node = (PromelaParserNode*)ast; std::list<PromelaParserNode*>::iterator opIter = node->operands.begin(); switch (node->type) { case PML_CONST: + if (iequals(node->value, "false")) + return Data(false); + if (iequals(node->value, "true")) + return Data(true); return strTo<int>(node->value); case PML_NAME: case PML_VAR_ARRAY: + case PML_CMPND: return getVariable(node); + case PML_STRING: { + std::string stripped = node->value.substr(1, node->value.size() - 2); + return Data(stripped, Data::VERBATIM); + } case PML_PLUS: - return evaluateExpr(*opIter++) + evaluateExpr(*opIter++); + return dataToInt(evaluateExpr(*opIter++)) + dataToInt(evaluateExpr(*opIter++)); case PML_MINUS: - return evaluateExpr(*opIter++) - evaluateExpr(*opIter++); + return dataToInt(evaluateExpr(*opIter++)) - dataToInt(evaluateExpr(*opIter++)); case PML_DIVIDE: - return evaluateExpr(*opIter++) / evaluateExpr(*opIter++); + return dataToInt(evaluateExpr(*opIter++)) / dataToInt(evaluateExpr(*opIter++)); case PML_MODULO: - return evaluateExpr(*opIter++) % evaluateExpr(*opIter++); - case PML_EQ: - return evaluateExpr(*opIter++) == evaluateExpr(*opIter++); + return dataToInt(evaluateExpr(*opIter++)) % dataToInt(evaluateExpr(*opIter++)); + case PML_EQ: { + PromelaParserNode* lhs = *opIter++; + PromelaParserNode* rhs = *opIter++; + + Data left = evaluateExpr(lhs); + Data right = evaluateExpr(rhs); + + if (left == right) // overloaded operator== + return Data(true); + + // literal strings or strings in variables + if ((lhs->type == PML_STRING || rhs->type == PML_STRING) + || (left.type == Data::VERBATIM && right.type == Data::VERBATIM)) { + return (left.atom.compare(right.atom) == 0 ? Data(true) : Data(false)); + } + return dataToInt(left) == dataToInt(right); + } + case PML_NEG: + return !dataToBool(evaluateExpr(*opIter++)); case PML_LT: - return evaluateExpr(*opIter++) < evaluateExpr(*opIter++); + return dataToInt(evaluateExpr(*opIter++)) < dataToInt(evaluateExpr(*opIter++)); case PML_LE: - return evaluateExpr(*opIter++) <= evaluateExpr(*opIter++); + return dataToInt(evaluateExpr(*opIter++)) <= dataToInt(evaluateExpr(*opIter++)); case PML_GT: - return evaluateExpr(*opIter++) > evaluateExpr(*opIter++); + return dataToInt(evaluateExpr(*opIter++)) > dataToInt(evaluateExpr(*opIter++)); case PML_GE: - return evaluateExpr(*opIter++) >= evaluateExpr(*opIter++); + return dataToInt(evaluateExpr(*opIter++)) >= dataToInt(evaluateExpr(*opIter++)); case PML_TIMES: - return evaluateExpr(*opIter++) * evaluateExpr(*opIter++); + return dataToInt(evaluateExpr(*opIter++)) * dataToInt(evaluateExpr(*opIter++)); case PML_LSHIFT: - return evaluateExpr(*opIter++) << evaluateExpr(*opIter++); + return dataToInt(evaluateExpr(*opIter++)) << dataToInt(evaluateExpr(*opIter++)); case PML_RSHIFT: - return evaluateExpr(*opIter++) >> evaluateExpr(*opIter++); + return dataToInt(evaluateExpr(*opIter++)) >> dataToInt(evaluateExpr(*opIter++)); case PML_AND: - return evaluateExpr(*opIter++) != 0 && evaluateExpr(*opIter++) != 0; - case PML_OR: - return evaluateExpr(*opIter++) != 0 || evaluateExpr(*opIter++) != 0; + case PML_OR: { + PromelaParserNode* lhs = *opIter++; + PromelaParserNode* rhs = *opIter++; + + std::cout << "-----" << std::endl; + lhs->dump(); + rhs->dump(); + + Data left = evaluateExpr(lhs); + Data right = evaluateExpr(rhs); + + bool truthLeft = dataToBool(left); + bool truthRight = dataToBool(right); + + if (node->type == PML_AND) { + return truthLeft && truthRight; + } else { + return truthLeft || truthRight; + } + } default: ERROR_EXECUTION_THROW("Support for " + PromelaParserNode::typeToDesc(node->type) + " expressions not implemented"); } @@ -299,7 +547,7 @@ void PromelaDataModel::evaluateStmnt(void* ast) { } } -void PromelaDataModel::setVariable(void* ast, int value) { +void PromelaDataModel::setVariable(void* ast, Data value) { PromelaParserNode* node = (PromelaParserNode*)ast; std::list<PromelaParserNode*>::iterator opIter = node->operands.begin(); @@ -307,7 +555,12 @@ void PromelaDataModel::setVariable(void* ast, int value) { case PML_VAR_ARRAY: { PromelaParserNode* name = *opIter++; PromelaParserNode* expr = *opIter++; - int index = evaluateExpr(expr); + + if (INVALID_ASSIGNMENT(name->value)) { + ERROR_EXECUTION_THROW("Cannot assign to " + name->value); + } + + int index = dataToInt(evaluateExpr(expr)); if (_variables.compound.find(name->value) == _variables.compound.end()) { ERROR_EXECUTION_THROW("No variable " + name->value + " was declared"); @@ -321,12 +574,15 @@ void PromelaDataModel::setVariable(void* ast, int value) { ERROR_EXECUTION_THROW("Index " + toStr(index) + " in array " + name->value + "[" + _variables[name->value]["size"].atom + "] is out of bounds"); } - _variables.compound[name->value].compound["value"][index] = Data(value, Data::VERBATIM); + _variables.compound[name->value].compound["value"][index] = value; break; } case PML_NAME: - _variables.compound[node->value].compound["value"] = Data(value, Data::VERBATIM); + if (INVALID_ASSIGNMENT(node->value)) { + ERROR_EXECUTION_THROW("Cannot assign to " + node->value); + } + _variables.compound[node->value].compound["value"] = value; break; default: break; @@ -335,7 +591,7 @@ void PromelaDataModel::setVariable(void* ast, int value) { // std::cout << Data::toJSON(_variables) << std::endl; } -int PromelaDataModel::getVariable(void* ast) { +Data PromelaDataModel::getVariable(void* ast) { PromelaParserNode* node = (PromelaParserNode*)ast; // node->dump(); @@ -345,14 +601,14 @@ int PromelaDataModel::getVariable(void* ast) { if (_variables.compound.find(node->value) == _variables.compound.end()) { ERROR_EXECUTION_THROW("No variable " + node->value + " was declared"); } - if (_variables[node->value].compound.find("size") != _variables[node->value].compound.end()) { - ERROR_EXECUTION_THROW("Type error: Variable " + node->value + " is an array"); - } - return strTo<int>(_variables[node->value]["value"].atom); +// if (_variables[node->value].compound.find("size") != _variables[node->value].compound.end()) { +// ERROR_EXECUTION_THROW("Type error: Variable " + node->value + " is an array"); +// } + return _variables[node->value]["value"]; case PML_VAR_ARRAY: { PromelaParserNode* name = *opIter++; PromelaParserNode* expr = *opIter++; - int index = evaluateExpr(expr); + int index = dataToInt(evaluateExpr(expr)); if (_variables.compound.find(name->value) == _variables.compound.end()) { ERROR_EXECUTION_THROW("No variable " + name->value + " was declared"); @@ -365,7 +621,54 @@ int PromelaDataModel::getVariable(void* ast) { if (strTo<int>(_variables[name->value]["size"].atom) <= index) { ERROR_EXECUTION_THROW("Index " + toStr(index) + " in array " + name->value + "[" + _variables[name->value]["size"].atom + "] is out of bounds"); } - return strTo<int>(_variables.compound[name->value].compound["value"][index].atom); + return _variables.compound[name->value].compound["value"][index]; + } + case PML_CMPND: { +// node->dump(); +// std::cout << Data::toJSON(_variables["_event"]); + + std::stringstream idPath; + PromelaParserNode* name = *opIter++; + + // special case for _x variables + if (name->value.compare("_x") == 0) { + PromelaParserNode* what = *opIter++; + + if (what->type == PML_VAR_ARRAY) { + if (what->operands.size() == 2) { + std::string arrName = what->operands.front()->value; + std::string index = what->operands.back()->value; + + if (what->operands.back()->type == PML_STRING) { + index = index.substr(1, index.size() - 2); // remove quotes + } + + if (arrName.compare("states") == 0) { + return Data(_interpreter->isInState(index)); + } + } + } + ERROR_EXECUTION_THROW("No variable " + name->value + " was declared"); + } + + if (_variables.compound.find(name->value) == _variables.compound.end()) { + ERROR_EXECUTION_THROW("No variable " + name->value + " was declared"); + } + + Data currData = _variables.compound[name->value]["value"]; + idPath << name->value; + while(opIter != node->operands.end()) { + std::string key = (*opIter)->value; + idPath << "." << key; + if (currData.compound.find(key) == currData.compound.end()) { + ERROR_EXECUTION_THROW("No variable " + idPath.str() + " was declared"); + } + Data tmp = currData.compound[key]; + currData = tmp; + + opIter++; + } + return currData; } default: ERROR_EXECUTION_THROW("Retrieving value of " + PromelaParserNode::typeToDesc(node->type) + " variable not implemented"); @@ -395,14 +698,35 @@ std::string PromelaDataModel::andExpressions(std::list<std::string> expressions) } void PromelaDataModel::assign(const std::string& location, const Data& data) { - // used for e.g. to assign command line parameters - std::cout << "Ignoring " << location << " = " << Data::toJSON(data) << std::endl; + // used for e.g. to assign command line parameters and idlocation + PromelaParser parser(location); + setVariable(parser.ast, data); } void PromelaDataModel::init(const Element<std::string>& dataElem, const Node<std::string>& node, 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; + + size_t bracketPos = type.find("["); + if (bracketPos != std::string::npos) { + arrSize = type.substr(bracketPos, type.length() - bracketPos); + type = type.substr(0, bracketPos); + } + + dataElemCopy.setAttribute("id", type + " " + identifier + arrSize); + + assign(dataElemCopy, node, content); + dataElemCopy.setAttribute("id", identifier); + + return; + } + assign(dataElem, node, content); } void PromelaDataModel::init(const std::string& location, const Data& data) { @@ -410,6 +734,10 @@ void PromelaDataModel::init(const std::string& location, const Data& data) { } bool PromelaDataModel::isDeclared(const std::string& expr) { + PromelaParser parser(expr); + if (parser.ast->type == PML_VAR_ARRAY) + return _variables.compound.find(parser.ast->operands.front()->value) != _variables.compound.end(); + return _variables.compound.find(expr) != _variables.compound.end(); } diff --git a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h index 89078bd..b286f4b 100644 --- a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h +++ b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h @@ -41,9 +41,6 @@ public: return names; } - virtual void initialize(); - virtual void setSessionId(const std::string& sessionId); - virtual void setName(const std::string& name); virtual void setEvent(const Event& event); virtual void registerIOProcessor(const std::string& name, const IOProcessor& ioprocessor); @@ -85,12 +82,21 @@ public: protected: + int dataToInt(const Data& data); + bool dataToBool(const Data& data); + void evaluateDecl(void* ast); - int evaluateExpr(void* ast); + Data evaluateExpr(void* ast); void evaluateStmnt(void* ast); - void setVariable(void* ast, int value); - int getVariable(void* ast); + void evaluateDecl(const std::string& expr); + Data evaluateExpr(const std::string& expr); + void evaluateStmnt(const std::string& expr); + + void setVariable(void* ast, Data value); + Data getVariable(void* ast); + + void adaptType(Data& data); int _lastMType; diff --git a/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp b/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp index d12b7fc..9fed02c 100644 --- a/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp +++ b/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp @@ -46,17 +46,32 @@ PromelaParser::PromelaParser(const std::string& expr) { init(expr); } -PromelaParser::PromelaParser(const std::string& expr, Type expectedType) { +PromelaParser::PromelaParser(const std::string& expr, int nrArgs, ...) { init(expr); - if (type != expectedType) { - std::stringstream ss; - ss << "Promela syntax type mismatch: Expected " << typeToDesc(expectedType) << " but got " << typeToDesc(type); - ERROR_EXECUTION_THROW(ss.str()); + + if (nrArgs == 0) + return; + + std::stringstream errSS; + std::string seperator; + errSS << "Promela syntax type mismatch: Expected {"; + + va_list ap; + va_start(ap, nrArgs); + for(int i = 1; i <= nrArgs; i++) { + int expectedType = va_arg(ap, int); + if (type == expectedType) + return; + errSS << seperator << typeToDesc(expectedType); + seperator = ", "; } + errSS << "} but got " << typeToDesc(type); + ERROR_EXECUTION_THROW(errSS.str()); } void PromelaParser::init(const std::string& expr) { ast = NULL; + parseInCompound = 0; input_length = expr.length() + 2; // plus some zero terminators input = (char*) calloc(1, input_length); memcpy(input, expr.c_str(), expr.length()); @@ -69,6 +84,7 @@ void PromelaParser::init(const std::string& expr) { if (pendingException.name.size() > 0) { // parsing failed in promela_error destroy(); + pendingException.data.compound["code"] = Data(expr, Data::VERBATIM); throw pendingException; } } @@ -234,6 +250,14 @@ std::string PromelaParserNode::typeToDesc(int type) { return "DECLLIST"; case PML_NAMELIST: return "NAMELIST"; + case PML_STRING: + return "STRING"; + case PML_TYPEDEF: + return "TYPEDEF"; + case PML_CMPND: + return "CMPND"; + case PML_ASSERT: + return "ASSERT"; default: return std::string("UNK(") + toStr(type) + ")"; diff --git a/src/uscxml/plugins/datamodel/promela/PromelaParser.h b/src/uscxml/plugins/datamodel/promela/PromelaParser.h index 5cf4483..6cf9a81 100644 --- a/src/uscxml/plugins/datamodel/promela/PromelaParser.h +++ b/src/uscxml/plugins/datamodel/promela/PromelaParser.h @@ -17,14 +17,14 @@ * @endcond */ -// bison -v -d promela-expr.ypp && flex promela-expr.l -// bison promela-expr.ypp && flex promela-expr.l +// bison -v promela.ypp && flex promela.l #ifndef PROMELA_H_9AB78YB1 #define PROMELA_H_9AB78YB1 #include <stdlib.h> -#include <stdarg.h> +//#include <stdarg.h> +#include <cstdarg> #include "uscxml/Message.h" @@ -59,13 +59,14 @@ public: static std::string typeToDesc(int type); PromelaParser(const std::string& expr); - PromelaParser(const std::string& expr, Type expectedType); + PromelaParser(const std::string& expr, int nrArgs, ...); virtual ~PromelaParser(); virtual PromelaParserNode* node(int type, int nrArgs, ...); virtual PromelaParserNode* value(int type, const char* value); void dump(); + int parseInCompound; PromelaParserNode* ast; Type type; diff --git a/src/uscxml/plugins/datamodel/promela/parser/promela.l b/src/uscxml/plugins/datamodel/promela/parser/promela.l index 2aaef06..faa134c 100644 --- a/src/uscxml/plugins/datamodel/promela/parser/promela.l +++ b/src/uscxml/plugins/datamodel/promela/parser/promela.l @@ -24,7 +24,9 @@ L [a-zA-Z_] %% -bit|bool|byte|int|mtype|short|unsigned { +\/\*([^*]|\*[^/])*\*+\/ /* multiline comments */ + +bit|bool|byte|int|mtype|short|unsigned|string { yylval->value = strdup(yytext); return PML_TYPE; } @@ -33,6 +35,8 @@ len { return PML_LEN; } false|skip|true { yylval->value = strdup(yytext); return PML_CONST; } printf { return PML_PRINT; } printm { return PML_PRINTM; } +typedef { return PML_TYPEDEF; } +assert { return PML_ASSERT; } "!" { return PML_NEG; } "~" { return PML_COMPL; } @@ -80,13 +84,18 @@ printm { return PML_PRINTM; } "=" { return PML_ASGN; } -L?\"(\\.|[^\\"])*\" { yylval->value = strdup(yytext); return(PML_STRING); } +L?\"(\\.|[^\\"])*\" { yylval->value = strdup(yytext); return(PML_STRING); } + + +L?'(\\.|[^\'])*\' { + /* Non PROMELA extension for single quoted string literals */ + yylval->value = strdup(yytext); return(PML_STRING); +} {DIGIT}+ { yylval->value = strdup(yytext); return PML_CONST; } {ID} { yylval->value = strdup(yytext); return PML_NAME; } -\'(\\.|[^'])*\' { } +[ \t\n]+ /* eat up whitespace */ -[ \t\n]+ /* eat up whitespace */ . { /*printf( "Unrecognized character: %s\n", yytext ); */ } diff --git a/src/uscxml/plugins/datamodel/promela/parser/promela.lex.yy.cpp b/src/uscxml/plugins/datamodel/promela/parser/promela.lex.yy.cpp index 5073be3..13085dc 100644 --- a/src/uscxml/plugins/datamodel/promela/parser/promela.lex.yy.cpp +++ b/src/uscxml/plugins/datamodel/promela/parser/promela.lex.yy.cpp @@ -433,28 +433,30 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); yyg->yy_c_buf_p = yy_cp; /* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */ -#define YY_NUM_RULES 44 -#define YY_END_OF_BUFFER 45 +#define YY_NUM_RULES 47 +#define YY_END_OF_BUFFER 48 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info { flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[102] = { +static yyconst flex_int16_t yy_accept[125] = { 0, - 0, 0, 45, 43, 42, 42, 6, 43, 12, 23, - 43, 31, 32, 10, 13, 29, 14, 28, 11, 39, - 30, 19, 37, 20, 40, 40, 33, 34, 24, 40, - 40, 40, 40, 40, 40, 40, 40, 40, 35, 25, - 36, 7, 42, 21, 0, 38, 0, 26, 0, 41, - 0, 8, 9, 39, 15, 17, 22, 18, 16, 40, - 0, 40, 40, 40, 40, 40, 40, 40, 40, 40, - 40, 40, 40, 27, 0, 41, 0, 1, 40, 40, - 40, 2, 40, 40, 40, 40, 40, 40, 40, 40, - 40, 40, 3, 40, 40, 40, 4, 5, 40, 40, - - 0 + 0, 0, 48, 46, 45, 45, 9, 46, 15, 26, + 46, 34, 35, 13, 16, 32, 17, 31, 14, 43, + 33, 22, 40, 23, 44, 44, 36, 37, 27, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 38, + 28, 39, 10, 45, 24, 0, 41, 0, 29, 0, + 42, 0, 11, 12, 0, 43, 18, 20, 25, 21, + 19, 44, 0, 0, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 30, + 0, 42, 0, 0, 0, 44, 2, 44, 44, 44, + 3, 44, 44, 44, 44, 44, 44, 44, 44, 0, + + 1, 44, 44, 44, 44, 44, 4, 44, 44, 44, + 1, 44, 44, 44, 44, 44, 8, 5, 6, 44, + 44, 7, 44, 0 } ; static yyconst flex_int32_t yy_ec[256] = { @@ -498,65 +500,72 @@ static yyconst flex_int32_t yy_meta[51] = { 2, 2, 2, 2, 2, 2, 1, 1, 1, 1 } ; -static yyconst flex_int16_t yy_base[106] = { +static yyconst flex_int16_t yy_base[130] = { 0, - 0, 0, 141, 142, 49, 51, 120, 50, 142, 132, - 48, 142, 142, 142, 126, 142, 123, 142, 142, 119, - 142, 38, 115, 39, 0, 129, 142, 142, 142, 26, - 105, 93, 100, 86, 87, 28, 86, 88, 142, 78, - 142, 142, 65, 142, 58, 142, 122, 142, 57, 142, - 66, 142, 142, 107, 142, 142, 142, 142, 142, 0, - 65, 79, 82, 77, 83, 75, 79, 71, 81, 75, - 79, 68, 69, 142, 63, 68, 76, 0, 74, 79, - 66, 0, 67, 61, 57, 57, 66, 61, 64, 63, - 48, 45, 0, 54, 48, 46, 0, 0, 50, 48, - - 142, 101, 103, 75, 105 + 0, 0, 170, 171, 49, 51, 149, 50, 171, 161, + 48, 171, 171, 171, 155, 171, 152, 171, 154, 147, + 171, 38, 143, 39, 0, 56, 171, 171, 171, 119, + 28, 133, 121, 128, 114, 115, 33, 20, 117, 171, + 107, 171, 171, 68, 171, 60, 171, 151, 171, 64, + 171, 73, 171, 171, 142, 135, 171, 171, 171, 171, + 171, 0, 74, 70, 108, 106, 109, 104, 110, 102, + 106, 98, 108, 102, 106, 98, 94, 97, 94, 171, + 72, 75, 79, 125, 75, 104, 0, 97, 102, 89, + 0, 90, 91, 87, 87, 92, 95, 94, 89, 77, + + 171, 81, 91, 90, 76, 75, 0, 79, 87, 83, + 104, 70, 52, 80, 72, 63, 0, 0, 0, 69, + 65, 0, 64, 171, 104, 106, 90, 108, 110 } ; -static yyconst flex_int16_t yy_def[106] = { +static yyconst flex_int16_t yy_def[130] = { 0, - 101, 1, 101, 101, 101, 101, 101, 102, 101, 101, - 103, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 104, 104, 101, 101, 101, 104, - 104, 104, 104, 104, 104, 104, 104, 104, 101, 101, - 101, 101, 101, 101, 102, 101, 102, 101, 103, 101, - 105, 101, 101, 101, 101, 101, 101, 101, 101, 104, - 102, 104, 104, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 101, 103, 103, 105, 104, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, - - 0, 101, 101, 101, 101 + 124, 1, 124, 124, 124, 124, 124, 125, 124, 124, + 126, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 127, 127, 124, 124, 124, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 124, + 124, 124, 124, 124, 124, 125, 124, 125, 124, 126, + 124, 128, 124, 124, 129, 124, 124, 124, 124, 124, + 124, 127, 125, 126, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 124, + 126, 126, 128, 129, 129, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 129, + + 124, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 129, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 0, 124, 124, 124, 124, 124 } ; -static yyconst flex_int16_t yy_nxt[193] = { +static yyconst flex_int16_t yy_nxt[222] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 4, 28, 29, 25, 30, 25, - 25, 31, 25, 25, 32, 25, 33, 34, 25, 25, - 35, 25, 36, 37, 38, 25, 39, 40, 41, 42, - 43, 43, 43, 43, 46, 50, 55, 56, 58, 59, - 62, 70, 46, 71, 50, 63, 43, 43, 49, 46, - 50, 64, 51, 76, 47, 50, 60, 78, 49, 97, - 100, 51, 47, 76, 99, 98, 96, 51, 78, 47, - 77, 95, 51, 78, 93, 94, 93, 93, 92, 91, - - 77, 45, 45, 49, 49, 75, 75, 90, 89, 78, - 78, 88, 87, 86, 85, 84, 83, 82, 78, 81, - 80, 79, 78, 54, 101, 74, 73, 72, 69, 68, - 67, 66, 65, 61, 57, 54, 53, 52, 48, 44, - 101, 3, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101 - + 24, 25, 26, 27, 4, 28, 29, 30, 31, 25, + 25, 32, 25, 25, 33, 25, 34, 35, 25, 25, + 36, 25, 37, 38, 39, 25, 40, 41, 42, 43, + 44, 44, 44, 44, 47, 51, 57, 58, 60, 61, + 63, 77, 66, 64, 47, 78, 74, 67, 75, 44, + 44, 51, 52, 68, 48, 50, 76, 51, 47, 51, + 82, 50, 51, 118, 48, 100, 82, 85, 52, 119, + 101, 62, 111, 87, 52, 123, 52, 83, 48, 52, + + 122, 121, 120, 83, 46, 46, 50, 50, 81, 81, + 84, 84, 87, 117, 85, 116, 115, 114, 87, 113, + 87, 107, 112, 110, 109, 107, 108, 107, 106, 105, + 104, 103, 87, 87, 102, 85, 99, 98, 97, 96, + 95, 94, 93, 92, 91, 87, 90, 89, 88, 87, + 86, 56, 85, 124, 80, 79, 73, 72, 71, 70, + 69, 65, 59, 56, 55, 54, 53, 49, 45, 124, + 3, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124 } ; -static yyconst flex_int16_t yy_chk[193] = { +static yyconst flex_int16_t yy_chk[222] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -564,31 +573,34 @@ static yyconst flex_int16_t yy_chk[193] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 6, 6, 8, 11, 22, 22, 24, 24, - 30, 36, 45, 36, 49, 30, 43, 43, 51, 61, - 75, 30, 11, 51, 8, 76, 104, 100, 77, 95, - 99, 49, 45, 77, 96, 95, 94, 75, 92, 61, - 51, 91, 76, 90, 89, 88, 87, 86, 85, 84, - - 77, 102, 102, 103, 103, 105, 105, 83, 81, 80, - 79, 73, 72, 71, 70, 69, 68, 67, 66, 65, - 64, 63, 62, 54, 47, 40, 38, 37, 35, 34, - 33, 32, 31, 26, 23, 20, 17, 15, 10, 7, - 3, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101 - + 26, 38, 31, 26, 46, 38, 37, 31, 37, 44, + 44, 50, 11, 31, 8, 52, 37, 64, 63, 81, + 52, 83, 82, 113, 46, 85, 83, 100, 50, 113, + 85, 127, 100, 123, 64, 121, 81, 52, 63, 82, + + 120, 116, 115, 83, 125, 125, 126, 126, 128, 128, + 129, 129, 114, 112, 111, 110, 109, 108, 106, 105, + 104, 103, 102, 99, 98, 97, 96, 95, 94, 93, + 92, 90, 89, 88, 86, 84, 79, 78, 77, 76, + 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, + 65, 56, 55, 48, 41, 39, 36, 35, 34, 33, + 32, 30, 23, 20, 19, 17, 15, 10, 7, 3, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124 } ; -static yyconst flex_int16_t yy_rule_linenum[44] = { +static yyconst flex_int16_t yy_rule_linenum[47] = { 0, - 27, 32, 33, 34, 35, 37, 38, 39, 40, 42, - 43, 44, 46, 47, 49, 50, 52, 53, 54, 55, - 57, 58, 60, 61, 62, 65, 66, 68, 69, 70, - 72, 73, 75, 76, 78, 79, 81, 83, 85, 86, - 88, 90, 92 + 27, 29, 34, 35, 36, 37, 38, 39, 41, 42, + 43, 44, 46, 47, 48, 50, 51, 53, 54, 56, + 57, 58, 59, 61, 62, 64, 65, 66, 69, 70, + 72, 73, 74, 76, 77, 79, 80, 82, 83, 85, + 87, 90, 95, 96, 98, 101 } ; /* The intent behind this definition is that it'll catch @@ -608,7 +620,7 @@ static yyconst flex_int16_t yy_rule_linenum[44] = { #include "promela.tab.hpp" #define YYSTYPE PROMELA_STYPE -#line 614 "promela.lex.yy.cpp" +#line 626 "promela.lex.yy.cpp" #define INITIAL 0 @@ -907,7 +919,7 @@ YY_DECL { #line 25 "promela.l" -#line 915 "promela.lex.yy.cpp" +#line 927 "promela.lex.yy.cpp" yylval = yylval_param; @@ -967,12 +979,12 @@ yy_match: } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 102 ) + if ( yy_current_state >= 125 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; - } while ( yy_current_state != 101 ); + } while ( yy_current_state != 124 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -990,13 +1002,13 @@ do_action: /* This label is used only to access EOF actions. */ if ( yy_flex_debug ) { if ( yy_act == 0 ) fprintf( stderr, "--scanner backing up\n" ); - else if ( yy_act < 44 ) + else if ( yy_act < 47 ) fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", (long)yy_rule_linenum[yy_act], yytext ); - else if ( yy_act == 44 ) + else if ( yy_act == 47 ) fprintf( stderr, "--accepting default rule (\"%s\")\n", yytext ); - else if ( yy_act == 45 ) + else if ( yy_act == 48 ) fprintf( stderr, "--(end of buffer or a NUL)\n" ); else fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); @@ -1013,232 +1025,252 @@ do_action: /* This label is used only to access EOF actions. */ goto yy_find_action; case 1: + /* rule 1 can match eol */ YY_RULE_SETUP #line 27 "promela.l" + /* multiline comments */ + YY_BREAK + case 2: + YY_RULE_SETUP +#line 29 "promela.l" { yylval->value = strdup(yytext); return PML_TYPE; } YY_BREAK - case 2: - YY_RULE_SETUP -#line 32 "promela.l" - { return PML_LEN; } - YY_BREAK case 3: YY_RULE_SETUP -#line 33 "promela.l" - { yylval->value = strdup(yytext); return PML_CONST; } +#line 34 "promela.l" + { return PML_LEN; } YY_BREAK case 4: YY_RULE_SETUP -#line 34 "promela.l" - { return PML_PRINT; } +#line 35 "promela.l" + { yylval->value = strdup(yytext); return PML_CONST; } YY_BREAK case 5: YY_RULE_SETUP -#line 35 "promela.l" - { return PML_PRINTM; } +#line 36 "promela.l" + { return PML_PRINT; } YY_BREAK case 6: YY_RULE_SETUP #line 37 "promela.l" - { return PML_NEG; } + { return PML_PRINTM; } YY_BREAK case 7: YY_RULE_SETUP #line 38 "promela.l" - { return PML_COMPL; } + { return PML_TYPEDEF; } YY_BREAK case 8: YY_RULE_SETUP #line 39 "promela.l" - { return PML_INCR; } + { return PML_ASSERT; } YY_BREAK case 9: YY_RULE_SETUP -#line 40 "promela.l" - { return PML_DECR; } +#line 41 "promela.l" + { return PML_NEG; } YY_BREAK case 10: YY_RULE_SETUP #line 42 "promela.l" - { return PML_TIMES; } + { return PML_COMPL; } YY_BREAK case 11: YY_RULE_SETUP #line 43 "promela.l" - { return PML_DIVIDE; } + { return PML_INCR; } YY_BREAK case 12: YY_RULE_SETUP #line 44 "promela.l" - { return PML_MODULO; } + { return PML_DECR; } YY_BREAK case 13: YY_RULE_SETUP #line 46 "promela.l" - { return PML_PLUS; } + { return PML_TIMES; } YY_BREAK case 14: YY_RULE_SETUP #line 47 "promela.l" - { return PML_MINUS; } + { return PML_DIVIDE; } YY_BREAK case 15: YY_RULE_SETUP -#line 49 "promela.l" - { return PML_LSHIFT; } +#line 48 "promela.l" + { return PML_MODULO; } YY_BREAK case 16: YY_RULE_SETUP #line 50 "promela.l" - { return PML_RSHIFT; } + { return PML_PLUS; } YY_BREAK case 17: YY_RULE_SETUP -#line 52 "promela.l" - { return PML_LE; } +#line 51 "promela.l" + { return PML_MINUS; } YY_BREAK case 18: YY_RULE_SETUP #line 53 "promela.l" - { return PML_GE; } + { return PML_LSHIFT; } YY_BREAK case 19: YY_RULE_SETUP #line 54 "promela.l" - { return PML_LT; } + { return PML_RSHIFT; } YY_BREAK case 20: YY_RULE_SETUP -#line 55 "promela.l" - { return PML_GT; } +#line 56 "promela.l" + { return PML_LE; } YY_BREAK case 21: YY_RULE_SETUP #line 57 "promela.l" - { return PML_NE; } + { return PML_GE; } YY_BREAK case 22: YY_RULE_SETUP #line 58 "promela.l" - { return PML_EQ; } + { return PML_LT; } YY_BREAK case 23: YY_RULE_SETUP -#line 60 "promela.l" - { return PML_BITAND; } +#line 59 "promela.l" + { return PML_GT; } YY_BREAK case 24: YY_RULE_SETUP #line 61 "promela.l" - { return PML_BITXOR; } + { return PML_NE; } YY_BREAK case 25: YY_RULE_SETUP #line 62 "promela.l" - { return PML_BITOR; } + { return PML_EQ; } YY_BREAK case 26: YY_RULE_SETUP -#line 65 "promela.l" - { return PML_AND; } +#line 64 "promela.l" + { return PML_BITAND; } YY_BREAK case 27: YY_RULE_SETUP -#line 66 "promela.l" - { return PML_OR; } +#line 65 "promela.l" + { return PML_BITXOR; } YY_BREAK case 28: YY_RULE_SETUP -#line 68 "promela.l" - { return PML_DOT; } +#line 66 "promela.l" + { return PML_BITOR; } YY_BREAK case 29: YY_RULE_SETUP #line 69 "promela.l" - { return PML_COMMA; } + { return PML_AND; } YY_BREAK case 30: YY_RULE_SETUP #line 70 "promela.l" - { return PML_SEMI; } + { return PML_OR; } YY_BREAK case 31: YY_RULE_SETUP #line 72 "promela.l" - { return '('; } + { return PML_DOT; } YY_BREAK case 32: YY_RULE_SETUP #line 73 "promela.l" - { return ')'; } + { return PML_COMMA; } YY_BREAK case 33: YY_RULE_SETUP -#line 75 "promela.l" - { return '['; } +#line 74 "promela.l" + { return PML_SEMI; } YY_BREAK case 34: YY_RULE_SETUP #line 76 "promela.l" - { return ']'; } + { return '('; } YY_BREAK case 35: YY_RULE_SETUP -#line 78 "promela.l" - { return '{'; } +#line 77 "promela.l" + { return ')'; } YY_BREAK case 36: YY_RULE_SETUP #line 79 "promela.l" - { return '}'; } + { return '['; } YY_BREAK case 37: YY_RULE_SETUP -#line 81 "promela.l" - { return PML_ASGN; } +#line 80 "promela.l" + { return ']'; } YY_BREAK case 38: - /* rule 38 can match eol */ YY_RULE_SETUP -#line 83 "promela.l" - { yylval->value = strdup(yytext); return(PML_STRING); } +#line 82 "promela.l" + { return '{'; } YY_BREAK case 39: YY_RULE_SETUP -#line 85 "promela.l" - { yylval->value = strdup(yytext); return PML_CONST; } +#line 83 "promela.l" + { return '}'; } YY_BREAK case 40: YY_RULE_SETUP -#line 86 "promela.l" - { yylval->value = strdup(yytext); return PML_NAME; } +#line 85 "promela.l" + { return PML_ASGN; } YY_BREAK case 41: /* rule 41 can match eol */ YY_RULE_SETUP -#line 88 "promela.l" - { } +#line 87 "promela.l" + { yylval->value = strdup(yytext); return(PML_STRING); } YY_BREAK case 42: /* rule 42 can match eol */ YY_RULE_SETUP #line 90 "promela.l" - /* eat up whitespace */ + { + /* Non PROMELA extension for single quoted string literals */ + yylval->value = strdup(yytext); + return(PML_STRING); + } YY_BREAK case 43: YY_RULE_SETUP -#line 92 "promela.l" - { /*printf( "Unrecognized character: %s\n", yytext ); */ } +#line 95 "promela.l" + { yylval->value = strdup(yytext); return PML_CONST; } YY_BREAK case 44: YY_RULE_SETUP -#line 93 "promela.l" +#line 96 "promela.l" + { yylval->value = strdup(yytext); return PML_NAME; } + YY_BREAK + case 45: + /* rule 45 can match eol */ + YY_RULE_SETUP +#line 98 "promela.l" + /* eat up whitespace */ + YY_BREAK + case 46: + YY_RULE_SETUP +#line 101 "promela.l" + { /*printf( "Unrecognized character: %s\n", yytext ); */ } + YY_BREAK + case 47: + YY_RULE_SETUP +#line 102 "promela.l" ECHO; YY_BREAK -#line 1253 "promela.lex.yy.cpp" +#line 1284 "promela.lex.yy.cpp" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1535,7 +1567,7 @@ static yy_state_type yy_get_previous_state (yyscan_t yyscanner) } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 102 ) + if ( yy_current_state >= 125 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1567,11 +1599,11 @@ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_ } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 102 ) + if ( yy_current_state >= 125 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 101); + yy_is_jam = (yy_current_state == 124); return yy_is_jam ? 0 : yy_current_state; } @@ -2489,4 +2521,4 @@ void promela_free (void * ptr , yyscan_t yyscanner) { /* %ok-for-header */ -#line 93 "promela.l" +#line 102 "promela.l" diff --git a/src/uscxml/plugins/datamodel/promela/parser/promela.tab.cpp b/src/uscxml/plugins/datamodel/promela/parser/promela.tab.cpp index ad4581f..67501fa 100644 --- a/src/uscxml/plugins/datamodel/promela/parser/promela.tab.cpp +++ b/src/uscxml/plugins/datamodel/promela/parser/promela.tab.cpp @@ -202,7 +202,8 @@ enum promela_tokentype { PML_INCR = 326, PML_COMPL = 327, PML_NEG = 328, - PML_DOT = 329 + PML_CMPND = 329, + PML_DOT = 330 }; #endif @@ -217,7 +218,7 @@ typedef union PROMELA_STYPE { /* Line 387 of yacc.c */ -#line 222 "promela.tab.cpp" +#line 223 "promela.tab.cpp" } PROMELA_STYPE; # define PROMELA_STYPE_IS_TRIVIAL 1 # define promela_stype PROMELA_STYPE /* obsolescent; will be withdrawn */ @@ -244,7 +245,7 @@ int promela_parse (); /* Copy the second part of user declarations. */ /* Line 390 of yacc.c */ -#line 249 "promela.tab.cpp" +#line 250 "promela.tab.cpp" #ifdef short # undef short @@ -470,22 +471,22 @@ union yyalloc { #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 33 +#define YYFINAL 34 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 304 +#define YYLAST 311 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 81 +#define YYNTOKENS 82 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 23 /* YYNRULES -- Number of rules. */ -#define YYNRULES 83 +#define YYNRULES 85 /* YYNRULES -- Number of states. */ -#define YYNSTATES 146 +#define YYNSTATES 152 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 329 +#define YYMAXUTOK 330 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -524,67 +525,69 @@ static const yytype_uint8 yytranslate[] = { 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, 78, 79, 80 + 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 81 }; #if PROMELA_DEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const yytype_uint16 yyprhs[] = { - 0, 0, 3, 5, 7, 9, 11, 13, 18, 19, - 23, 24, 27, 31, 35, 39, 43, 47, 51, 55, - 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, - 99, 103, 106, 109, 114, 116, 118, 119, 121, 123, - 125, 129, 133, 140, 142, 145, 149, 151, 155, 157, - 161, 163, 167, 172, 174, 177, 181, 185, 189, 193, - 197, 201, 203, 206, 209, 211, 214, 218, 220, 224, - 227, 230, 236, 241, 246, 249, 251, 252, 261, 262, - 264, 265, 268, 270 + 0, 0, 3, 5, 7, 9, 11, 13, 18, 21, + 22, 25, 29, 33, 37, 41, 45, 49, 53, 57, + 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, + 101, 104, 107, 112, 114, 116, 118, 119, 121, 123, + 125, 129, 133, 140, 143, 149, 151, 154, 158, 160, + 164, 166, 170, 172, 176, 181, 183, 186, 190, 194, + 198, 202, 206, 210, 212, 215, 218, 220, 223, 227, + 229, 233, 236, 239, 245, 250, 255, 258, 260, 261, + 270, 271, 273, 274, 277, 279 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 82, 0, -1, 91, -1, 88, -1, 97, -1, 85, - -1, 48, -1, 48, 13, 88, 14, -1, -1, 84, - 86, 87, -1, -1, 80, 85, -1, 11, 88, 12, - -1, 88, 72, 88, -1, 88, 71, 88, -1, 88, - 75, 88, -1, 88, 74, 88, -1, 88, 73, 88, - -1, 88, 60, 88, -1, 88, 61, 88, -1, 88, - 62, 88, -1, 88, 68, 88, -1, 88, 67, 88, - -1, 88, 66, 88, -1, 88, 65, 88, -1, 88, - 64, 88, -1, 88, 63, 88, -1, 88, 58, 88, - -1, 88, 59, 88, -1, 88, 70, 88, -1, 88, - 69, 88, -1, 79, 88, -1, 71, 88, -1, 20, - 11, 83, 12, -1, 83, -1, 45, -1, -1, 42, - -1, 43, -1, 44, -1, 89, 46, 92, -1, 89, - 49, 92, -1, 89, 46, 57, 15, 96, 16, -1, - 90, -1, 90, 31, -1, 90, 31, 91, -1, 93, - -1, 93, 56, 92, -1, 94, -1, 94, 57, 88, - -1, 48, -1, 48, 8, 45, -1, 48, 13, 95, - 14, -1, 45, -1, 71, 95, -1, 11, 95, 12, - -1, 95, 72, 95, -1, 95, 71, 95, -1, 95, - 75, 95, -1, 95, 74, 95, -1, 95, 73, 95, - -1, 48, -1, 96, 48, -1, 96, 56, -1, 98, - -1, 98, 31, -1, 98, 31, 97, -1, 99, -1, - 83, 57, 88, -1, 83, 77, -1, 83, 76, -1, - 18, 11, 21, 102, 12, -1, 19, 11, 83, 12, - -1, 19, 11, 45, 12, -1, 17, 88, -1, 88, - -1, -1, 83, 57, 51, 100, 11, 101, 12, 99, - -1, -1, 103, -1, -1, 56, 103, -1, 88, -1, - 88, 56, 103, -1 + 83, 0, -1, 92, -1, 88, -1, 98, -1, 86, + -1, 48, -1, 48, 13, 88, 14, -1, 85, 87, + -1, -1, 81, 86, -1, 11, 88, 12, -1, 88, + 72, 88, -1, 88, 71, 88, -1, 88, 75, 88, + -1, 88, 74, 88, -1, 88, 73, 88, -1, 88, + 60, 88, -1, 88, 61, 88, -1, 88, 62, 88, + -1, 88, 68, 88, -1, 88, 67, 88, -1, 88, + 66, 88, -1, 88, 65, 88, -1, 88, 64, 88, + -1, 88, 63, 88, -1, 88, 58, 88, -1, 88, + 59, 88, -1, 88, 70, 88, -1, 88, 69, 88, + -1, 79, 88, -1, 71, 88, -1, 20, 11, 84, + 12, -1, 84, -1, 45, -1, 21, -1, -1, 42, + -1, 43, -1, 44, -1, 89, 46, 93, -1, 89, + 49, 93, -1, 89, 46, 57, 15, 97, 16, -1, + 89, 91, -1, 22, 48, 15, 92, 16, -1, 90, + -1, 90, 31, -1, 90, 31, 92, -1, 94, -1, + 94, 56, 93, -1, 95, -1, 95, 57, 88, -1, + 48, -1, 48, 8, 45, -1, 48, 13, 96, 14, + -1, 45, -1, 71, 96, -1, 11, 96, 12, -1, + 96, 72, 96, -1, 96, 71, 96, -1, 96, 75, + 96, -1, 96, 74, 96, -1, 96, 73, 96, -1, + 48, -1, 97, 48, -1, 97, 56, -1, 99, -1, + 99, 31, -1, 99, 31, 98, -1, 100, -1, 84, + 57, 88, -1, 84, 77, -1, 84, 76, -1, 18, + 11, 21, 103, 12, -1, 19, 11, 84, 12, -1, + 19, 11, 45, 12, -1, 17, 88, -1, 88, -1, + -1, 84, 57, 51, 101, 11, 102, 12, 100, -1, + -1, 104, -1, -1, 56, 104, -1, 88, -1, 88, + 56, 104, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint8 yyrline[] = { - 0, 84, 84, 88, 92, 98, 101, 102, 105, 105, - 109, 110, 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, - 138, 139, 140, 142, 143, 144, 148, 149, 150, 151, - 154, 155, 156, 159, 160, 161, 171, 172, 175, 176, - 179, 180, 181, 184, 185, 186, 187, 188, 189, 190, - 191, 194, 195, 204, 207, 208, 209, 212, 215, 216, - 217, 218, 219, 220, 221, 222, 223, 223, 226, 227, - 230, 231, 234, 235 +static const yytype_uint16 yyrline[] = { + 0, 84, 84, 88, 92, 98, 101, 102, 105, 132, + 133, 143, 144, 145, 146, 147, 148, 149, 150, 151, + 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, + 162, 163, 165, 166, 167, 168, 174, 175, 176, 177, + 180, 181, 182, 183, 186, 189, 190, 191, 201, 202, + 205, 206, 209, 210, 211, 214, 215, 216, 217, 218, + 219, 220, 221, 224, 225, 234, 237, 238, 239, 242, + 245, 246, 247, 248, 249, 250, 251, 252, 253, 253, + 256, 257, 260, 261, 264, 265 }; #endif @@ -606,10 +609,10 @@ static const char *const yytname[] = { "PML_BITOR", "PML_NE", "PML_EQ", "PML_LE", "PML_GE", "PML_LT", "PML_GT", "PML_RSHIFT", "PML_LSHIFT", "PML_MINUS", "PML_PLUS", "PML_MODULO", "PML_DIVIDE", "PML_TIMES", "PML_DECR", "PML_INCR", "PML_COMPL", - "PML_NEG", "PML_DOT", "$accept", "program", "varref", "pfld", "cmpnd", - "$@1", "sfld", "expr", "vis", "one_decl", "decl_lst", "var_list", "ivar", - "vardcl", "const_expr", "nlst", "stmnt_lst", "stmnt", "Stmnt", "$@2", - "args", "prargs", "arg", YY_NULL + "PML_NEG", "PML_CMPND", "PML_DOT", "$accept", "program", "varref", + "pfld", "cmpnd", "sfld", "expr", "vis", "one_decl", "utype", "decl_lst", + "var_list", "ivar", "vardcl", "const_expr", "nlst", "stmnt_lst", "stmnt", + "Stmnt", "$@1", "args", "prargs", "arg", YY_NULL }; #endif @@ -625,188 +628,193 @@ static const yytype_uint16 yytoknum[] = { 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, - 329 + 329, 330 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 81, 82, 82, 82, 83, 84, 84, 86, 85, - 87, 87, 88, 88, 88, 88, 88, 88, 88, 88, + 0, 82, 83, 83, 83, 84, 85, 85, 86, 87, + 87, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 89, 89, 89, 89, - 90, 90, 90, 91, 91, 91, 92, 92, 93, 93, - 94, 94, 94, 95, 95, 95, 95, 95, 95, 95, - 95, 96, 96, 96, 97, 97, 97, 98, 99, 99, - 99, 99, 99, 99, 99, 99, 100, 99, 101, 101, - 102, 102, 103, 103 + 90, 90, 90, 90, 91, 92, 92, 92, 93, 93, + 94, 94, 95, 95, 95, 96, 96, 96, 96, 96, + 96, 96, 96, 97, 97, 97, 98, 98, 98, 99, + 100, 100, 100, 100, 100, 100, 100, 100, 101, 100, + 102, 102, 103, 103, 104, 104 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { - 0, 2, 1, 1, 1, 1, 1, 4, 0, 3, - 0, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 0, 2, 1, 1, 1, 1, 1, 4, 2, 0, + 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 2, 2, 4, 1, 1, 0, 1, 1, 1, - 3, 3, 6, 1, 2, 3, 1, 3, 1, 3, - 1, 3, 4, 1, 2, 3, 3, 3, 3, 3, - 3, 1, 2, 2, 1, 2, 3, 1, 3, 2, - 2, 5, 4, 4, 2, 1, 0, 8, 0, 1, - 0, 2, 1, 3 + 2, 2, 4, 1, 1, 1, 0, 1, 1, 1, + 3, 3, 6, 2, 5, 1, 2, 3, 1, 3, + 1, 3, 1, 3, 4, 1, 2, 3, 3, 3, + 3, 3, 3, 1, 2, 2, 1, 2, 3, 1, + 3, 2, 2, 5, 4, 4, 2, 1, 0, 8, + 0, 1, 0, 2, 1, 3 }; /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. Performed when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { - 36, 0, 0, 0, 0, 0, 37, 38, 39, 35, - 6, 0, 0, 0, 34, 8, 5, 3, 0, 43, - 2, 4, 64, 67, 34, 0, 74, 0, 0, 0, - 0, 32, 31, 1, 0, 70, 69, 10, 0, 0, + 36, 0, 0, 0, 0, 0, 35, 37, 38, 39, + 34, 6, 0, 0, 0, 33, 9, 5, 3, 0, + 45, 2, 4, 66, 69, 33, 0, 76, 0, 0, + 0, 0, 31, 30, 1, 0, 72, 71, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 36, 65, - 12, 80, 0, 0, 0, 0, 76, 68, 0, 9, - 27, 28, 18, 19, 20, 26, 25, 24, 23, 22, - 21, 30, 29, 14, 13, 17, 16, 15, 50, 0, - 40, 46, 48, 41, 45, 75, 66, 0, 0, 73, - 72, 33, 7, 0, 11, 0, 0, 0, 0, 0, - 82, 81, 71, 78, 51, 0, 53, 0, 0, 61, - 0, 47, 49, 0, 0, 79, 0, 54, 52, 0, - 0, 0, 0, 0, 42, 62, 63, 83, 0, 55, - 57, 56, 60, 59, 58, 77 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 43, 36, 67, 11, 82, 0, 0, 0, 0, + 78, 70, 10, 26, 27, 17, 18, 19, 25, 24, + 23, 22, 21, 20, 29, 28, 13, 12, 16, 15, + 14, 0, 52, 0, 40, 48, 50, 41, 47, 77, + 68, 0, 0, 75, 74, 32, 7, 0, 36, 0, + 0, 0, 0, 0, 84, 83, 73, 80, 0, 53, + 0, 55, 0, 0, 63, 0, 49, 51, 0, 0, + 81, 44, 0, 56, 54, 0, 0, 0, 0, 0, + 42, 64, 65, 85, 0, 57, 59, 58, 62, 61, + 60, 79 }; /* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int8 yydefgoto[] = { - -1, 13, 24, 15, 16, 37, 69, 110, 18, 19, - 20, 90, 91, 92, 118, 120, 21, 22, 23, 103, - 124, 98, 111 +static const yytype_int16 yydefgoto[] = { + -1, 14, 25, 16, 17, 39, 114, 19, 20, 61, + 21, 94, 95, 96, 123, 125, 22, 23, 24, 107, + 129, 102, 115 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -109 +#define YYPACT_NINF -112 static const yytype_int16 yypact[] = { - 46, 65, 65, -5, 7, 9, -109, -109, -109, -109, - 8, 65, 65, 33, -53, -109, -109, 155, -36, 5, - -109, -109, 6, -109, -109, 87, 193, 54, -29, 36, - 65, -1, -109, -109, 60, -109, -109, 13, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, -40, 38, 35, 50, - -109, 25, 71, 75, 84, 110, -109, 193, 36, -109, - 209, 209, 222, 222, 222, 170, 170, 229, 229, 229, - 229, -46, -46, -1, -1, -109, -109, -109, 1, 82, - -109, 51, 49, -109, -109, 193, -109, 65, 100, -109, - -109, -109, -109, 103, -109, 70, 11, 68, 38, 65, - 136, -109, -109, 65, -109, 11, -109, 11, 116, -109, - 44, -109, 193, 65, 106, -109, 92, 28, -109, 11, - 11, 11, 11, 11, -109, -109, -109, -109, 50, -109, - 28, 28, -109, -109, -109, -109 + 50, 66, 66, 5, 8, 25, -112, -112, -112, -112, + -112, 26, 66, 66, 62, -52, -8, -112, 159, -12, + 45, -112, -112, 57, -112, -112, 91, 200, 70, -37, + 41, 66, 10, -112, -112, 54, -112, -112, 41, -112, + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, + 66, 66, 66, 66, 66, 66, 66, 66, 48, -39, + 49, -112, 193, 61, -112, 51, 88, 89, 92, 114, + -112, 200, -112, 216, 216, 229, 229, 229, 133, 133, + 236, 236, 236, 236, -45, -45, 10, 10, -112, -112, + -112, 95, 7, 97, -112, 64, 67, -112, -112, 200, + -112, 66, 111, -112, -112, -112, -112, 115, -21, 82, + -7, 83, 49, 66, 182, -112, -112, 66, 118, -112, + -7, -112, -7, 44, -112, 74, -112, 200, 66, 123, + -112, -112, 96, 68, -112, -7, -7, -7, -7, -7, + -112, -112, -112, -112, 61, -112, 68, 68, -112, -112, + -112, -112 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -109, -109, 3, -109, 52, -109, -109, 0, -109, -109, - 61, -50, -109, -109, 117, -109, 63, -109, -15, -109, - -109, -109, -108 + -112, -112, 3, -112, 98, -112, 0, -112, -112, -112, + -48, -53, -112, -112, 75, -112, 76, -112, -6, -112, + -112, -112, -111 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -76 +#define YYTABLE_NINF -78 static const yytype_int16 yytable[] = { - 17, 25, 26, 14, 34, 125, 27, 93, 88, 105, - 56, 31, 32, 57, 106, 137, 62, 89, 28, 10, - 29, 30, 115, 35, 36, 51, 52, 53, 54, 55, - 65, 63, 64, 33, 67, -44, 58, 59, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - 82, 83, 84, 85, 86, 87, 116, 1, 121, 95, - 134, 1, 14, 2, 3, 4, 5, 2, 3, 4, - 5, 1, 53, 54, 55, 61, 1, 6, 7, 8, - 5, 97, 117, 99, 10, 5, 88, 100, 6, 7, - 8, 9, 135, 68, 10, 9, 101, 107, 10, 60, - 136, 131, 132, 133, 139, 9, 109, 108, 10, 122, - 9, 66, 112, 10, 113, 114, 119, 11, 138, 94, - 104, 11, 96, 145, 102, 12, 0, 0, 0, 12, - 128, 11, 0, 0, 0, 0, 11, 0, 95, 12, - 0, 14, 0, 0, 12, 38, 39, 40, 41, 42, + 18, 26, 27, 15, 120, 35, 130, 97, 66, 92, + 58, 11, 32, 33, 98, 109, 28, 143, 93, 29, + 110, 7, 8, 9, 36, 37, 53, 54, 55, 56, + 57, 69, 67, 68, 59, 71, 30, 60, 121, 31, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + 83, 84, 85, 86, 87, 88, 89, 90, 134, 126, + 118, 1, 34, 99, 122, 1, 15, 2, 3, 4, + 5, 6, 1, 38, 5, 6, 62, 1, 2, 3, + 4, 5, 6, 55, 56, 57, 5, 6, 63, 11, + 140, 65, 7, 8, 9, 10, 91, 92, 11, 10, + 103, 104, 11, 64, 105, 70, 10, 101, 145, 11, + 108, 10, 111, 127, 11, 135, 136, 137, 138, 139, + 112, 12, 141, 116, 113, 12, 117, 119, 106, 13, + 142, 124, 12, 13, 131, 144, 72, 12, 151, 100, + 13, 137, 138, 139, 99, 13, 0, 15, 0, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 135, 136, 137, + 138, 139, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + -77, 0, 0, -46, 0, 132, 0, 133, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, -46, + 146, 147, 148, 149, 150, 0, 0, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 129, 130, 131, 132, 133, 38, 39, + 53, 54, 55, 56, 57, 7, 8, 9, 128, 0, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, -75, 129, 130, 131, - 132, 133, 123, 0, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 0, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 0, 126, 0, 127, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 140, 141, 142, 143, - 144, 38, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 49, 50, - 51, 52, 53, 54, 55 + 50, 51, 52, 53, 54, 55, 56, 57, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 51, 52, 53, 54, 55, + 56, 57 }; #define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-109))) + (!!((Yystate) == (-112))) #define yytable_value_is_error(Yytable_value) \ YYID (0) static const yytype_int16 yycheck[] = { - 0, 1, 2, 0, 57, 113, 11, 57, 48, 8, - 46, 11, 12, 49, 13, 123, 45, 57, 11, 48, - 11, 13, 11, 76, 77, 71, 72, 73, 74, 75, - 30, 28, 29, 0, 34, 0, 31, 31, 38, 39, + 0, 1, 2, 0, 11, 57, 117, 60, 45, 48, + 22, 48, 12, 13, 62, 8, 11, 128, 57, 11, + 13, 42, 43, 44, 76, 77, 71, 72, 73, 74, + 75, 31, 29, 30, 46, 35, 11, 49, 45, 13, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 45, 11, 108, 59, - 16, 11, 59, 17, 18, 19, 20, 17, 18, 19, - 20, 11, 73, 74, 75, 21, 11, 42, 43, 44, - 20, 56, 71, 12, 48, 20, 48, 12, 42, 43, - 44, 45, 48, 80, 48, 45, 12, 15, 48, 12, - 56, 73, 74, 75, 12, 45, 57, 56, 48, 109, - 45, 51, 12, 48, 11, 45, 48, 71, 12, 58, - 68, 71, 59, 138, 14, 79, -1, -1, -1, 79, - 14, 71, -1, -1, -1, -1, 71, -1, 138, 79, - -1, 138, -1, -1, 79, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 71, 72, 73, 74, 75, 58, 59, + 50, 51, 52, 53, 54, 55, 56, 57, 14, 112, + 108, 11, 0, 63, 71, 11, 63, 17, 18, 19, + 20, 21, 11, 81, 20, 21, 31, 11, 17, 18, + 19, 20, 21, 73, 74, 75, 20, 21, 31, 48, + 16, 21, 42, 43, 44, 45, 48, 48, 48, 45, + 12, 12, 48, 12, 12, 51, 45, 56, 12, 48, + 15, 45, 15, 113, 48, 71, 72, 73, 74, 75, + 56, 71, 48, 12, 57, 71, 11, 45, 14, 79, + 56, 48, 71, 79, 16, 12, 38, 71, 144, 63, + 79, 73, 74, 75, 144, 79, -1, 144, -1, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 71, 72, 73, + 74, 75, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, + 31, -1, -1, 0, -1, 120, -1, 122, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 16, + 135, 136, 137, 138, 139, -1, -1, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 42, 43, 44, 56, -1, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 31, 71, 72, 73, - 74, 75, 56, -1, 58, 59, 60, 61, 62, 63, + 70, 71, 72, 73, 74, 75, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 75, -1, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, -1, 115, -1, 117, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 129, 130, 131, 132, - 133, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 69, 70, - 71, 72, 73, 74, 75 + 74, 75, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 69, 70, 71, 72, 73, + 74, 75 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 11, 17, 18, 19, 20, 42, 43, 44, 45, - 48, 71, 79, 82, 83, 84, 85, 88, 89, 90, - 91, 97, 98, 99, 83, 88, 88, 11, 11, 11, - 13, 88, 88, 0, 57, 76, 77, 86, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 46, 49, 31, 31, - 12, 21, 45, 83, 83, 88, 51, 88, 80, 87, + 0, 11, 17, 18, 19, 20, 21, 42, 43, 44, + 45, 48, 71, 79, 83, 84, 85, 86, 88, 89, + 90, 92, 98, 99, 100, 84, 88, 88, 11, 11, + 11, 13, 88, 88, 0, 57, 76, 77, 81, 87, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 22, 46, + 49, 91, 31, 31, 12, 21, 45, 84, 84, 88, + 51, 88, 86, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 48, 57, - 92, 93, 94, 92, 91, 88, 97, 56, 102, 12, - 12, 12, 14, 100, 85, 8, 13, 15, 56, 57, - 88, 103, 12, 11, 45, 11, 45, 71, 95, 48, - 96, 92, 88, 56, 101, 103, 95, 95, 14, 71, - 72, 73, 74, 75, 16, 48, 56, 103, 12, 12, - 95, 95, 95, 95, 95, 99 + 88, 48, 48, 57, 93, 94, 95, 93, 92, 88, + 98, 56, 103, 12, 12, 12, 14, 101, 15, 8, + 13, 15, 56, 57, 88, 104, 12, 11, 92, 45, + 11, 45, 71, 96, 48, 97, 93, 88, 56, 102, + 104, 16, 96, 96, 14, 71, 72, 73, 74, 75, + 16, 48, 56, 104, 12, 12, 96, 96, 96, 96, + 96, 100 }; #define yyerrok (yyerrstatus = 0) @@ -1632,7 +1640,9 @@ yyreduce: case 5: /* Line 1787 of yacc.c */ #line 98 "promela.ypp" - {} + { + (yyval.node) = (yyvsp[(1) - (1)].node); + } break; case 6: @@ -1655,222 +1665,257 @@ yyreduce: case 8: /* Line 1787 of yacc.c */ -#line 105 "promela.ypp" - {} +#line 106 "promela.ypp" + { + if ((yyvsp[(2) - (2)].node) != NULL) { + if ((yyvsp[(2) - (2)].node)->type == PML_CMPND) { + (yyval.node) = ctx->node(PML_CMPND, 1, (yyvsp[(1) - (2)].node)); + (yyval.node)->merge((yyvsp[(2) - (2)].node)); + delete (yyvsp[(2) - (2)].node); + } else { + (yyval.node) = ctx->node(PML_CMPND, 2, (yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].node)); + } + } else { + /* $$ = ctx->node(PML_CMPND, 1, $1);*/ + (yyval.node) = (yyvsp[(1) - (2)].node); + } + /* if ($2 != NULL) { + $$ = ctx->node(PML_CMPND, 1, $1); + if ($2->operands.size() > 0) { + $$->merge($2); + delete $2; + } else { + $$->push($2); + } + } else { + $$ = $1; + } + */ + } break; case 9: /* Line 1787 of yacc.c */ -#line 106 "promela.ypp" - {} +#line 132 "promela.ypp" + { + (yyval.node) = NULL; + } break; case 10: /* Line 1787 of yacc.c */ -#line 109 "promela.ypp" - {} +#line 133 "promela.ypp" + { + (yyval.node) = (yyvsp[(2) - (2)].node); + } break; case 11: /* Line 1787 of yacc.c */ -#line 110 "promela.ypp" - {} +#line 143 "promela.ypp" + { + (yyval.node) = (yyvsp[(2) - (3)].node); + } break; case 12: /* Line 1787 of yacc.c */ -#line 120 "promela.ypp" +#line 144 "promela.ypp" { - (yyval.node) = (yyvsp[(2) - (3)].node); + (yyval.node) = ctx->node(PML_PLUS, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 13: /* Line 1787 of yacc.c */ -#line 121 "promela.ypp" +#line 145 "promela.ypp" { - (yyval.node) = ctx->node(PML_PLUS, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_MINUS, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 14: /* Line 1787 of yacc.c */ -#line 122 "promela.ypp" +#line 146 "promela.ypp" { - (yyval.node) = ctx->node(PML_MINUS, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_TIMES, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 15: /* Line 1787 of yacc.c */ -#line 123 "promela.ypp" +#line 147 "promela.ypp" { - (yyval.node) = ctx->node(PML_TIMES, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_DIVIDE, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 16: /* Line 1787 of yacc.c */ -#line 124 "promela.ypp" +#line 148 "promela.ypp" { - (yyval.node) = ctx->node(PML_DIVIDE, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_MODULO, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 17: /* Line 1787 of yacc.c */ -#line 125 "promela.ypp" +#line 149 "promela.ypp" { - (yyval.node) = ctx->node(PML_MODULO, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_BITAND, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 18: /* Line 1787 of yacc.c */ -#line 126 "promela.ypp" +#line 150 "promela.ypp" { - (yyval.node) = ctx->node(PML_BITAND, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_BITXOR, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 19: /* Line 1787 of yacc.c */ -#line 127 "promela.ypp" +#line 151 "promela.ypp" { - (yyval.node) = ctx->node(PML_BITXOR, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_BITOR, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 20: /* Line 1787 of yacc.c */ -#line 128 "promela.ypp" +#line 152 "promela.ypp" { - (yyval.node) = ctx->node(PML_BITOR, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_GT, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 21: /* Line 1787 of yacc.c */ -#line 129 "promela.ypp" +#line 153 "promela.ypp" { - (yyval.node) = ctx->node(PML_GT, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_LT, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 22: /* Line 1787 of yacc.c */ -#line 130 "promela.ypp" +#line 154 "promela.ypp" { - (yyval.node) = ctx->node(PML_LT, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_GE, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 23: /* Line 1787 of yacc.c */ -#line 131 "promela.ypp" +#line 155 "promela.ypp" { - (yyval.node) = ctx->node(PML_GE, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_LE, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 24: /* Line 1787 of yacc.c */ -#line 132 "promela.ypp" +#line 156 "promela.ypp" { - (yyval.node) = ctx->node(PML_LE, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_EQ, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 25: /* Line 1787 of yacc.c */ -#line 133 "promela.ypp" +#line 157 "promela.ypp" { - (yyval.node) = ctx->node(PML_EQ, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_NE, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 26: /* Line 1787 of yacc.c */ -#line 134 "promela.ypp" +#line 158 "promela.ypp" { - (yyval.node) = ctx->node(PML_NE, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_AND, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 27: /* Line 1787 of yacc.c */ -#line 135 "promela.ypp" +#line 159 "promela.ypp" { - (yyval.node) = ctx->node(PML_AND, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_OR, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 28: /* Line 1787 of yacc.c */ -#line 136 "promela.ypp" +#line 160 "promela.ypp" { - (yyval.node) = ctx->node(PML_OR, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_LSHIFT, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 29: /* Line 1787 of yacc.c */ -#line 137 "promela.ypp" +#line 161 "promela.ypp" { - (yyval.node) = ctx->node(PML_LSHIFT, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_RSHIFT, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; case 30: /* Line 1787 of yacc.c */ -#line 138 "promela.ypp" +#line 162 "promela.ypp" { - (yyval.node) = ctx->node(PML_RSHIFT, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + (yyval.node) = ctx->node(PML_NEG, 1, (yyvsp[(2) - (2)].node)); } break; case 31: /* Line 1787 of yacc.c */ -#line 139 "promela.ypp" +#line 163 "promela.ypp" { - (yyval.node) = ctx->node(PML_NEG, 1, (yyvsp[(2) - (2)].node)); + (yyval.node) = ctx->node(PML_MINUS, 1, (yyvsp[(2) - (2)].node)); } break; case 32: /* Line 1787 of yacc.c */ -#line 140 "promela.ypp" +#line 165 "promela.ypp" { - (yyval.node) = ctx->node(PML_MINUS, 1, (yyvsp[(2) - (2)].node)); + (yyval.node) = ctx->node(PML_LEN, 1, (yyvsp[(3) - (4)].node)); } break; case 33: /* Line 1787 of yacc.c */ -#line 142 "promela.ypp" +#line 166 "promela.ypp" { - (yyval.node) = ctx->node(PML_LEN, 1, (yyvsp[(3) - (4)].node)); + (yyval.node) = (yyvsp[(1) - (1)].node); } break; case 34: /* Line 1787 of yacc.c */ -#line 143 "promela.ypp" - { } +#line 167 "promela.ypp" + { + (yyval.node) = ctx->value(PML_CONST, (yyvsp[(1) - (1)].value)); + free((yyvsp[(1) - (1)].value)); + } break; case 35: /* Line 1787 of yacc.c */ -#line 144 "promela.ypp" +#line 168 "promela.ypp" { - (yyval.node) = ctx->value(PML_CONST, (yyvsp[(1) - (1)].value)); + /* Non standard promela for string literals */ + (yyval.node) = ctx->value(PML_STRING, (yyvsp[(1) - (1)].value)); free((yyvsp[(1) - (1)].value)); } break; case 36: /* Line 1787 of yacc.c */ -#line 148 "promela.ypp" +#line 174 "promela.ypp" { (yyval.node) = ctx->node(PML_SHOW, 0); } @@ -1878,7 +1923,7 @@ yyreduce: case 37: /* Line 1787 of yacc.c */ -#line 149 "promela.ypp" +#line 175 "promela.ypp" { (yyval.node) = ctx->node(PML_HIDDEN, 0); } @@ -1886,7 +1931,7 @@ yyreduce: case 38: /* Line 1787 of yacc.c */ -#line 150 "promela.ypp" +#line 176 "promela.ypp" { (yyval.node) = ctx->node(PML_SHOW, 0); } @@ -1894,7 +1939,7 @@ yyreduce: case 39: /* Line 1787 of yacc.c */ -#line 151 "promela.ypp" +#line 177 "promela.ypp" { (yyval.node) = ctx->node(PML_ISLOCAL, 0); } @@ -1902,7 +1947,7 @@ yyreduce: case 40: /* Line 1787 of yacc.c */ -#line 154 "promela.ypp" +#line 180 "promela.ypp" { (yyval.node) = ctx->node(PML_DECL, 3, (yyvsp[(1) - (3)].node), ctx->value(PML_TYPE, (yyvsp[(2) - (3)].value)), (yyvsp[(3) - (3)].node)); free((yyvsp[(2) - (3)].value)); @@ -1911,7 +1956,7 @@ yyreduce: case 41: /* Line 1787 of yacc.c */ -#line 155 "promela.ypp" +#line 181 "promela.ypp" { (yyval.node) = ctx->node(PML_UNAME, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } @@ -1919,7 +1964,7 @@ yyreduce: case 42: /* Line 1787 of yacc.c */ -#line 156 "promela.ypp" +#line 182 "promela.ypp" { (yyval.node) = ctx->node(PML_DECL, 3, (yyvsp[(1) - (6)].node), ctx->value(PML_TYPE, (yyvsp[(2) - (6)].value)), (yyvsp[(5) - (6)].node)); free((yyvsp[(2) - (6)].value)); @@ -1928,23 +1973,39 @@ yyreduce: case 43: /* Line 1787 of yacc.c */ -#line 159 "promela.ypp" +#line 183 "promela.ypp" { - (yyval.node) = (yyvsp[(1) - (1)].node); + (yyval.node) = (yyvsp[(2) - (2)].node); } break; case 44: /* Line 1787 of yacc.c */ -#line 160 "promela.ypp" +#line 186 "promela.ypp" { - (yyval.node) = (yyvsp[(1) - (2)].node); + (yyval.node) = ctx->node(PML_TYPEDEF, 2, ctx->value(PML_NAME, (yyvsp[(2) - (5)].value)), (yyvsp[(4) - (5)].node)); } break; case 45: /* Line 1787 of yacc.c */ -#line 161 "promela.ypp" +#line 189 "promela.ypp" + { + (yyval.node) = (yyvsp[(1) - (1)].node); + } + break; + + case 46: + /* Line 1787 of yacc.c */ +#line 190 "promela.ypp" + { + (yyval.node) = (yyvsp[(1) - (2)].node); + } + break; + + case 47: + /* Line 1787 of yacc.c */ +#line 191 "promela.ypp" { (yyval.node) = ctx->node(PML_DECLLIST, 1, (yyvsp[(1) - (3)].node)); if((yyvsp[(3) - (3)].node)->type == PML_DECLLIST) { @@ -1956,17 +2017,17 @@ yyreduce: } break; - case 46: + case 48: /* Line 1787 of yacc.c */ -#line 171 "promela.ypp" +#line 201 "promela.ypp" { (yyval.node) = ctx->node(PML_VARLIST, 1, (yyvsp[(1) - (1)].node)); } break; - case 47: + case 49: /* Line 1787 of yacc.c */ -#line 172 "promela.ypp" +#line 202 "promela.ypp" { (yyval.node) = ctx->node(PML_VARLIST, 1, (yyvsp[(1) - (3)].node)); (yyval.node)->merge((yyvsp[(3) - (3)].node)); @@ -1974,34 +2035,34 @@ yyreduce: } break; - case 48: + case 50: /* Line 1787 of yacc.c */ -#line 175 "promela.ypp" +#line 205 "promela.ypp" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; - case 49: + case 51: /* Line 1787 of yacc.c */ -#line 176 "promela.ypp" +#line 206 "promela.ypp" { (yyval.node) = ctx->node(PML_ASGN, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; - case 50: + case 52: /* Line 1787 of yacc.c */ -#line 179 "promela.ypp" +#line 209 "promela.ypp" { (yyval.node) = ctx->value(PML_NAME, (yyvsp[(1) - (1)].value)); free((yyvsp[(1) - (1)].value)); } break; - case 51: + case 53: /* Line 1787 of yacc.c */ -#line 180 "promela.ypp" +#line 210 "promela.ypp" { (yyval.node) = ctx->node(PML_COLON, 2, ctx->value(PML_NAME, (yyvsp[(1) - (3)].value)), ctx->value(PML_CONST, (yyvsp[(3) - (3)].value))); free((yyvsp[(1) - (3)].value)); @@ -2009,92 +2070,92 @@ yyreduce: } break; - case 52: + case 54: /* Line 1787 of yacc.c */ -#line 181 "promela.ypp" +#line 211 "promela.ypp" { (yyval.node) = ctx->node(PML_VAR_ARRAY, 2, ctx->value(PML_NAME, (yyvsp[(1) - (4)].value)), (yyvsp[(3) - (4)].node)); free((yyvsp[(1) - (4)].value)); } break; - case 53: + case 55: /* Line 1787 of yacc.c */ -#line 184 "promela.ypp" +#line 214 "promela.ypp" { (yyval.node) = ctx->value(PML_CONST, (yyvsp[(1) - (1)].value)); free((yyvsp[(1) - (1)].value)); } break; - case 54: + case 56: /* Line 1787 of yacc.c */ -#line 185 "promela.ypp" +#line 215 "promela.ypp" { (yyval.node) = ctx->node(PML_MINUS, 1, (yyvsp[(2) - (2)].node)); } break; - case 55: + case 57: /* Line 1787 of yacc.c */ -#line 186 "promela.ypp" +#line 216 "promela.ypp" { (yyval.node) = (yyvsp[(2) - (3)].node); } break; - case 56: + case 58: /* Line 1787 of yacc.c */ -#line 187 "promela.ypp" +#line 217 "promela.ypp" { (yyval.node) = ctx->node(PML_PLUS, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; - case 57: + case 59: /* Line 1787 of yacc.c */ -#line 188 "promela.ypp" +#line 218 "promela.ypp" { (yyval.node) = ctx->node(PML_MINUS, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; - case 58: + case 60: /* Line 1787 of yacc.c */ -#line 189 "promela.ypp" +#line 219 "promela.ypp" { (yyval.node) = ctx->node(PML_TIMES, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; - case 59: + case 61: /* Line 1787 of yacc.c */ -#line 190 "promela.ypp" +#line 220 "promela.ypp" { (yyval.node) = ctx->node(PML_DIVIDE, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; - case 60: + case 62: /* Line 1787 of yacc.c */ -#line 191 "promela.ypp" +#line 221 "promela.ypp" { (yyval.node) = ctx->node(PML_MODULO, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; - case 61: + case 63: /* Line 1787 of yacc.c */ -#line 194 "promela.ypp" +#line 224 "promela.ypp" { (yyval.node) = ctx->value(PML_NAME, (yyvsp[(1) - (1)].value)); free((yyvsp[(1) - (1)].value)); } break; - case 62: + case 64: /* Line 1787 of yacc.c */ -#line 195 "promela.ypp" +#line 225 "promela.ypp" { if ((yyvsp[(1) - (2)].node)->type == PML_NAME) { (yyval.node) = ctx->node(PML_NAMELIST, 1, (yyvsp[(1) - (2)].node)); @@ -2106,161 +2167,163 @@ yyreduce: } break; - case 63: + case 65: /* Line 1787 of yacc.c */ -#line 204 "promela.ypp" +#line 234 "promela.ypp" { (yyval.node) = (yyvsp[(1) - (2)].node); } break; - case 64: + case 66: /* Line 1787 of yacc.c */ -#line 207 "promela.ypp" +#line 237 "promela.ypp" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; - case 65: + case 67: /* Line 1787 of yacc.c */ -#line 208 "promela.ypp" +#line 238 "promela.ypp" { (yyval.node) = (yyvsp[(1) - (2)].node); } break; - case 66: + case 68: /* Line 1787 of yacc.c */ -#line 209 "promela.ypp" +#line 239 "promela.ypp" { (yyval.node) = ctx->node(PML_STMNT, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; - case 67: + case 69: /* Line 1787 of yacc.c */ -#line 212 "promela.ypp" +#line 242 "promela.ypp" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; - case 68: + case 70: /* Line 1787 of yacc.c */ -#line 215 "promela.ypp" +#line 245 "promela.ypp" { (yyval.node) = ctx->node(PML_ASGN, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } break; - case 69: + case 71: /* Line 1787 of yacc.c */ -#line 216 "promela.ypp" +#line 246 "promela.ypp" { (yyval.node) = ctx->node(PML_INCR, 1, (yyvsp[(1) - (2)].node)); } break; - case 70: + case 72: /* Line 1787 of yacc.c */ -#line 217 "promela.ypp" +#line 247 "promela.ypp" { (yyval.node) = ctx->node(PML_DECR, 1, (yyvsp[(1) - (2)].node)); } break; - case 71: + case 73: /* Line 1787 of yacc.c */ -#line 218 "promela.ypp" +#line 248 "promela.ypp" { (yyval.node) = ctx->node(PML_PRINT, 2, ctx->value(PML_STRING, (yyvsp[(3) - (5)].value)), (yyvsp[(4) - (5)].node)); free((yyvsp[(3) - (5)].value)); } break; - case 72: + case 74: /* Line 1787 of yacc.c */ -#line 219 "promela.ypp" +#line 249 "promela.ypp" { (yyval.node) = ctx->node(PML_PRINTM, 1, (yyvsp[(3) - (4)].node)); } break; - case 73: + case 75: /* Line 1787 of yacc.c */ -#line 220 "promela.ypp" +#line 250 "promela.ypp" { (yyval.node) = ctx->node(PML_PRINTM, 1, ctx->value(PML_CONST, (yyvsp[(3) - (4)].value))); free((yyvsp[(3) - (4)].value)); } break; - case 74: + case 76: /* Line 1787 of yacc.c */ -#line 221 "promela.ypp" - { } +#line 251 "promela.ypp" + { + (yyval.node) = ctx->node(PML_ASSERT, 1, (yyvsp[(2) - (2)].node)); + } break; - case 75: + case 77: /* Line 1787 of yacc.c */ -#line 222 "promela.ypp" +#line 252 "promela.ypp" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; - case 76: + case 78: /* Line 1787 of yacc.c */ -#line 223 "promela.ypp" +#line 253 "promela.ypp" { } break; - case 77: + case 79: /* Line 1787 of yacc.c */ -#line 223 "promela.ypp" +#line 253 "promela.ypp" { } break; - case 78: + case 80: /* Line 1787 of yacc.c */ -#line 226 "promela.ypp" +#line 256 "promela.ypp" { } break; - case 79: + case 81: /* Line 1787 of yacc.c */ -#line 227 "promela.ypp" +#line 257 "promela.ypp" { } break; - case 80: + case 82: /* Line 1787 of yacc.c */ -#line 230 "promela.ypp" +#line 260 "promela.ypp" { (yyval.node) = ctx->value(0, ""); } break; - case 81: + case 83: /* Line 1787 of yacc.c */ -#line 231 "promela.ypp" +#line 261 "promela.ypp" { (yyval.node) = (yyvsp[(2) - (2)].node); } break; - case 82: + case 84: /* Line 1787 of yacc.c */ -#line 234 "promela.ypp" +#line 264 "promela.ypp" { (yyval.node) = (yyvsp[(1) - (1)].node); } break; - case 83: + case 85: /* Line 1787 of yacc.c */ -#line 235 "promela.ypp" +#line 265 "promela.ypp" { (yyval.node) = ctx->node(0, 2, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); } @@ -2268,7 +2331,7 @@ yyreduce: /* Line 1787 of yacc.c */ -#line 2162 "promela.tab.cpp" +#line 2207 "promela.tab.cpp" default: break; } @@ -2487,6 +2550,6 @@ yyreturn: /* Line 2050 of yacc.c */ -#line 239 "promela.ypp" +#line 269 "promela.ypp" diff --git a/src/uscxml/plugins/datamodel/promela/parser/promela.tab.hpp b/src/uscxml/plugins/datamodel/promela/parser/promela.tab.hpp index b8381cf..e6eb572 100644 --- a/src/uscxml/plugins/datamodel/promela/parser/promela.tab.hpp +++ b/src/uscxml/plugins/datamodel/promela/parser/promela.tab.hpp @@ -125,7 +125,8 @@ extern int promela_debug; PML_INCR = 326, PML_COMPL = 327, PML_NEG = 328, - PML_DOT = 329 + PML_CMPND = 329, + PML_DOT = 330 }; #endif @@ -141,7 +142,7 @@ typedef union PROMELA_STYPE /* Line 2053 of yacc.c */ -#line 145 "promela.tab.hpp" +#line 146 "promela.tab.hpp" } PROMELA_STYPE; # define PROMELA_STYPE_IS_TRIVIAL 1 # define promela_stype PROMELA_STYPE /* obsolescent; will be withdrawn */ diff --git a/src/uscxml/plugins/datamodel/promela/parser/promela.ypp b/src/uscxml/plugins/datamodel/promela/parser/promela.ypp index cf8deea..45767ed 100644 --- a/src/uscxml/plugins/datamodel/promela/parser/promela.ypp +++ b/src/uscxml/plugins/datamodel/promela/parser/promela.ypp @@ -43,8 +43,8 @@ using namespace uscxml; %error-verbose /* %type <node> expr_lst */ -%type <node> expr pfld varref decl_lst stmnt_lst vardcl ivar var_list one_decl prargs -%type <node> stmnt Stmnt const_expr nlst vis arg +%type <node> expr pfld sfld varref decl_lst stmnt_lst vardcl ivar var_list one_decl prargs utype cmpnd +%type <node> stmnt Stmnt const_expr nlst vis arg %token PML_VAR_ARRAY PML_VARLIST PML_DECL PML_DECLLIST PML_STMNT PML_COLON PML_EXPR PML_NAMELIST @@ -73,7 +73,7 @@ using namespace uscxml; %left PML_INCR PML_DECR %left PML_COMPL %right PML_NEG -%left PML_DOT +%left PML_DOT PML_CMPND %% @@ -95,19 +95,30 @@ program : } ; -varref : cmpnd {} +varref : cmpnd { $$ = $1; } ; pfld : PML_NAME { $$ = ctx->value(PML_NAME, $1); free($1); } | PML_NAME '[' expr ']' { $$ = ctx->node(PML_VAR_ARRAY, 2, ctx->value(PML_NAME, $1), $3); free($1); } ; -cmpnd : pfld {} - sfld {} +cmpnd : pfld + sfld { + if ($2 != NULL) { + if ($2->type == PML_CMPND) { + $$ = ctx->node(PML_CMPND, 1, $1); + $$->merge($2); delete $2; + } else { + $$ = ctx->node(PML_CMPND, 2, $1, $2); + } + } else { + $$ = $1; + } + } ; -sfld : /* empty */ {} - | PML_DOT cmpnd %prec PML_DOT {} +sfld : /* empty */ { $$ = NULL; } + | PML_DOT cmpnd %prec PML_DOT { $$ = $2; } ; /* @@ -140,8 +151,11 @@ expr : '(' expr ')' { $$ = $2; } | PML_MINUS expr %prec PML_MINUS { $$ = ctx->node(PML_MINUS, 1, $2); } | PML_LEN '(' varref ')' { $$ = ctx->node(PML_LEN, 1, $3); } - | varref { } + | varref { $$ = $1; } | PML_CONST { $$ = ctx->value(PML_CONST, $1); free($1); } + | PML_STRING { + /* Non standard promela for string literals */ + $$ = ctx->value(PML_STRING, $1); free($1); } ; @@ -154,6 +168,10 @@ vis : /* empty */ { $$ = ctx->node(PML_SHOW, 0); } one_decl: vis PML_TYPE var_list { $$ = ctx->node(PML_DECL, 3, $1, ctx->value(PML_TYPE, $2), $3); free($2); } | vis PML_UNAME var_list { $$ = ctx->node(PML_UNAME, 2, $1, $3); } | vis PML_TYPE PML_ASGN '{' nlst '}' { $$ = ctx->node(PML_DECL, 3, $1, ctx->value(PML_TYPE, $2), $5); free($2); } + | vis utype { $$ = $2; } + ; + +utype : PML_TYPEDEF PML_NAME '{' decl_lst '}' { $$ = ctx->node(PML_TYPEDEF, 2, ctx->value(PML_NAME, $2), $4); } ; decl_lst: one_decl { $$ = $1; } @@ -218,7 +236,7 @@ Stmnt : varref PML_ASGN expr { $$ = ctx->node(PML_ASGN, 2, $1, $3); } | PML_PRINT '(' PML_STRING prargs ')' { $$ = ctx->node(PML_PRINT, 2, ctx->value(PML_STRING, $3), $4); free($3); } | PML_PRINTM '(' varref ')' { $$ = ctx->node(PML_PRINTM, 1, $3); } | PML_PRINTM '(' PML_CONST ')' { $$ = ctx->node(PML_PRINTM, 1, ctx->value(PML_CONST, $3)); free($3); } - | PML_ASSERT expr { } + | PML_ASSERT expr { $$ = ctx->node(PML_ASSERT, 1, $2); } | expr { $$ = $1; } | varref PML_ASGN PML_INAME { } '(' args ')' Stmnt { } ; |