Merge lp:~tapaal-dist-ctl/verifypn/escapeKey_issue_fix into lp:~verifypn-maintainers/verifypn/trunk

Proposed by Søren Moss Nielsen on 2016-08-04
Status: Merged
Approved by: Jiri Srba on 2016-08-07
Approved revision: 92
Merged at revision: 92
Proposed branch: lp:~tapaal-dist-ctl/verifypn/escapeKey_issue_fix
Merge into: lp:~verifypn-maintainers/verifypn/trunk
Diff against target: 90 lines (+27/-5)
2 files modified
CTLParser/CTLParser_v2.cpp (+17/-5)
CTLParser/CTLParser_v2.h (+10/-0)
To merge this branch: bzr merge lp:~tapaal-dist-ctl/verifypn/escapeKey_issue_fix
Reviewer Review Type Date Requested Status
Jiri Srba 2016-08-04 Approve on 2016-08-07
Review via email: mp+302020@code.launchpad.net

Commit message

Fixes the use of escape characters in query parsing of CTL queries.

Description of the change

Fixed the issue with formatting the query, using escape keys.
This means a query like the below will now work.
...
  <place>
    TAPN1.P0
  </place>
...

To post a comment you must log in.
Jiri Srba (srba) wrote :

Looks fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CTLParser/CTLParser_v2.cpp'
2--- CTLParser/CTLParser_v2.cpp 2016-05-16 12:24:30 +0000
3+++ CTLParser/CTLParser_v2.cpp 2016-08-04 13:21:05 +0000
4@@ -344,14 +344,15 @@
5 else if (firstLetter == 'i' ) {
6 //Construct Atom
7 std::string atom_str = "";
8+
9 if (root_name[1] == 's' ){
10 //Fireability Query File
11 atom_str = root->name();
12 atom_str = atom_str + "(";
13 root = root->first_node();
14- atom_str = atom_str + root->value();
15+ atom_str = atom_str + choppy(root->value());
16 for (xml_node<> * transition_node = root->next_sibling(); transition_node; transition_node = transition_node->next_sibling()) {
17- atom_str = atom_str + ", " + transition_node->value();
18+ atom_str = atom_str + ", " + choppy(transition_node->value());
19 }
20 atom_str = atom_str + ")";
21 }
22@@ -440,15 +441,15 @@
23
24 if (parameter->name()[0] == 't'){
25 xml_node<> * place_node = parameter->first_node();
26- parameter_str = parameter_str + place_node->value();
27+ parameter_str = parameter_str + choppy(place_node->value());
28 for(place_node = place_node->next_sibling(); place_node; place_node = place_node->next_sibling()){
29- parameter_str = parameter_str + ", " + place_node->value();
30+ parameter_str = parameter_str + ", " + choppy(place_node->value());
31 }
32 parameter_str = parameter_str + ")";
33 }
34
35 else if(parameter->name()[0] == 'i'){
36- parameter_str = parameter_str + parameter->value() + ")";
37+ parameter_str = parameter_str + choppy(parameter->value()) + ")";
38 }
39 else assert(false && "Failed parsing cardinality parameter. Incorrect format.");
40 return parameter_str;
41@@ -506,3 +507,14 @@
42 }
43 else assert(false && "ERROR::: Copying query failed");
44 }
45+
46+std::string CTLParser_v2::choppy( char *s )
47+{
48+ std::string res_str = "";
49+ for(int s_index = 0; s_index < strlen(s); s_index++){
50+ if(s[s_index] != '\n' && s[s_index] != '\t' && s[s_index] != '\r'){
51+ res_str = res_str + s[s_index];
52+ }
53+ }
54+ return res_str;
55+}
56\ No newline at end of file
57
58=== modified file 'CTLParser/CTLParser_v2.h'
59--- CTLParser/CTLParser_v2.h 2016-05-14 13:40:07 +0000
60+++ CTLParser/CTLParser_v2.h 2016-08-04 13:21:05 +0000
61@@ -19,6 +19,7 @@
62 #include <string>
63 #include <stdio.h>
64 #include "CTLQuery.h"
65+#include <string.h>
66
67 struct QueryMeta{
68 int numberof_queries = 0;
69@@ -26,6 +27,14 @@
70
71 };
72
73+struct RemoveDelimiter
74+{
75+ bool operator()(char c)
76+ {
77+ return (c =='\r' || c =='\t' || c == ' ' || c == '\n');
78+ }
79+};
80+
81 class CTLParser_v2 {
82 public:
83 CTLParser_v2();
84@@ -49,6 +58,7 @@
85 CTLQuery* TemporalSetting(CTLQuery* query);
86 int IdSetting(CTLQuery* query, int id);
87 QueryMeta *_meta;
88+ std::string choppy( char *s );
89
90 };
91

Subscribers

People subscribed via source and target branches