diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-04-11 07:58:48 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-04-11 07:58:48 (GMT) |
commit | 71c334bf4e35559496feac3f3cf00b72ceb88812 (patch) | |
tree | 859f78af51c8e929559a53d70492035ef3fad862 /src/uscxml/plugins/datamodel/promela/PromelaParser.cpp | |
parent | 5180e4666a314db36a15d953fdfa38af4f285758 (diff) | |
download | uscxml-71c334bf4e35559496feac3f3cf00b72ceb88812.zip uscxml-71c334bf4e35559496feac3f3cf00b72ceb88812.tar.gz uscxml-71c334bf4e35559496feac3f3cf00b72ceb88812.tar.bz2 |
More work on promela DM
changed const of Data subscript operator and introduced at(key) and item(index)
Diffstat (limited to 'src/uscxml/plugins/datamodel/promela/PromelaParser.cpp')
-rw-r--r-- | src/uscxml/plugins/datamodel/promela/PromelaParser.cpp | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp b/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp index ba89e14..a27d2df 100644 --- a/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp +++ b/src/uscxml/plugins/datamodel/promela/PromelaParser.cpp @@ -9,37 +9,44 @@ int promela_lex_init (void**); \ int promela_lex_destroy (void*); \ void promela_error (uscxml::PromelaParser* ctx, void* yyscanner, const char* err) { - uscxml::Event exceptionEvent; - exceptionEvent.data.compound["exception"] = uscxml::Data(err, uscxml::Data::VERBATIM); - exceptionEvent.name = "error.execution"; - exceptionEvent.eventType = uscxml::Event::PLATFORM; - throw exceptionEvent; + uscxml::Event excEvent; + excEvent.data.compound["exception"] = uscxml::Data(err, uscxml::Data::VERBATIM); + excEvent.name = "error.execution"; + excEvent.eventType = uscxml::Event::PLATFORM; + throw excEvent; } namespace uscxml { +PromelaParser::PromelaParser(const std::string& expr) { + init(expr); +} + PromelaParser::PromelaParser(const std::string& expr, Type expectedType) { + init(expr); + if (type != expectedType) { + std::stringstream ss; + ss << "Promela syntax type mismatch: Expected " << typeToDesc(expectedType) << " but got " << typeToDesc(type); + + uscxml::Event excEvent; + excEvent.data.compound["exception"] = uscxml::Data(ss.str(), uscxml::Data::VERBATIM); + excEvent.name = "error.execution"; + excEvent.eventType = uscxml::Event::PLATFORM; + throw excEvent; + } +} + +void PromelaParser::init(const std::string& expr) { input_length = expr.length() + 5; // plus some zero terminators input = (char*) calloc(1, input_length); memcpy(input, expr.c_str(), expr.length()); - + promela_lex_init(&scanner); // promela_assign_set_extra(ast, &scanner); promela__scan_buffer(input, input_length, scanner); promela_parse(this, scanner); - - if (type != expectedType) { - std::stringstream ss; - ss << "Promela syntax type mismatch: Expected " << typeToDesc(expectedType) << " but got " << typeToDesc(type); - - uscxml::Event exceptionEvent; - exceptionEvent.data.compound["exception"] = uscxml::Data(ss.str(), uscxml::Data::VERBATIM); - exceptionEvent.name = "error.execution"; - exceptionEvent.eventType = uscxml::Event::PLATFORM; - throw exceptionEvent; - } } - + PromelaParser::~PromelaParser() { free(input); promela_lex_destroy(scanner); |