|
Go to the documentation of this file.
18 std::string::size_type pos = 0;
23 if (tmpFileName == "") {
24 std::stringstream errstr;
25 errstr << "Exception opening temp file";
26 throw Exception( "pd_dotparser::RewriteDotFile", errstr.str(), 2);
30 tmp.open(tmpFileName.c_str());
34 std::ifstream file (fileName.c_str(), std::ios::in | std::ios::binary);
36 std::string line = "";
40 while (getline(file, line)) {
43 line.erase(std::remove_if(line.begin(), line.end(), ::isspace),
47 if (line.find( "->") != std::string::npos
48 && line.find( "label") != std::string::npos) {
49 pos = line.find( "label");
50 std::string label = "";
51 getIde(pos, line, label, fileName, nr);
53 std::string post = "\"];";
57 if (label.find( '[') != std::string::npos
58 || label.find( ']') != std::string::npos) {
60 std::stringstream errstr;
61 errstr << "Transition containing '[' or ']' as part of label, which is not allowed ! Line "
62 << nr << " in " << fileName;
63 throw Exception( "pd_dotparser::RewriteDotFile",
68 if (line.find(post) == std::string::npos) {
70 std::stringstream errstr;
71 errstr << "Can not find end of label ( ' \"]; ' ) ! Line "
72 << nr << " in " << fileName;
73 throw Exception( "pd_dotparser::RewriteDotFile",
79 line.replace(line.find(post), post.length(), ",[],[]" + post);
83 tmp << line << std::endl;
87 tmp << std::endl << "\"" << "default_stackbottom"
88 << "\" [style=\"invis\", attr=\"stackbottom\"];"
96 std::stringstream errstr;
97 errstr << "Unable to open file : " << fileName;
98 throw Exception( "pd_dotparser::RewriteDotFile", errstr.str(), 1);
107 std::stringstream errstr;
108 errstr << "Exception writing dot input file";
109 throw Exception( "pd_dotparser::RewriteDotFile", errstr.str(), 2);
117 FD_DF( "ParseSystemFromDot(...): " << filename);
125 std::stringstream errstr;
126 errstr << "Exception opening temporary file";
127 throw Exception( "pd_dotparser::ParseSystemFromDot", errstr.str(), 2);
140 std::stringstream errstr;
141 errstr << "Exception writing dot input file";
142 throw Exception( "pd_dotparser::ParseSystemFromDot", errstr.str(), 2);
153 return ((s == "_") || (s == "λ") || (s == "lambda"));
157 std::vector<std::string> split( const std::string& rStr, const std::string& rSep,
158 const std::string& rFilename, const int lineNr) {
161 std::vector<std::string> vTokens;
164 std::string::size_type start = 0, end = 0, curr = 0;
166 std::string str = rStr;
170 if ((end = str.find(rSep, start)) == std::string::npos) {
172 vTokens.push_back(str);
179 while ((end = str.find(rSep, curr)) != std::string::npos) {
181 sub = str.substr(curr, end - curr);
184 if (sub.find( "(") != std::string::npos) {
185 end = str.find( ")", curr);
186 #ifdef FAUDES_CHECKED
187 if (end == std::string::npos) {
188 std::stringstream errstr;
189 errstr << "Missing ')' in " << rFilename << " L:" << lineNr
191 throw Exception( "pd_dotparser::split(inp,sep)", errstr.str(),
198 sub = str.substr(curr, end - curr);
202 vTokens.push_back(sub);
208 if (curr < str.size())
209 vTokens.push_back(str.substr(curr));
216 std::string::size_type getIde(std::string::size_type& rPos,
217 const std::string& rInput, std::string& rRestString,
218 const std::string& rFilename, const int lineNr) {
219 std::string::size_type end_position = rPos;
221 rPos = rInput.find( '"', rPos);
222 if (rPos != std::string::npos) {
224 end_position = rInput.find( '"', ++rPos);
225 if (end_position != std::string::npos) {
227 rRestString = rInput.substr(rPos, end_position - rPos);
228 return end_position + 1;
230 #ifdef FAUDES_CHECKED
231 std::stringstream errstr;
232 errstr << "Missing \" in " << rFilename << " L:" << lineNr << " "
233 << rInput << std::endl;
234 throw Exception( "pd_dotparser::getIde for" + rInput.substr(rPos),
240 return rInput.size();
libFAUDES 2.28c
--- 2016.09.30
--- c++ api documentaion by doxygen
|