diff options
author | Stefan Radomski <sradomski@mintwerk.de> | 2016-02-11 09:40:02 (GMT) |
---|---|---|
committer | Stefan Radomski <sradomski@mintwerk.de> | 2016-02-11 09:40:02 (GMT) |
commit | 7b428e5435f83a7e7db37094a9197afa2dd09bf5 (patch) | |
tree | 8e23dcc47322ddd79ada2bdbb5f0315266b1e1b4 /apps/uscxml-transform.cpp | |
parent | 179fe8cd5cf53893ad1783ff0ff41cf94e24a59b (diff) | |
download | uscxml-7b428e5435f83a7e7db37094a9197afa2dd09bf5.zip uscxml-7b428e5435f83a7e7db37094a9197afa2dd09bf5.tar.gz uscxml-7b428e5435f83a7e7db37094a9197afa2dd09bf5.tar.bz2 |
Some tidying up of ANSI-C transformation
Diffstat (limited to 'apps/uscxml-transform.cpp')
-rw-r--r-- | apps/uscxml-transform.cpp | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/apps/uscxml-transform.cpp b/apps/uscxml-transform.cpp index 857a160..a5aa9ec 100644 --- a/apps/uscxml-transform.cpp +++ b/apps/uscxml-transform.cpp @@ -275,11 +275,44 @@ int main(int argc, char** argv) { } else { interpreter = Interpreter::fromURL(inputFile); } - if (!interpreter) { - LOG(ERROR) << "Cannot create interpreter from " << inputFile; - exit(EXIT_FAILURE); + } catch (Event e) { + // we will reattempt below, not yet a fatal error + } catch (const std::exception &e) { + std::cout << e.what() << std::endl; + } + + if (!interpreter) { + URL tmp(inputFile); + tmp.toAbsoluteCwd(); + std::stringstream contentSS; + contentSS << tmp; + + std::string inlineBeginMarker = "INLINE SCXML BEGIN\n"; + std::string inlineEndMarker = "\nINLINE SCXML END"; + + size_t inlineSCXMLBegin = contentSS.str().find(inlineBeginMarker); + if (inlineSCXMLBegin != std::string::npos) { + inlineSCXMLBegin += inlineBeginMarker.size(); + size_t inlineSCXMLEnd = contentSS.str().find(inlineEndMarker); + std::string inlineSCXMLContent = contentSS.str().substr(inlineSCXMLBegin, inlineSCXMLEnd - inlineSCXMLBegin); + try { + interpreter = Interpreter::fromXML(inlineSCXMLContent, tmp); + } catch (Event e) { + std::cout << e << std::endl; + } catch (const std::exception &e) { + std::cout << e.what() << std::endl; + } } + } + + if (!interpreter) { + LOG(ERROR) << "Cannot create interpreter from " << inputFile; + exit(EXIT_FAILURE); + + } + + try { if (verbose) { std::list<InterpreterIssue> issues = interpreter.validate(); for (std::list<InterpreterIssue>::iterator issueIter = issues.begin(); issueIter != issues.end(); issueIter++) { |