Merge lp:~verifydtapn-contributers/verifydtapn/timeDartPtrie into lp:verifydtapn

Proposed by Peter Gjøl Jensen
Status: Merged
Approved by: Jiri Srba
Approved revision: 437
Merged at revision: 276
Proposed branch: lp:~verifydtapn-contributers/verifydtapn/timeDartPtrie
Merge into: lp:verifydtapn
Diff against target: 9641 lines (+5659/-2401)
62 files modified
src/Core/ArgsParser.cpp (+366/-317)
src/Core/ArgsParser.hpp (+1/-1)
src/Core/QueryParser/Generated/lexer.cpp (+72/-57)
src/Core/QueryParser/Generated/location.hh (+42/-29)
src/Core/QueryParser/Generated/parser.cpp (+200/-249)
src/Core/QueryParser/Generated/parser.hpp (+35/-53)
src/Core/QueryParser/Generated/position.hh (+40/-32)
src/Core/QueryParser/Generated/stack.hh (+26/-30)
src/Core/TAPN/TimedArcPetriNet.cpp (+9/-0)
src/Core/TAPN/TimedTransition.hpp (+6/-3)
src/Core/VerificationOptions.cpp (+22/-13)
src/Core/VerificationOptions.hpp (+14/-5)
src/DiscreteVerification/DataStructures/EncodingStructure.cpp (+14/-0)
src/DiscreteVerification/DataStructures/EncodingStructure.h (+241/-0)
src/DiscreteVerification/DataStructures/NonStrictMarking.cpp (+0/-240)
src/DiscreteVerification/DataStructures/NonStrictMarking.hpp (+36/-158)
src/DiscreteVerification/DataStructures/NonStrictMarkingBase.cpp (+339/-0)
src/DiscreteVerification/DataStructures/NonStrictMarkingBase.hpp (+196/-0)
src/DiscreteVerification/DataStructures/PData.cpp (+16/-0)
src/DiscreteVerification/DataStructures/PData.h (+427/-0)
src/DiscreteVerification/DataStructures/PWList.cpp (+77/-8)
src/DiscreteVerification/DataStructures/PWList.hpp (+74/-9)
src/DiscreteVerification/DataStructures/TimeDart.hpp (+128/-0)
src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.cpp (+164/-0)
src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.hpp (+118/-0)
src/DiscreteVerification/DataStructures/TimeDartPWList.cpp (+126/-0)
src/DiscreteVerification/DataStructures/TimeDartPWList.hpp (+112/-0)
src/DiscreteVerification/DataStructures/WaitingList.cpp (+0/-202)
src/DiscreteVerification/DataStructures/WaitingList.hpp (+341/-39)
src/DiscreteVerification/DiscreteVerification.cpp (+129/-350)
src/DiscreteVerification/DiscreteVerification.hpp (+7/-7)
src/DiscreteVerification/QueryVisitor.cpp (+0/-75)
src/DiscreteVerification/QueryVisitor.hpp (+91/-25)
src/DiscreteVerification/SearchStrategies/LivenessWeightQueryVisitor.hpp (+2/-2)
src/DiscreteVerification/SearchStrategies/NonStrictBFS.hpp (+4/-4)
src/DiscreteVerification/SearchStrategies/NonStrictDFS.hpp (+4/-3)
src/DiscreteVerification/SearchStrategies/NonStrictDFSHeuristic.hpp (+3/-2)
src/DiscreteVerification/SearchStrategies/NonStrictDFSRandom.hpp (+4/-3)
src/DiscreteVerification/SearchStrategies/NonStrictHeuristic.hpp (+3/-2)
src/DiscreteVerification/SearchStrategies/NonStrictRandom.hpp (+4/-3)
src/DiscreteVerification/SearchStrategies/SearchFactory.h (+74/-0)
src/DiscreteVerification/SearchStrategies/SearchStrategies.hpp (+13/-0)
src/DiscreteVerification/SearchStrategies/SearchStrategy.hpp (+4/-1)
src/DiscreteVerification/SearchStrategies/WeightQueryVisitor.hpp (+2/-2)
src/DiscreteVerification/SuccessorGenerator.cpp (+0/-263)
src/DiscreteVerification/SuccessorGenerator.hpp (+413/-136)
src/DiscreteVerification/TimeDartSuccessorGenerator.cpp (+236/-0)
src/DiscreteVerification/TimeDartSuccessorGenerator.hpp (+65/-0)
src/DiscreteVerification/Util/IntervalOps.cpp (+79/-0)
src/DiscreteVerification/Util/IntervalOps.hpp (+30/-0)
src/DiscreteVerification/VerificationTypes/LivenessSearch.cpp (+44/-33)
src/DiscreteVerification/VerificationTypes/LivenessSearch.hpp (+22/-5)
src/DiscreteVerification/VerificationTypes/ReachabilitySearch.cpp (+43/-13)
src/DiscreteVerification/VerificationTypes/ReachabilitySearch.hpp (+28/-6)
src/DiscreteVerification/VerificationTypes/TimeDartLiveness.cpp (+196/-0)
src/DiscreteVerification/VerificationTypes/TimeDartLiveness.hpp (+86/-0)
src/DiscreteVerification/VerificationTypes/TimeDartReachabilitySearch.cpp (+126/-0)
src/DiscreteVerification/VerificationTypes/TimeDartReachabilitySearch.hpp (+78/-0)
src/DiscreteVerification/VerificationTypes/TimeDartVerification.cpp (+246/-0)
src/DiscreteVerification/VerificationTypes/TimeDartVerification.hpp (+67/-0)
src/DiscreteVerification/VerificationTypes/Verification.hpp (+309/-16)
src/compile-linux-32-64.sh (+5/-5)
To merge this branch: bzr merge lp:~verifydtapn-contributers/verifydtapn/timeDartPtrie
Reviewer Review Type Date Requested Status
Jakob Taankvist Approve
Mathias Grund Sørensen Approve
Jiri Srba Approve
Review via email: mp+154525@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Peter Gjøl Jensen (peter-gjoel) wrote :

Merge into trunk.

Revision history for this message
Jiri Srba (srba) wrote :

There are many conflicts. Please, resolve them.

review: Needs Fixing
428. By Peter Gjøl Jensen

fixed to short deadlock trace

429. By Peter Gjøl Jensen

should fix compile error

430. By Peter Gjøl Jensen

re-fixed short deadlock trace issue

Revision history for this message
Jiri Srba (srba) wrote :

the fix to deadlock trace seems to work;
the conflicts have to be resolved now before we can merge to trunk

431. By Peter Gjøl Jensen

merged with trunk

Revision history for this message
Peter Gjøl Jensen (peter-gjoel) wrote :

> There are many conflicts. Please, resolve them.

The conflicts should be resolved in last commit.

Revision history for this message
Jiri Srba (srba) wrote :

I found a net with wrongly reported deadlock. A separate bug report is made.

review: Needs Fixing
432. By Peter Gjøl Jensen

fix trace-loop detection delay for timedarts

433. By Peter Gjøl Jensen

trace-error seems fixed for naive engine

434. By Peter Gjøl Jensen

Seems to fix the trace issue for 2.xml as well as the delay in trace loop detection for timedarts

Revision history for this message
Jiri Srba (srba) wrote :

Now it passed almost all my tests, except for one that is reported as a separate bug.

review: Needs Fixing
435. By Peter Gjøl Jensen

Delay forever reported when loop is detected-bug fix

Revision history for this message
Jiri Srba (srba) wrote :

The problem seems fixed. The only small issue is that when I try this fix on 10.xml that I attached
to the bug report, sometimes I get

*delay 1
goto *

instead of

delay forever

Could this be fixed to delay for ever (as this is the same thing)?

Revision history for this message
Peter Gjøl Jensen (peter-gjoel) wrote :

I think so, yes - there is a bit of ambiguity between delay forever and loop-detection.
As you noted, the previous fix introduced this bug, as the fix was to remove a check.

I will attempt to find a nicer solution.

436. By Peter Gjøl Jensen

seems to have fixed the loop/delay for ever issue

437. By Peter Gjøl Jensen

fixed reintroduced bug

Revision history for this message
Jiri Srba (srba) wrote :

Now it passed all my tests. I suggest to (finally) merge it to trunk!
Any other issues should be then corrected in a separate branch.

Mathias and Jakob, please, take a look at the code to see if you find
any issues by inspecting the code and then approve.

review: Approve
Revision history for this message
Mathias Grund Sørensen (mathias.grund) wrote :

I think it looks pretty okay. I have a two (non-critical) comments (line numbers refer to changelog):

Line 2320-2328: Are transport arcs accounted for in GetPostset()? If not, it appears that it will be untimed even if it has transport arcs with timed postset (this might be an issue later I guess?).

Line 3489-3502: This loop should really be an else statement to the condition in line 3480-3486. Currently, we iterate over all tokens to test if any are older than c_max even though we just removed all tokens older than c_max --> twice the iterations for dead places (I know this is small, but because it is in cut it will be run a lot).

review: Approve
Revision history for this message
Jakob Taankvist (jakob-taankvist) wrote :

1) The file src/DiscreteVerification/DataStructures/EncodingStructure.cpp is practically empty?

2) The lines

2569 + void Release() const {
2570 + delete[] shadow;
2571 + }

seems a little dodgy? Shouldn't this be in the destructor?

3) The file src/DiscreteVerification/DataStructures/NonStrictMarking.cpp had it's contents deleted - but the file wasn't?

4) The file src/DiscreteVerification/DataStructures/PData.cpp is practically empty?

5) The comment "//possible mem-leek?" in line 3807 seems like it should be investigated?

I don't think the above have any functional implications, but it should be fixed at some point.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Core/ArgsParser.cpp'
--- src/Core/ArgsParser.cpp 2012-07-12 15:47:35 +0000
+++ src/Core/ArgsParser.cpp 2013-03-31 13:25:26 +0000
@@ -8,321 +8,370 @@
8#include "boost/tokenizer.hpp"8#include "boost/tokenizer.hpp"
99
10namespace VerifyTAPN {10namespace VerifyTAPN {
11 static const std::string KBOUND_OPTION = "k-bound";11static const std::string KBOUND_OPTION = "k-bound";
12 static const std::string SEARCH_OPTION = "search-type";12static const std::string SEARCH_OPTION = "search-type";
13 static const std::string TRACE_OPTION = "trace";13static const std::string VERIFICATION_OPTION = "verification-method";
14 static const std::string MAX_CONSTANT_OPTION = "global-max-constants";14static const std::string MEMORY_OPTIMIZATION_OPTION = "memory-optimization";
15 static const std::string XML_TRACE_OPTION = "xml-trace";15static const std::string TRACE_OPTION = "trace";
16 static const std::string LEGACY = "legacy";16static const std::string MAX_CONSTANT_OPTION = "global-max-constants";
17 static const std::string KEEP_DEAD = "keep-dead-tokens";17static const std::string XML_TRACE_OPTION = "xml-trace";
1818static const std::string LEGACY = "legacy";
19 std::ostream& operator<<(std::ostream& out, const Switch& flag)19static const std::string KEEP_DEAD = "keep-dead-tokens";
20 {20
21 flag.Print(out);21std::ostream& operator<<(std::ostream& out, const Switch& flag) {
22 return out;22 flag.Print(out);
23 }23 return out;
2424}
25 std::ostream& operator <<(std::ostream& out, const Version& version)25
26 {26std::ostream& operator <<(std::ostream& out, const Version& version) {
27 out << version.maj << "." << version.min << "." << version.build;27 out << version.maj << "." << version.min << "." << version.build;
28 return out;28 return out;
29 }29}
3030
31 void PrintIndentedDescription(std::ostream& out, const std::string& description)31void PrintIndentedDescription(std::ostream& out,
32 {32 const std::string& description) {
33 typedef boost::tokenizer<boost::char_separator<char> > tokens;33 typedef boost::tokenizer<boost::char_separator<char> > tokens;
34 tokens lines(description.begin(), description.end(), boost::char_separator<char>("\n", "", boost::keep_empty_tokens));34 tokens lines(description.begin(), description.end(),
35 bool first = true;35 boost::char_separator<char>("\n", "", boost::keep_empty_tokens));
36 for(tokens::const_iterator it = lines.begin(); it != lines.end(); it++)36 bool first = true;
37 {37 for (tokens::const_iterator it = lines.begin(); it != lines.end(); it++) {
38 if(!first){38 if (!first) {
39 out << std::setw(WIDTH) << " ";39 out << std::setw(WIDTH) << " ";
40 }40 }
41 out << *it << std::endl;41 out << *it << std::endl;
42 first = false;42 first = false;
43 }43 }
44 }44}
4545
46 void Switch::Print(std::ostream& out) const46void Switch::Print(std::ostream& out) const {
47 {47 std::stringstream s;
48 std::stringstream s;48 s << "-" << ShortName();
49 s << "-" << ShortName();49 s << " [ --" << LongName() << " ]";
50 s << " [ --" << LongName() << " ]";50 out << std::setw(WIDTH) << std::left << s.str();
51 out << std::setw(WIDTH) << std::left << s.str();51 PrintIndentedDescription(out, Description());
52 PrintIndentedDescription(out, Description());52}
53 };53;
5454
55 void SwitchWithArg::Print(std::ostream& out) const55void SwitchWithArg::Print(std::ostream& out) const {
56 {56 std::stringstream s;
57 std::stringstream s;57 s << "-" << ShortName();
58 s << "-" << ShortName();58 s << " [ --" << LongName() << " ] ";
59 s << " [ --" << LongName() << " ] ";59 s << " arg (=" << default_value << ")";
60 s << " arg (=" << default_value << ")";60 out << std::setw(WIDTH) << std::left << s.str();
61 out << std::setw(WIDTH) << std::left << s.str();61 PrintIndentedDescription(out, Description());
62 PrintIndentedDescription(out, Description());62}
63 };63;
6464
65 void SwitchWithStringArg::Print(std::ostream& out) const65void SwitchWithStringArg::Print(std::ostream& out) const {
66 {66 std::stringstream s;
67 std::stringstream s;67 s << "-" << ShortName();
68 s << "-" << ShortName();68 s << " [ --" << LongName() << " ] ";
69 s << " [ --" << LongName() << " ] ";69 s << " a1,a2,.. (=" << default_value << ")";
70 s << " a1,a2,.. (=" << default_value << ")";70 out << std::setw(WIDTH) << std::left << s.str();
71 out << std::setw(WIDTH) << std::left << s.str();71 PrintIndentedDescription(out, Description());
72 PrintIndentedDescription(out, Description());72}
73 };73;
7474
75 bool Switch::Handles(const std::string& flag) const75bool Switch::Handles(const std::string& flag) const {
76 {76 std::stringstream stream;
77 std::stringstream stream;77 stream << "-" << name << " ";
78 stream << "-" << name << " ";78 if (flag.find(stream.str()) != std::string::npos)
79 if(flag.find(stream.str()) != std::string::npos) return true;79 return true;
80 if(flag.find(long_name) != std::string::npos) return true;80 if (flag.find(long_name) != std::string::npos)
81 return false;81 return true;
82 };82 return false;
8383}
84 option Switch::Parse(const std::string& flag)84;
85 {85
86 assert(Handles(flag));86option Switch::Parse(const std::string& flag) {
87 handled_option = true;87 assert(Handles(flag));
88 return option(LongName(), "1");88 handled_option = true;
89 };89 return option(LongName(), "1");
9090}
9191;
92 option SwitchWithArg::Parse(const std::string& flag)92
93 {93option SwitchWithArg::Parse(const std::string& flag) {
94 assert(Handles(flag));94 assert(Handles(flag));
95 handled_option = true;95 handled_option = true;
96 std::string copy(flag);96 std::string copy(flag);
97 std::stringstream stream;97 std::stringstream stream;
98 stream << "-" << ShortName() << " ";98 stream << "-" << ShortName() << " ";
99 if(flag.find(stream.str()) != std::string::npos)99 if (flag.find(stream.str()) != std::string::npos) {
100 {100 boost::erase_all(copy, stream.str());
101 boost::erase_all(copy, stream.str());101 } else {
102 }102 std::stringstream long_name_stream;
103 else103 long_name_stream << "--" << LongName() << " ";
104 {104 boost::erase_all(copy, long_name_stream.str());
105 std::stringstream long_name_stream;105 }
106 long_name_stream << "--" << LongName() << " ";106 boost::trim(copy);
107 boost::erase_all(copy, long_name_stream.str());107 return option(LongName(), copy);
108 }108}
109 boost::trim(copy);109;
110 return option(LongName(), copy);110
111 };111option SwitchWithStringArg::Parse(const std::string& flag) {
112112 assert(Handles(flag));
113 option SwitchWithStringArg::Parse(const std::string& flag)113 handled_option = true;
114 {114 std::string copy(flag);
115 assert(Handles(flag));115 std::stringstream stream;
116 handled_option = true;116 stream << "-" << ShortName() << " ";
117 std::string copy(flag);117 if (flag.find(stream.str()) != std::string::npos) {
118 std::stringstream stream;118 boost::erase_all(copy, stream.str());
119 stream << "-" << ShortName() << " ";119 } else {
120 if(flag.find(stream.str()) != std::string::npos)120 std::stringstream long_name_stream;
121 {121 long_name_stream << "--" << LongName() << " ";
122 boost::erase_all(copy, stream.str());122 boost::erase_all(copy, long_name_stream.str());
123 }123 }
124 else124 boost::trim(copy);
125 {125 return option(LongName(), copy);
126 std::stringstream long_name_stream;126}
127 long_name_stream << "--" << LongName() << " ";127;
128 boost::erase_all(copy, long_name_stream.str());128
129 }129void ArgsParser::Initialize() {
130 boost::trim(copy);130 // NOTE: The Help() function only splits and indents descriptions based on newlines.
131 return option(LongName(), copy);131 // Each line in the description is assumed to fit within the remaining width
132 };132 // of the console, so keep descriptions short, or implement manual word-wrapping :).
133133 parsers.push_back(
134 void ArgsParser::Initialize()134 boost::make_shared<SwitchWithArg > ("k", KBOUND_OPTION,
135 {135 "Max tokens to use during exploration.", 0));
136 // NOTE: The Help() function only splits and indents descriptions based on newlines.136 parsers.push_back(
137 // Each line in the description is assumed to fit within the remaining width137 boost::make_shared<SwitchWithArg > ("o", SEARCH_OPTION,
138 // of the console, so keep descriptions short, or implement manual word-wrapping :).138 "Specify the desired search strategy.\n - 0: Breadth-First Search\n - 1: Depth-First Search\n - 2: Random Search\n - 3: Heuristic Search",
139 parsers.push_back(boost::make_shared<SwitchWithArg>("k", KBOUND_OPTION, "Max tokens to use during exploration.",0));139 3));
140 parsers.push_back(boost::make_shared<SwitchWithArg>("o", SEARCH_OPTION, "Specify the desired search strategy.\n - 0: Breadth-First Search\n - 1: Depth-First Search\n - 2: Random Search\n - 3: Heuristic Search",3));140 parsers.push_back(
141 parsers.push_back(boost::make_shared<SwitchWithArg>("t", TRACE_OPTION, "Specify the desired trace option.\n - 0: none\n - 1: some",0));141 boost::make_shared<SwitchWithArg > ("m", VERIFICATION_OPTION,
142 parsers.push_back(boost::make_shared<Switch>("d",KEEP_DEAD, "Do not discard dead tokens\n(used for boundedness checking)"));142 "Specify the desired verification method.\n - 0: Default (discrete)\n - 1: Time Darts",
143 parsers.push_back(boost::make_shared<Switch>("g",MAX_CONSTANT_OPTION, "Use global maximum constant for \nextrapolation (as opposed to local \nconstants)."));143 0)); // TODO change to 0!
144 parsers.push_back(boost::make_shared<Switch>("s",LEGACY, "Legacy option (no effect)."));144 parsers.push_back(
145145 boost::make_shared<SwitchWithArg > ("p", MEMORY_OPTIMIZATION_OPTION,
146 parsers.push_back(boost::make_shared<Switch>("x",XML_TRACE_OPTION, "Output trace in xml format for TAPAAL."));146 "Specify the desired memory optimization.\n - 0: None \n - 1: PTrie",
147 };147 1)); // TODO change to 0!
148148 parsers.push_back(
149 void ArgsParser::Help() const149 boost::make_shared<SwitchWithArg > ("t", TRACE_OPTION,
150 {150 "Specify the desired trace option.\n - 0: none\n - 1: some",
151 std::cout << "Usage: verifydtapn -k <number> [optional arguments] model-file query-file" << std::endl;151 0));
152 std::cout << "Allowed Options:" << std::endl;152 parsers.push_back(
153 std::cout << std::setw(WIDTH) << std::left << "-h [ --help ]" << "Displays this help message." << std::endl;153 boost::make_shared<Switch > ("d", KEEP_DEAD,
154 std::cout << std::setw(WIDTH) << std::left << "-v [ --version ]" << "Displays version information." << std::endl;154 "Do not discard dead tokens\n(used for boundedness checking)"));
155 for(parser_vec::const_iterator arg = parsers.begin(); arg != parsers.end(); arg++)155 parsers.push_back(
156 {156 boost::make_shared<Switch > ("g", MAX_CONSTANT_OPTION,
157 std::cout << **arg;157 "Use global maximum constant for \nextrapolation (as opposed to local \nconstants)."));
158 }158 parsers.push_back(
159 };159 boost::make_shared<Switch > ("s", LEGACY,
160160 "Legacy option (no effect)."));
161 void ArgsParser::Version() const161
162 {162 parsers.push_back(
163 std::cout << "VerifyDTAPN " << version << std::endl;163 boost::make_shared<Switch > ("x", XML_TRACE_OPTION,
164 std::cout << "Licensed under BSD." << std::endl;164 "Output trace in xml format for TAPAAL."));
165 }165};
166166
167 VerificationOptions ArgsParser::Parse(int argc, char* argv[]) const167void ArgsParser::Help() const {
168 {168 std::cout
169 if(argc == 1 || std::string(argv[1]) == "-h" || std::string(argv[1]) == "--help")169 << "Usage: verifydtapn -k <number> [optional arguments] model-file query-file"
170 {170 << std::endl;
171 Help();171 std::cout << "Allowed Options:" << std::endl;
172 exit(0);172 std::cout << std::setw(WIDTH) << std::left << "-h [ --help ]"
173 }173 << "Displays this help message." << std::endl;
174174 std::cout << std::setw(WIDTH) << std::left << "-v [ --version ]"
175 if(std::string(argv[1]) == "-v" || std::string(argv[1]) == "--version")175 << "Displays version information." << std::endl;
176 {176 for (parser_vec::const_iterator arg = parsers.begin(); arg != parsers.end();
177 Version();177 arg++) {
178 exit(0);178 std::cout << **arg;
179 }179 }
180180}
181 if(argc < 3)181;
182 {182
183 std::cout << "too few parameters." << std::endl;183void ArgsParser::Version() const {
184 std::cout << "Use '-h' for help on correct usage." << std::endl;184 std::cout << "VerifyDTAPN " << version << std::endl;
185 exit(1);185 std::cout << "Licensed under BSD." << std::endl;
186 }186}
187187
188 std::string model_file(argv[argc-2]);188VerificationOptions ArgsParser::Parse(int argc, char* argv[]) const {
189 std::string query_file(argv[argc-1]);189 if (argc == 1 || std::string(argv[1]) == "-h"
190190 || std::string(argv[1]) == "--help") {
191 if(boost::iends_with(query_file,".xml"))191 Help();
192 {192 exit(0);
193 std::cout << "Missing query file." << std::endl;193 }
194 exit(1);194
195 }195 if (std::string(argv[1]) == "-v" || std::string(argv[1]) == "--version") {
196196 Version();
197 if(!boost::iends_with(model_file,".xml"))197 exit(0);
198 {198 }
199 std::cout << "Invalid model file specified." << std::endl;199
200 exit(1);200 if (argc < 3) {
201 }201 std::cout << "too few parameters." << std::endl;
202202 std::cout << "Use '-h' for help on correct usage." << std::endl;
203 if(!boost::iends_with(query_file, ".q"))203 exit(1);
204 {204 }
205 std::cout << "Invalid query file specified." << std::endl;205
206 exit(1);206 std::string model_file(argv[argc - 2]);
207 }207 std::string query_file(argv[argc - 1]);
208208
209 std::vector<std::string> flags;209 if (boost::iends_with(query_file, ".xml")) {
210 unsigned int i = 1;210 std::cout << "Missing query file." << std::endl;
211 unsigned int size = static_cast<unsigned int>(argc);211 exit(1);
212 while(i < size-2)212 }
213 {213
214 std::string arg(argv[i]);214 if (!boost::iends_with(model_file, ".xml")) {
215 if(boost::istarts_with(arg, "-"))215 std::cout << "Invalid model file specified." << std::endl;
216 {216 exit(1);
217 std::string arg2(argv[i+1]);217 }
218 if(!boost::istarts_with(arg2,"-") && i+1 < size-2)218
219 {219 if (!boost::iends_with(query_file, ".q")) {
220 flags.push_back(arg + " " + arg2);220 std::cout << "Invalid query file specified." << std::endl;
221 i++;221 exit(1);
222 }else{222 }
223 flags.push_back(arg + " ");223
224 }224 std::vector<std::string> flags;
225 }225 unsigned int i = 1;
226 i++;226 unsigned int size = static_cast<unsigned int>(argc);
227 }227 while (i < size - 2) {
228228 std::string arg(argv[i]);
229 option_map options;229 if (boost::istarts_with(arg, "-")) {
230 for(std::vector<std::string>::const_iterator flag = flags.begin(); flag != flags.end(); flag++)230 std::string arg2(argv[i + 1]);
231 {231 if (!boost::istarts_with(arg2, "-") && i + 1 < size - 2) {
232 bool handled = false;232 flags.push_back(arg + " " + arg2);
233 for(parser_vec::const_iterator it = parsers.begin(); it != parsers.end(); it++)233 i++;
234 {234 } else {
235 if((*it)->Handles(*flag))235 flags.push_back(arg + " ");
236 {236 }
237 options.insert((*it)->Parse(*flag));237 }
238 handled = true;238 i++;
239 }239 }
240 }240
241 if(!handled)241 option_map options;
242 {242 for (std::vector<std::string>::const_iterator flag = flags.begin();
243 std::cout << "Unknown option flag '" << *flag << "'" << std::endl;243 flag != flags.end(); flag++) {
244 std::cout << "Use '-h' to see a list of valid options." << std::endl;244 bool handled = false;
245 exit(1);245 for (parser_vec::const_iterator it = parsers.begin();
246 }246 it != parsers.end(); it++) {
247 }247 if ((*it)->Handles(*flag)) {
248248 options.insert((*it)->Parse(*flag));
249 // Put in default values for non-specified options249 handled = true;
250 for(parser_vec::const_iterator it = parsers.begin(); it != parsers.end(); it++)250 }
251 {251 }
252 if(!(*it)->HandledOption())252 if (!handled) {
253 {253 std::cout << "Unknown option flag '" << *flag << "'" << std::endl;
254 options.insert((*it)->DefaultOption());254 std::cout << "Use '-h' to see a list of valid options."
255 }255 << std::endl;
256 }256 exit(1);
257257 }
258 return CreateVerificationOptions(options, model_file, query_file);258 }
259 }259
260260 // Put in default values for non-specified options
261 SearchType intToSearchTypeEnum(int i) {261 for (parser_vec::const_iterator it = parsers.begin(); it != parsers.end();
262 switch(i){262 it++) {
263 case 0: return BREADTHFIRST;263 if (!(*it)->HandledOption()) {
264 case 1: return DEPTHFIRST;264 options.insert((*it)->DefaultOption());
265 case 2: return RANDOM;265 }
266 case 3: return COVERMOST;266 }
267 default:267
268 std::cout << "Unknown search strategy specified." << std::endl;268 return CreateVerificationOptions(options, model_file, query_file);
269 exit(1);269}
270 }270
271 }271SearchType intToSearchTypeEnum(int i) {
272272 switch (i) {
273 Trace intToEnum(int i){273 case 0:
274 switch(i)274 return BREADTHFIRST;
275 {275 case 1:
276 case 0: return NONE;276 return DEPTHFIRST;
277 case 1: return SOME;277 case 2:
278 default:278 return RANDOM;
279 std::cout << "Unknown trace option specified." << std::endl;279 case 3:
280 exit(1);280 return COVERMOST;
281 }281 default:
282 }282 std::cout << "Unknown search strategy specified." << std::endl;
283283 exit(1);
284 unsigned int ArgsParser::TryParseInt(const option& option) const284 }
285 {285}
286 unsigned int result = 0;286
287 try287VerificationType intToVerificationTypeEnum(int i) {
288 {288 switch (i) {
289 result = boost::lexical_cast<unsigned int>(option.second);289 case 0:
290 }290 return DISCRETE;
291 catch(boost::bad_lexical_cast & e)291 case 1:
292 {292 return TIMEDART;
293 std::cout << "Invalid value '" << option.second << "' for option '--" << option.first << "'" << std::endl;293 default:
294 exit(1);294 std::cout << "Unknown verification method specified." << std::endl;
295 }295 exit(1);
296 return result;296 }
297 }297}
298298
299 std::vector<std::string> ArgsParser::ParseIncPlaces(const std::string& string) const299MemoryOptimization intToMemoryOptimizationEnum(int i) {
300 {300 switch (i) {
301 std::vector<std::string> vec;301 case 0:
302 boost::split( vec, string, boost::is_any_of(",") );302 return NO_MEMORY_OPTIMIZATION;
303 return vec;303 case 1:
304 }304 return PTRIE;
305305 default:
306 VerificationOptions ArgsParser::CreateVerificationOptions(const option_map& map, const std::string& modelFile, const std::string& queryFile) const306 std::cout << "Unknown memory optimization specified." << std::endl;
307 {307 exit(1);
308 assert(map.find(KBOUND_OPTION) != map.end());308 }
309 unsigned int kbound = TryParseInt(*map.find(KBOUND_OPTION));309}
310310
311 assert(map.find(SEARCH_OPTION) != map.end());311
312 SearchType search = intToSearchTypeEnum(TryParseInt(*map.find(SEARCH_OPTION)));312Trace intToEnum(int i) {
313313 switch (i) {
314 assert(map.find(TRACE_OPTION) != map.end());314 case 0:
315 Trace trace = intToEnum(TryParseInt(*map.find(TRACE_OPTION)));315 return NONE;
316316 case 1:
317 assert(map.find(MAX_CONSTANT_OPTION) != map.end());317 return SOME;
318 bool max_constant = boost::lexical_cast<bool>(map.find(MAX_CONSTANT_OPTION)->second);318 default:
319319 std::cout << "Unknown trace option specified." << std::endl;
320 assert(map.find(KEEP_DEAD) != map.end());320 exit(1);
321 bool keep_dead = boost::lexical_cast<bool>(map.find(KEEP_DEAD)->second);321 }
322322}
323 assert(map.find(XML_TRACE_OPTION) != map.end());323
324 bool xml_trace = boost::lexical_cast<bool>(map.find(XML_TRACE_OPTION)->second);324unsigned int ArgsParser::TryParseInt(const option& option) const {
325325 unsigned int result = 0;
326 return VerificationOptions(modelFile, queryFile, search, kbound, trace, xml_trace, max_constant, keep_dead);326 try {
327 }327 result = boost::lexical_cast<unsigned int>(option.second);
328 } catch (boost::bad_lexical_cast & e) {
329 std::cout << "Invalid value '" << option.second << "' for option '--"
330 << option.first << "'" << std::endl;
331 exit(1);
332 }
333 return result;
334}
335
336std::vector<std::string> ArgsParser::ParseIncPlaces(
337 const std::string& string) const {
338 std::vector<std::string> vec;
339 boost::split(vec, string, boost::is_any_of(","));
340 return vec;
341}
342
343VerificationOptions ArgsParser::CreateVerificationOptions(const option_map& map,
344 const std::string& modelFile, const std::string& queryFile) const {
345 assert(map.find(KBOUND_OPTION) != map.end());
346 unsigned int kbound = TryParseInt(*map.find(KBOUND_OPTION));
347
348 assert(map.find(SEARCH_OPTION) != map.end());
349 SearchType search = intToSearchTypeEnum(
350 TryParseInt(*map.find(SEARCH_OPTION)));
351
352 assert(map.find(VERIFICATION_OPTION) != map.end());
353 VerificationType verification = intToVerificationTypeEnum(
354 TryParseInt(*map.find(VERIFICATION_OPTION)));
355
356 assert(map.find(MEMORY_OPTIMIZATION_OPTION) != map.end());
357 MemoryOptimization memoptimization = intToMemoryOptimizationEnum(
358 TryParseInt(*map.find(MEMORY_OPTIMIZATION_OPTION)));
359
360 assert(map.find(TRACE_OPTION) != map.end());
361 Trace trace = intToEnum(TryParseInt(*map.find(TRACE_OPTION)));
362
363 assert(map.find(MAX_CONSTANT_OPTION) != map.end());
364 bool max_constant = boost::lexical_cast<bool>(
365 map.find(MAX_CONSTANT_OPTION)->second);
366
367 assert(map.find(KEEP_DEAD) != map.end());
368 bool keep_dead = boost::lexical_cast<bool>(map.find(KEEP_DEAD)->second);
369
370 assert(map.find(XML_TRACE_OPTION) != map.end());
371 bool xml_trace = boost::lexical_cast<bool>(
372 map.find(XML_TRACE_OPTION)->second);
373
374 return VerificationOptions(modelFile, queryFile, search, verification, memoptimization, kbound, trace,
375 xml_trace, max_constant, keep_dead);
376}
328}377}
329378
=== modified file 'src/Core/ArgsParser.hpp' (properties changed: +x to -x)
--- src/Core/ArgsParser.hpp 2012-11-29 00:53:29 +0000
+++ src/Core/ArgsParser.hpp 2013-03-31 13:25:26 +0000
@@ -80,7 +80,7 @@
80 class ArgsParser {80 class ArgsParser {
81 typedef std::vector< boost::shared_ptr<Switch> > parser_vec;81 typedef std::vector< boost::shared_ptr<Switch> > parser_vec;
82 public:82 public:
83 ArgsParser() : parsers(), version(1,0,1) { Initialize(); };83 ArgsParser() : parsers(), version(2,0,0) { Initialize(); };
84 virtual ~ArgsParser() {};84 virtual ~ArgsParser() {};
8585
86 VerificationOptions Parse(int argc, char* argv[]) const;86 VerificationOptions Parse(int argc, char* argv[]) const;
8787
=== modified file 'src/Core/QueryParser/Generated/lexer.cpp'
--- src/Core/QueryParser/Generated/lexer.cpp 2012-04-19 12:40:05 +0000
+++ src/Core/QueryParser/Generated/lexer.cpp 2013-03-31 13:25:26 +0000
@@ -1,6 +1,6 @@
1#line 2 "Generated/lexer.cpp"1#line 2 "Core/QueryParser/Generated/lexer.cpp"
22
3#line 4 "Generated/lexer.cpp"3#line 4 "Core/QueryParser/Generated/lexer.cpp"
44
5#define YY_INT_ALIGNED short int5#define YY_INT_ALIGNED short int
66
@@ -54,7 +54,6 @@
54typedef unsigned char flex_uint8_t; 54typedef unsigned char flex_uint8_t;
55typedef unsigned short int flex_uint16_t;55typedef unsigned short int flex_uint16_t;
56typedef unsigned int flex_uint32_t;56typedef unsigned int flex_uint32_t;
57#endif /* ! C99 */
5857
59/* Limits of integral types. */58/* Limits of integral types. */
60#ifndef INT8_MIN59#ifndef INT8_MIN
@@ -85,6 +84,8 @@
85#define UINT32_MAX (4294967295U)84#define UINT32_MAX (4294967295U)
86#endif85#endif
8786
87#endif /* ! C99 */
88
88#endif /* ! FLEXINT_H */89#endif /* ! FLEXINT_H */
8990
90#ifdef __cplusplus91#ifdef __cplusplus
@@ -141,7 +142,15 @@
141142
142/* Size of default input buffer. */143/* Size of default input buffer. */
143#ifndef YY_BUF_SIZE144#ifndef YY_BUF_SIZE
145#ifdef __ia64__
146/* On IA-64, the buffer size is 16k, not 8k.
147 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
148 * Ditto for the __ia64__ case accordingly.
149 */
150#define YY_BUF_SIZE 32768
151#else
144#define YY_BUF_SIZE 16384152#define YY_BUF_SIZE 16384
153#endif /* __ia64__ */
145#endif154#endif
146155
147/* The state buf must be large enough to hold one state per character in the main buffer.156/* The state buf must be large enough to hold one state per character in the main buffer.
@@ -153,12 +162,7 @@
153typedef struct yy_buffer_state *YY_BUFFER_STATE;162typedef struct yy_buffer_state *YY_BUFFER_STATE;
154#endif163#endif
155164
156#ifndef YY_TYPEDEF_YY_SIZE_T165extern int yyleng;
157#define YY_TYPEDEF_YY_SIZE_T
158typedef size_t yy_size_t;
159#endif
160
161extern yy_size_t yyleng;
162166
163extern FILE *yyin, *yyout;167extern FILE *yyin, *yyout;
164168
@@ -184,6 +188,11 @@
184188
185#define unput(c) yyunput( c, (yytext_ptr) )189#define unput(c) yyunput( c, (yytext_ptr) )
186190
191#ifndef YY_TYPEDEF_YY_SIZE_T
192#define YY_TYPEDEF_YY_SIZE_T
193typedef size_t yy_size_t;
194#endif
195
187#ifndef YY_STRUCT_YY_BUFFER_STATE196#ifndef YY_STRUCT_YY_BUFFER_STATE
188#define YY_STRUCT_YY_BUFFER_STATE197#define YY_STRUCT_YY_BUFFER_STATE
189struct yy_buffer_state198struct yy_buffer_state
@@ -201,7 +210,7 @@
201 /* Number of characters read into yy_ch_buf, not including EOB210 /* Number of characters read into yy_ch_buf, not including EOB
202 * characters.211 * characters.
203 */212 */
204 yy_size_t yy_n_chars;213 int yy_n_chars;
205214
206 /* Whether we "own" the buffer - i.e., we know we created it,215 /* Whether we "own" the buffer - i.e., we know we created it,
207 * and can realloc() it to grow it, and should free() it to216 * and can realloc() it to grow it, and should free() it to
@@ -271,8 +280,8 @@
271280
272/* yy_hold_char holds the character lost when yytext is formed. */281/* yy_hold_char holds the character lost when yytext is formed. */
273static char yy_hold_char;282static char yy_hold_char;
274static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */283static int yy_n_chars; /* number of characters read into yy_ch_buf */
275yy_size_t yyleng;284int yyleng;
276285
277/* Points to current character in buffer. */286/* Points to current character in buffer. */
278static char *yy_c_buf_p = (char *) 0;287static char *yy_c_buf_p = (char *) 0;
@@ -300,7 +309,7 @@
300309
301YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );310YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
302YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );311YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
303YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );312YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
304313
305void *yyalloc (yy_size_t );314void *yyalloc (yy_size_t );
306void *yyrealloc (void *,yy_size_t );315void *yyrealloc (void *,yy_size_t );
@@ -478,8 +487,8 @@
478#define YY_MORE_ADJ 0487#define YY_MORE_ADJ 0
479#define YY_RESTORE_YY_MORE_OFFSET488#define YY_RESTORE_YY_MORE_OFFSET
480char *yytext;489char *yytext;
481#line 1 "flex.ll"490#line 1 "Core/QueryParser/flex.ll"
482#line 2 "flex.ll"491#line 2 "Core/QueryParser/flex.ll"
483# include <string>492# include <string>
484# include "../TAPNQueryParser.hpp"493# include "../TAPNQueryParser.hpp"
485# include "parser.hpp"494# include "parser.hpp"
@@ -495,9 +504,9 @@
495 Unfortunately yyterminate by default returns 0, which is504 Unfortunately yyterminate by default returns 0, which is
496 not of token_type. */505 not of token_type. */
497#define yyterminate() return token::END506#define yyterminate() return token::END
498#line 26 "flex.ll"507#line 26 "Core/QueryParser/flex.ll"
499# define YY_USER_ACTION yylloc->columns (yyleng);508# define YY_USER_ACTION yylloc->columns (yyleng);
500#line 501 "Generated/lexer.cpp"509#line 510 "Core/QueryParser/Generated/lexer.cpp"
501510
502#define INITIAL 0511#define INITIAL 0
503512
@@ -536,7 +545,7 @@
536545
537void yyset_out (FILE * out_str );546void yyset_out (FILE * out_str );
538547
539yy_size_t yyget_leng (void );548int yyget_leng (void );
540549
541char *yyget_text (void );550char *yyget_text (void );
542551
@@ -576,7 +585,12 @@
576585
577/* Amount of stuff to slurp up with each read. */586/* Amount of stuff to slurp up with each read. */
578#ifndef YY_READ_BUF_SIZE587#ifndef YY_READ_BUF_SIZE
588#ifdef __ia64__
589/* On IA-64, the buffer size is 16k, not 8k */
590#define YY_READ_BUF_SIZE 16384
591#else
579#define YY_READ_BUF_SIZE 8192592#define YY_READ_BUF_SIZE 8192
593#endif /* __ia64__ */
580#endif594#endif
581595
582/* Copy whatever the last rule matched to the standard output. */596/* Copy whatever the last rule matched to the standard output. */
@@ -584,7 +598,7 @@
584/* This used to be an fputs(), but since the string might contain NUL's,598/* This used to be an fputs(), but since the string might contain NUL's,
585 * we now use fwrite().599 * we now use fwrite().
586 */600 */
587#define ECHO fwrite( yytext, yyleng, 1, yyout )601#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
588#endif602#endif
589603
590/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,604/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -595,7 +609,7 @@
595 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \609 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
596 { \610 { \
597 int c = '*'; \611 int c = '*'; \
598 yy_size_t n; \612 size_t n; \
599 for ( n = 0; n < max_size && \613 for ( n = 0; n < max_size && \
600 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \614 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
601 buf[n] = (char) c; \615 buf[n] = (char) c; \
@@ -680,12 +694,12 @@
680 register char *yy_cp, *yy_bp;694 register char *yy_cp, *yy_bp;
681 register int yy_act;695 register int yy_act;
682 696
683#line 28 "flex.ll"697#line 28 "Core/QueryParser/flex.ll"
684698
685699
686 yylloc->step ();700 yylloc->step ();
687701
688#line 689 "Generated/lexer.cpp"702#line 703 "Core/QueryParser/Generated/lexer.cpp"
689703
690 if ( !(yy_init) )704 if ( !(yy_init) )
691 {705 {
@@ -767,13 +781,13 @@
767781
768case 1:782case 1:
769YY_RULE_SETUP783YY_RULE_SETUP
770#line 32 "flex.ll"784#line 32 "Core/QueryParser/flex.ll"
771{ yylloc->step (); }785{ yylloc->step (); }
772 YY_BREAK786 YY_BREAK
773case 2:787case 2:
774/* rule 2 can match eol */788/* rule 2 can match eol */
775YY_RULE_SETUP789YY_RULE_SETUP
776#line 33 "flex.ll"790#line 33 "Core/QueryParser/flex.ll"
777{ yylloc->lines (yyleng); yylloc->step (); }791{ yylloc->lines (yyleng); yylloc->step (); }
778 YY_BREAK792 YY_BREAK
779793
@@ -781,105 +795,105 @@
781795
782case 3:796case 3:
783YY_RULE_SETUP797YY_RULE_SETUP
784#line 39 "flex.ll"798#line 39 "Core/QueryParser/flex.ll"
785{ yylval->number = atoi(yytext); return token::NUMBER; }799{ yylval->number = atoi(yytext); return token::NUMBER; }
786 YY_BREAK800 YY_BREAK
787case 4:801case 4:
788YY_RULE_SETUP802YY_RULE_SETUP
789#line 40 "flex.ll"803#line 40 "Core/QueryParser/flex.ll"
790{ return token::EF; }804{ return token::EF; }
791 YY_BREAK805 YY_BREAK
792case 5:806case 5:
793YY_RULE_SETUP807YY_RULE_SETUP
794#line 41 "flex.ll"808#line 41 "Core/QueryParser/flex.ll"
795{ return token::AG; }809{ return token::AG; }
796 YY_BREAK810 YY_BREAK
797case 6:811case 6:
798YY_RULE_SETUP812YY_RULE_SETUP
799#line 42 "flex.ll"813#line 42 "Core/QueryParser/flex.ll"
800{ return token::AF; }814{ return token::AF; }
801 YY_BREAK815 YY_BREAK
802case 7:816case 7:
803YY_RULE_SETUP817YY_RULE_SETUP
804#line 43 "flex.ll"818#line 43 "Core/QueryParser/flex.ll"
805{ return token::EG; }819{ return token::EG; }
806 YY_BREAK820 YY_BREAK
807case 8:821case 8:
808YY_RULE_SETUP822YY_RULE_SETUP
809#line 44 "flex.ll"823#line 44 "Core/QueryParser/flex.ll"
810{ return token::OR; }824{ return token::OR; }
811 YY_BREAK825 YY_BREAK
812case 9:826case 9:
813YY_RULE_SETUP827YY_RULE_SETUP
814#line 45 "flex.ll"828#line 45 "Core/QueryParser/flex.ll"
815{ return token::AND; }829{ return token::AND; }
816 YY_BREAK830 YY_BREAK
817case 10:831case 10:
818YY_RULE_SETUP832YY_RULE_SETUP
819#line 46 "flex.ll"833#line 46 "Core/QueryParser/flex.ll"
820{ return token::BOOL_TRUE; }834{ return token::BOOL_TRUE; }
821 YY_BREAK835 YY_BREAK
822case 11:836case 11:
823YY_RULE_SETUP837YY_RULE_SETUP
824#line 47 "flex.ll"838#line 47 "Core/QueryParser/flex.ll"
825{ return token::BOOL_FALSE; }839{ return token::BOOL_FALSE; }
826 YY_BREAK840 YY_BREAK
827case 12:841case 12:
828YY_RULE_SETUP842YY_RULE_SETUP
829#line 48 "flex.ll"843#line 48 "Core/QueryParser/flex.ll"
830{ return token::NOT; }844{ return token::NOT; }
831 YY_BREAK845 YY_BREAK
832case 13:846case 13:
833YY_RULE_SETUP847YY_RULE_SETUP
834#line 49 "flex.ll"848#line 49 "Core/QueryParser/flex.ll"
835{ return token::LPARAN; }849{ return token::LPARAN; }
836 YY_BREAK850 YY_BREAK
837case 14:851case 14:
838YY_RULE_SETUP852YY_RULE_SETUP
839#line 50 "flex.ll"853#line 50 "Core/QueryParser/flex.ll"
840{ return token::RPARAN; }854{ return token::RPARAN; }
841 YY_BREAK855 YY_BREAK
842case 15:856case 15:
843YY_RULE_SETUP857YY_RULE_SETUP
844#line 51 "flex.ll"858#line 51 "Core/QueryParser/flex.ll"
845{ yylval->string = new std::string(yytext); return token::LESS; }859{ yylval->string = new std::string(yytext); return token::LESS; }
846 YY_BREAK860 YY_BREAK
847case 16:861case 16:
848YY_RULE_SETUP862YY_RULE_SETUP
849#line 52 "flex.ll"863#line 52 "Core/QueryParser/flex.ll"
850{ yylval->string = new std::string(yytext); return token::LESSEQUAL; }864{ yylval->string = new std::string(yytext); return token::LESSEQUAL; }
851 YY_BREAK865 YY_BREAK
852case 17:866case 17:
853YY_RULE_SETUP867YY_RULE_SETUP
854#line 53 "flex.ll"868#line 53 "Core/QueryParser/flex.ll"
855{ yylval->string = new std::string(yytext); return token::EQUAL; }869{ yylval->string = new std::string(yytext); return token::EQUAL; }
856 YY_BREAK870 YY_BREAK
857case 18:871case 18:
858YY_RULE_SETUP872YY_RULE_SETUP
859#line 54 "flex.ll"873#line 54 "Core/QueryParser/flex.ll"
860{ yylval->string = new std::string(yytext); return token::EQUAL; }874{ yylval->string = new std::string(yytext); return token::EQUAL; }
861 YY_BREAK875 YY_BREAK
862case 19:876case 19:
863YY_RULE_SETUP877YY_RULE_SETUP
864#line 55 "flex.ll"878#line 55 "Core/QueryParser/flex.ll"
865{ yylval->string = new std::string(yytext); return token::GREATEREQUAL; }879{ yylval->string = new std::string(yytext); return token::GREATEREQUAL; }
866 YY_BREAK880 YY_BREAK
867case 20:881case 20:
868YY_RULE_SETUP882YY_RULE_SETUP
869#line 56 "flex.ll"883#line 56 "Core/QueryParser/flex.ll"
870{ yylval->string = new std::string(yytext); return token::GREATER; }884{ yylval->string = new std::string(yytext); return token::GREATER; }
871 YY_BREAK885 YY_BREAK
872case 21:886case 21:
873YY_RULE_SETUP887YY_RULE_SETUP
874#line 57 "flex.ll"888#line 57 "Core/QueryParser/flex.ll"
875{ yylval->string = new std::string(yytext); return token::IDENTIFIER; }889{ yylval->string = new std::string(yytext); return token::IDENTIFIER; }
876 YY_BREAK890 YY_BREAK
877case 22:891case 22:
878YY_RULE_SETUP892YY_RULE_SETUP
879#line 59 "flex.ll"893#line 59 "Core/QueryParser/flex.ll"
880ECHO;894ECHO;
881 YY_BREAK895 YY_BREAK
882#line 883 "Generated/lexer.cpp"896#line 897 "Core/QueryParser/Generated/lexer.cpp"
883case YY_STATE_EOF(INITIAL):897case YY_STATE_EOF(INITIAL):
884 yyterminate();898 yyterminate();
885899
@@ -1066,7 +1080,7 @@
10661080
1067 else1081 else
1068 {1082 {
1069 yy_size_t num_to_read =1083 int num_to_read =
1070 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;1084 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
10711085
1072 while ( num_to_read <= 0 )1086 while ( num_to_read <= 0 )
@@ -1080,7 +1094,7 @@
10801094
1081 if ( b->yy_is_our_buffer )1095 if ( b->yy_is_our_buffer )
1082 {1096 {
1083 yy_size_t new_size = b->yy_buf_size * 2;1097 int new_size = b->yy_buf_size * 2;
10841098
1085 if ( new_size <= 0 )1099 if ( new_size <= 0 )
1086 b->yy_buf_size += b->yy_buf_size / 8;1100 b->yy_buf_size += b->yy_buf_size / 8;
@@ -1111,7 +1125,7 @@
11111125
1112 /* Read in more data. */1126 /* Read in more data. */
1113 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),1127 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1114 (yy_n_chars), num_to_read );1128 (yy_n_chars), (size_t) num_to_read );
11151129
1116 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);1130 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1117 }1131 }
@@ -1234,7 +1248,7 @@
12341248
1235 else1249 else
1236 { /* need more input */1250 { /* need more input */
1237 yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);1251 int offset = (yy_c_buf_p) - (yytext_ptr);
1238 ++(yy_c_buf_p);1252 ++(yy_c_buf_p);
12391253
1240 switch ( yy_get_next_buffer( ) )1254 switch ( yy_get_next_buffer( ) )
@@ -1258,7 +1272,7 @@
1258 case EOB_ACT_END_OF_FILE:1272 case EOB_ACT_END_OF_FILE:
1259 {1273 {
1260 if ( yywrap( ) )1274 if ( yywrap( ) )
1261 return 0;1275 return EOF;
12621276
1263 if ( ! (yy_did_buffer_switch_on_eof) )1277 if ( ! (yy_did_buffer_switch_on_eof) )
1264 YY_NEW_FILE;1278 YY_NEW_FILE;
@@ -1512,7 +1526,7 @@
1512 */1526 */
1513static void yyensure_buffer_stack (void)1527static void yyensure_buffer_stack (void)
1514{1528{
1515 yy_size_t num_to_alloc;1529 int num_to_alloc;
1516 1530
1517 if (!(yy_buffer_stack)) {1531 if (!(yy_buffer_stack)) {
15181532
@@ -1604,16 +1618,17 @@
16041618
1605/** Setup the input buffer state to scan the given bytes. The next call to yylex() will1619/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1606 * scan from a @e copy of @a bytes.1620 * scan from a @e copy of @a bytes.
1607 * @param bytes the byte buffer to scan1621 * @param yybytes the byte buffer to scan
1608 * @param len the number of bytes in the buffer pointed to by @a bytes.1622 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1609 * 1623 *
1610 * @return the newly allocated buffer state object.1624 * @return the newly allocated buffer state object.
1611 */1625 */
1612YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )1626YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
1613{1627{
1614 YY_BUFFER_STATE b;1628 YY_BUFFER_STATE b;
1615 char *buf;1629 char *buf;
1616 yy_size_t n, i;1630 yy_size_t n;
1631 int i;
1617 1632
1618 /* Get memory for full buffer, including space for trailing EOB's. */1633 /* Get memory for full buffer, including space for trailing EOB's. */
1619 n = _yybytes_len + 2;1634 n = _yybytes_len + 2;
@@ -1695,7 +1710,7 @@
1695/** Get the length of the current token.1710/** Get the length of the current token.
1696 * 1711 *
1697 */1712 */
1698yy_size_t yyget_leng (void)1713int yyget_leng (void)
1699{1714{
1700 return yyleng;1715 return yyleng;
1701}1716}
@@ -1843,7 +1858,7 @@
18431858
1844#define YYTABLES_NAME "yytables"1859#define YYTABLES_NAME "yytables"
18451860
1846#line 59 "flex.ll"1861#line 59 "Core/QueryParser/flex.ll"
18471862
18481863
1849namespace VerifyTAPN1864namespace VerifyTAPN
18501865
=== modified file 'src/Core/QueryParser/Generated/location.hh'
--- src/Core/QueryParser/Generated/location.hh 2012-04-19 12:40:05 +0000
+++ src/Core/QueryParser/Generated/location.hh 2013-03-31 13:25:26 +0000
@@ -1,8 +1,8 @@
1/* A Bison parser, made by GNU Bison 2.5. */1/* A Bison parser, made by GNU Bison 2.6.5. */
22
3/* Locations for Bison parsers in C++3/* Locations for Bison parsers in C++
4 4
5 Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc.5 Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc.
6 6
7 This program is free software: you can redistribute it and/or modify7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by8 it under the terms of the GNU General Public License as published by
@@ -31,41 +31,56 @@
31 version 2.2 of Bison. */31 version 2.2 of Bison. */
3232
33/**33/**
34 ** \file location.hh34 ** \file Core/QueryParser/Generated/location.hh
35 ** Define the VerifyTAPN::location class.35 ** Define the VerifyTAPN::location class.
36 */36 */
3737
38#ifndef BISON_LOCATION_HH38#ifndef YY_YY_CORE_QUERYPARSER_GENERATED_LOCATION_HH_INCLUDED
39# define BISON_LOCATION_HH39# define YY_YY_CORE_QUERYPARSER_GENERATED_LOCATION_HH_INCLUDED
4040
41# include <iostream>
42# include <string>
43# include "position.hh"41# include "position.hh"
4442
4543/* Line 164 of location.cc */
46/* Line 162 of location.cc */44#line 5 "Core/QueryParser/grammar.yy"
47#line 5 "grammar.yy"
48namespace VerifyTAPN {45namespace VerifyTAPN {
4946/* Line 164 of location.cc */
50/* Line 162 of location.cc */47#line 48 "Core/QueryParser/Generated/location.hh"
51#line 52 "Generated/location.hh"
5248
53 /// Abstract a location.49 /// Abstract a location.
54 class location50 class location
55 {51 {
56 public:52 public:
5753
58 /// Construct a location.54 /// Construct a location from \a b to \a e.
59 location ()55 location (const position& b, const position& e)
60 : begin (), end ()56 : begin (b)
57 , end (e)
58 {
59 }
60
61 /// Construct a 0-width location in \a p.
62 explicit location (const position& p = position ())
63 : begin (p)
64 , end (p)
65 {
66 }
67
68 /// Construct a 0-width location in \a f, \a l, \a c.
69 explicit location (std::string* f,
70 unsigned int l = 1u,
71 unsigned int c = 1u)
72 : begin (f, l, c)
73 , end (f, l, c)
61 {74 {
62 }75 }
6376
6477
65 /// Initialization.78 /// Initialization.
66 inline void initialize (std::string* fn)79 void initialize (std::string* f = YY_NULL,
80 unsigned int l = 1u,
81 unsigned int c = 1u)
67 {82 {
68 begin.initialize (fn);83 begin.initialize (f, l, c);
69 end = begin;84 end = begin;
70 }85 }
7186
@@ -73,19 +88,19 @@
73 ** \{ */88 ** \{ */
74 public:89 public:
75 /// Reset initial location to final location.90 /// Reset initial location to final location.
76 inline void step ()91 void step ()
77 {92 {
78 begin = end;93 begin = end;
79 }94 }
8095
81 /// Extend the current location to the COUNT next columns.96 /// Extend the current location to the COUNT next columns.
82 inline void columns (unsigned int count = 1)97 void columns (unsigned int count = 1)
83 {98 {
84 end += count;99 end += count;
85 }100 }
86101
87 /// Extend the current location to the COUNT next lines.102 /// Extend the current location to the COUNT next lines.
88 inline void lines (unsigned int count = 1)103 void lines (unsigned int count = 1)
89 {104 {
90 end.lines (count);105 end.lines (count);
91 }106 }
@@ -157,12 +172,10 @@
157 return ostr;172 return ostr;
158 }173 }
159174
160175/* Line 292 of location.cc */
161/* Line 271 of location.cc */176#line 5 "Core/QueryParser/grammar.yy"
162#line 5 "grammar.yy"
163} // VerifyTAPN177} // VerifyTAPN
164178/* Line 292 of location.cc */
165/* Line 271 of location.cc */179#line 180 "Core/QueryParser/Generated/location.hh"
166#line 167 "Generated/location.hh"180
167181#endif /* !YY_YY_CORE_QUERYPARSER_GENERATED_LOCATION_HH_INCLUDED */
168#endif // not BISON_LOCATION_HH
169182
=== modified file 'src/Core/QueryParser/Generated/parser.cpp'
--- src/Core/QueryParser/Generated/parser.cpp 2012-04-19 12:40:05 +0000
+++ src/Core/QueryParser/Generated/parser.cpp 2013-03-31 13:25:26 +0000
@@ -1,8 +1,8 @@
1/* A Bison parser, made by GNU Bison 2.5. */1/* A Bison parser, made by GNU Bison 2.6.5. */
22
3/* Skeleton implementation for Bison LALR(1) parsers in C++3/* Skeleton implementation for Bison LALR(1) parsers in C++
4 4
5 Copyright (C) 2002-2011 Free Software Foundation, Inc.5 Copyright (C) 2002-2012 Free Software Foundation, Inc.
6 6
7 This program is free software: you can redistribute it and/or modify7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by8 it under the terms of the GNU General Public License as published by
@@ -33,29 +33,34 @@
3333
34/* First part of user declarations. */34/* First part of user declarations. */
3535
3636/* Line 278 of lalr1.cc */
37/* Line 293 of lalr1.cc */37#line 38 "Core/QueryParser/Generated/parser.cpp"
38#line 39 "Generated/parser.cpp"
3938
4039
41#include "parser.hpp"40#include "parser.hpp"
4241
43/* User implementation prologue. */42/* User implementation prologue. */
4443
4544/* Line 284 of lalr1.cc */
46/* Line 299 of lalr1.cc */45#line 46 "Core/QueryParser/Generated/parser.cpp"
47#line 48 "Generated/parser.cpp"
48/* Unqualified %code blocks. */46/* Unqualified %code blocks. */
4947/* Line 285 of lalr1.cc */
50/* Line 300 of lalr1.cc */48#line 37 "Core/QueryParser/grammar.yy"
51#line 37 "grammar.yy"
5249
53 #include "../TAPNQueryParser.hpp"50 #include "../TAPNQueryParser.hpp"
5451
5552
5653/* Line 285 of lalr1.cc */
57/* Line 300 of lalr1.cc */54#line 55 "Core/QueryParser/Generated/parser.cpp"
58#line 59 "Generated/parser.cpp"55
56
57# ifndef YY_NULL
58# if defined __cplusplus && 201103L <= __cplusplus
59# define YY_NULL nullptr
60# else
61# define YY_NULL 0
62# endif
63# endif
5964
60#ifndef YY_65#ifndef YY_
61# if defined YYENABLE_NLS && YYENABLE_NLS66# if defined YYENABLE_NLS && YYENABLE_NLS
@@ -69,25 +74,26 @@
69# endif74# endif
70#endif75#endif
7176
77#define YYRHSLOC(Rhs, K) ((Rhs)[K])
72/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].78/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
73 If N is 0, then set CURRENT to the empty location which ends79 If N is 0, then set CURRENT to the empty location which ends
74 the previous symbol: RHS[0] (always defined). */80 the previous symbol: RHS[0] (always defined). */
7581
76#define YYRHSLOC(Rhs, K) ((Rhs)[K])82# ifndef YYLLOC_DEFAULT
77#ifndef YYLLOC_DEFAULT83# define YYLLOC_DEFAULT(Current, Rhs, N) \
78# define YYLLOC_DEFAULT(Current, Rhs, N) \84 do \
79 do \85 if (N) \
80 if (N) \86 { \
81 { \87 (Current).begin = YYRHSLOC (Rhs, 1).begin; \
82 (Current).begin = YYRHSLOC (Rhs, 1).begin; \88 (Current).end = YYRHSLOC (Rhs, N).end; \
83 (Current).end = YYRHSLOC (Rhs, N).end; \89 } \
84 } \90 else \
85 else \91 { \
86 { \92 (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
87 (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \93 } \
88 } \94 while (/*CONSTCOND*/ false)
89 while (false)95# endif
90#endif96
9197
92/* Suppress unused-variable warnings by "using" E. */98/* Suppress unused-variable warnings by "using" E. */
93#define YYUSE(e) ((void) (e))99#define YYUSE(e) ((void) (e))
@@ -137,13 +143,11 @@
137#define YYERROR goto yyerrorlab143#define YYERROR goto yyerrorlab
138#define YYRECOVERING() (!!yyerrstatus_)144#define YYRECOVERING() (!!yyerrstatus_)
139145
140146/* Line 352 of lalr1.cc */
141/* Line 382 of lalr1.cc */147#line 5 "Core/QueryParser/grammar.yy"
142#line 5 "grammar.yy"
143namespace VerifyTAPN {148namespace VerifyTAPN {
144149/* Line 352 of lalr1.cc */
145/* Line 382 of lalr1.cc */150#line 151 "Core/QueryParser/Generated/parser.cpp"
146#line 147 "Generated/parser.cpp"
147151
148 /* Return YYSTR after stripping away unnecessary quotes and152 /* Return YYSTR after stripping away unnecessary quotes and
149 backslashes, so that it's suitable for yyerror. The heuristic is153 backslashes, so that it's suitable for yyerror. The heuristic is
@@ -209,6 +213,9 @@
209 {213 {
210 YYUSE (yylocationp);214 YYUSE (yylocationp);
211 YYUSE (yyvaluep);215 YYUSE (yyvaluep);
216 std::ostream& yyo = debug_stream ();
217 std::ostream& yyoutput = yyo;
218 YYUSE (yyoutput);
212 switch (yytype)219 switch (yytype)
213 {220 {
214 default:221 default:
@@ -241,140 +248,110 @@
241248
242 switch (yytype)249 switch (yytype)
243 {250 {
244 case 3: /* "IDENTIFIER" */251 case 3: /* IDENTIFIER */
245252/* Line 453 of lalr1.cc */
246/* Line 480 of lalr1.cc */253#line 52 "Core/QueryParser/grammar.yy"
247#line 52 "grammar.yy"254 { delete ((*yyvaluep).string); };
248 { delete (yyvaluep->string); };255/* Line 453 of lalr1.cc */
249256#line 257 "Core/QueryParser/Generated/parser.cpp"
250/* Line 480 of lalr1.cc */257 break;
251#line 252 "Generated/parser.cpp"258 case 4: /* LESS */
252 break;259/* Line 453 of lalr1.cc */
253 case 4: /* "LESS" */260#line 52 "Core/QueryParser/grammar.yy"
254261 { delete ((*yyvaluep).string); };
255/* Line 480 of lalr1.cc */262/* Line 453 of lalr1.cc */
256#line 52 "grammar.yy"263#line 264 "Core/QueryParser/Generated/parser.cpp"
257 { delete (yyvaluep->string); };264 break;
258265 case 5: /* LESSEQUAL */
259/* Line 480 of lalr1.cc */266/* Line 453 of lalr1.cc */
260#line 261 "Generated/parser.cpp"267#line 52 "Core/QueryParser/grammar.yy"
261 break;268 { delete ((*yyvaluep).string); };
262 case 5: /* "LESSEQUAL" */269/* Line 453 of lalr1.cc */
263270#line 271 "Core/QueryParser/Generated/parser.cpp"
264/* Line 480 of lalr1.cc */271 break;
265#line 52 "grammar.yy"272 case 6: /* EQUAL */
266 { delete (yyvaluep->string); };273/* Line 453 of lalr1.cc */
267274#line 52 "Core/QueryParser/grammar.yy"
268/* Line 480 of lalr1.cc */275 { delete ((*yyvaluep).string); };
269#line 270 "Generated/parser.cpp"276/* Line 453 of lalr1.cc */
270 break;277#line 278 "Core/QueryParser/Generated/parser.cpp"
271 case 6: /* "EQUAL" */278 break;
272279 case 7: /* GREATEREQUAL */
273/* Line 480 of lalr1.cc */280/* Line 453 of lalr1.cc */
274#line 52 "grammar.yy"281#line 52 "Core/QueryParser/grammar.yy"
275 { delete (yyvaluep->string); };282 { delete ((*yyvaluep).string); };
276283/* Line 453 of lalr1.cc */
277/* Line 480 of lalr1.cc */284#line 285 "Core/QueryParser/Generated/parser.cpp"
278#line 279 "Generated/parser.cpp"285 break;
279 break;286 case 8: /* GREATER */
280 case 7: /* "GREATEREQUAL" */287/* Line 453 of lalr1.cc */
281288#line 52 "Core/QueryParser/grammar.yy"
282/* Line 480 of lalr1.cc */289 { delete ((*yyvaluep).string); };
283#line 52 "grammar.yy"290/* Line 453 of lalr1.cc */
284 { delete (yyvaluep->string); };291#line 292 "Core/QueryParser/Generated/parser.cpp"
285292 break;
286/* Line 480 of lalr1.cc */293 case 22: /* query */
287#line 288 "Generated/parser.cpp"294/* Line 453 of lalr1.cc */
288 break;295#line 54 "Core/QueryParser/grammar.yy"
289 case 8: /* "GREATER" */296 { delete ((*yyvaluep).query); };
290297/* Line 453 of lalr1.cc */
291/* Line 480 of lalr1.cc */298#line 299 "Core/QueryParser/Generated/parser.cpp"
292#line 52 "grammar.yy"299 break;
293 { delete (yyvaluep->string); };300 case 23: /* expression */
294301/* Line 453 of lalr1.cc */
295/* Line 480 of lalr1.cc */302#line 53 "Core/QueryParser/grammar.yy"
296#line 297 "Generated/parser.cpp"303 { delete ((*yyvaluep).expr); };
297 break;304/* Line 453 of lalr1.cc */
298 case 22: /* "query" */305#line 306 "Core/QueryParser/Generated/parser.cpp"
299306 break;
300/* Line 480 of lalr1.cc */307 case 24: /* parExpression */
301#line 54 "grammar.yy"308/* Line 453 of lalr1.cc */
302 { delete (yyvaluep->query); };309#line 53 "Core/QueryParser/grammar.yy"
303310 { delete ((*yyvaluep).expr); };
304/* Line 480 of lalr1.cc */311/* Line 453 of lalr1.cc */
305#line 306 "Generated/parser.cpp"312#line 313 "Core/QueryParser/Generated/parser.cpp"
306 break;313 break;
307 case 23: /* "expression" */314 case 25: /* notExpression */
308315/* Line 453 of lalr1.cc */
309/* Line 480 of lalr1.cc */316#line 53 "Core/QueryParser/grammar.yy"
310#line 53 "grammar.yy"317 { delete ((*yyvaluep).expr); };
311 { delete (yyvaluep->expr); };318/* Line 453 of lalr1.cc */
312319#line 320 "Core/QueryParser/Generated/parser.cpp"
313/* Line 480 of lalr1.cc */320 break;
314#line 315 "Generated/parser.cpp"321 case 26: /* orExpression */
315 break;322/* Line 453 of lalr1.cc */
316 case 24: /* "parExpression" */323#line 53 "Core/QueryParser/grammar.yy"
317324 { delete ((*yyvaluep).expr); };
318/* Line 480 of lalr1.cc */325/* Line 453 of lalr1.cc */
319#line 53 "grammar.yy"326#line 327 "Core/QueryParser/Generated/parser.cpp"
320 { delete (yyvaluep->expr); };327 break;
321328 case 27: /* andExpression */
322/* Line 480 of lalr1.cc */329/* Line 453 of lalr1.cc */
323#line 324 "Generated/parser.cpp"330#line 53 "Core/QueryParser/grammar.yy"
324 break;331 { delete ((*yyvaluep).expr); };
325 case 25: /* "notExpression" */332/* Line 453 of lalr1.cc */
326333#line 334 "Core/QueryParser/Generated/parser.cpp"
327/* Line 480 of lalr1.cc */334 break;
328#line 53 "grammar.yy"335 case 28: /* boolExpression */
329 { delete (yyvaluep->expr); };336/* Line 453 of lalr1.cc */
330337#line 53 "Core/QueryParser/grammar.yy"
331/* Line 480 of lalr1.cc */338 { delete ((*yyvaluep).expr); };
332#line 333 "Generated/parser.cpp"339/* Line 453 of lalr1.cc */
333 break;340#line 341 "Core/QueryParser/Generated/parser.cpp"
334 case 26: /* "orExpression" */341 break;
335342 case 29: /* atomicProposition */
336/* Line 480 of lalr1.cc */343/* Line 453 of lalr1.cc */
337#line 53 "grammar.yy"344#line 53 "Core/QueryParser/grammar.yy"
338 { delete (yyvaluep->expr); };345 { delete ((*yyvaluep).expr); };
339346/* Line 453 of lalr1.cc */
340/* Line 480 of lalr1.cc */347#line 348 "Core/QueryParser/Generated/parser.cpp"
341#line 342 "Generated/parser.cpp"348 break;
342 break;349 case 30: /* compareOp */
343 case 27: /* "andExpression" */350/* Line 453 of lalr1.cc */
344351#line 52 "Core/QueryParser/grammar.yy"
345/* Line 480 of lalr1.cc */352 { delete ((*yyvaluep).string); };
346#line 53 "grammar.yy"353/* Line 453 of lalr1.cc */
347 { delete (yyvaluep->expr); };354#line 355 "Core/QueryParser/Generated/parser.cpp"
348
349/* Line 480 of lalr1.cc */
350#line 351 "Generated/parser.cpp"
351 break;
352 case 28: /* "boolExpression" */
353
354/* Line 480 of lalr1.cc */
355#line 53 "grammar.yy"
356 { delete (yyvaluep->expr); };
357
358/* Line 480 of lalr1.cc */
359#line 360 "Generated/parser.cpp"
360 break;
361 case 29: /* "atomicProposition" */
362
363/* Line 480 of lalr1.cc */
364#line 53 "grammar.yy"
365 { delete (yyvaluep->expr); };
366
367/* Line 480 of lalr1.cc */
368#line 369 "Generated/parser.cpp"
369 break;
370 case 30: /* "compareOp" */
371
372/* Line 480 of lalr1.cc */
373#line 52 "grammar.yy"
374 { delete (yyvaluep->string); };
375
376/* Line 480 of lalr1.cc */
377#line 378 "Generated/parser.cpp"
378 break;355 break;
379356
380 default:357 default:
@@ -436,17 +413,18 @@
436 int yychar = yyempty_;413 int yychar = yyempty_;
437 int yytoken = 0;414 int yytoken = 0;
438415
439 /* State. */416 // State.
440 int yyn;417 int yyn;
441 int yylen = 0;418 int yylen = 0;
442 int yystate = 0;419 int yystate = 0;
443420
444 /* Error handling. */421 // Error handling.
445 int yynerrs_ = 0;422 int yynerrs_ = 0;
446 int yyerrstatus_ = 0;423 int yyerrstatus_ = 0;
447424
448 /// Semantic value of the lookahead.425 /// Semantic value of the lookahead.
449 semantic_type yylval;426 static semantic_type yyval_default;
427 semantic_type yylval = yyval_default;
450 /// Location of the lookahead.428 /// Location of the lookahead.
451 location_type yylloc;429 location_type yylloc;
452 /// The locations where the error started and ended.430 /// The locations where the error started and ended.
@@ -462,17 +440,15 @@
462 YYCDEBUG << "Starting parse" << std::endl;440 YYCDEBUG << "Starting parse" << std::endl;
463441
464442
465 /* User initialization code. */443/* User initialization code. */
466 444/* Line 539 of lalr1.cc */
467/* Line 565 of lalr1.cc */445#line 21 "Core/QueryParser/grammar.yy"
468#line 21 "grammar.yy"
469{446{
470 // Initialize the initial location.447 // Initialize the initial location.
471 yylloc.begin.filename = yylloc.end.filename = &driver.file;448 yylloc.begin.filename = yylloc.end.filename = &driver.file;
472}449}
473450/* Line 539 of lalr1.cc */
474/* Line 565 of lalr1.cc */451#line 452 "Core/QueryParser/Generated/parser.cpp"
475#line 476 "Generated/parser.cpp"
476452
477 /* Initialize the stacks. The initial state will be pushed in453 /* Initialize the stacks. The initial state will be pushed in
478 yynewstate, since the latter expects the semantical and the454 yynewstate, since the latter expects the semantical and the
@@ -510,7 +486,6 @@
510 yychar = yylex (&yylval, &yylloc, driver);486 yychar = yylex (&yylval, &yylloc, driver);
511 }487 }
512488
513
514 /* Convert token to internal form. */489 /* Convert token to internal form. */
515 if (yychar <= yyeof_)490 if (yychar <= yyeof_)
516 {491 {
@@ -589,121 +564,104 @@
589 switch (yyn)564 switch (yyn)
590 {565 {
591 case 2:566 case 2:
592567/* Line 661 of lalr1.cc */
593/* Line 690 of lalr1.cc */568#line 58 "Core/QueryParser/grammar.yy"
594#line 58 "grammar.yy"
595 { (yyval.query) = new VerifyTAPN::AST::Query(VerifyTAPN::AST::EF, (yysemantic_stack_[(2) - (2)].expr)); driver.SetAST((yyval.query)); }569 { (yyval.query) = new VerifyTAPN::AST::Query(VerifyTAPN::AST::EF, (yysemantic_stack_[(2) - (2)].expr)); driver.SetAST((yyval.query)); }
596 break;570 break;
597571
598 case 3:572 case 3:
599573/* Line 661 of lalr1.cc */
600/* Line 690 of lalr1.cc */574#line 59 "Core/QueryParser/grammar.yy"
601#line 59 "grammar.yy"
602 { (yyval.query) = new VerifyTAPN::AST::Query(VerifyTAPN::AST::AG, (yysemantic_stack_[(2) - (2)].expr)); driver.SetAST((yyval.query)); }575 { (yyval.query) = new VerifyTAPN::AST::Query(VerifyTAPN::AST::AG, (yysemantic_stack_[(2) - (2)].expr)); driver.SetAST((yyval.query)); }
603 break;576 break;
604577
605 case 4:578 case 4:
606579/* Line 661 of lalr1.cc */
607/* Line 690 of lalr1.cc */580#line 60 "Core/QueryParser/grammar.yy"
608#line 60 "grammar.yy"
609 { (yyval.query) = new VerifyTAPN::AST::Query(VerifyTAPN::AST::EG, (yysemantic_stack_[(2) - (2)].expr)); driver.SetAST((yyval.query)); }581 { (yyval.query) = new VerifyTAPN::AST::Query(VerifyTAPN::AST::EG, (yysemantic_stack_[(2) - (2)].expr)); driver.SetAST((yyval.query)); }
610 break;582 break;
611583
612 case 5:584 case 5:
613585/* Line 661 of lalr1.cc */
614/* Line 690 of lalr1.cc */586#line 61 "Core/QueryParser/grammar.yy"
615#line 61 "grammar.yy"
616 { (yyval.query) = new VerifyTAPN::AST::Query(VerifyTAPN::AST::AF, (yysemantic_stack_[(2) - (2)].expr)); driver.SetAST((yyval.query)); }587 { (yyval.query) = new VerifyTAPN::AST::Query(VerifyTAPN::AST::AF, (yysemantic_stack_[(2) - (2)].expr)); driver.SetAST((yyval.query)); }
617 break;588 break;
618589
619 case 6:590 case 6:
620591/* Line 661 of lalr1.cc */
621/* Line 690 of lalr1.cc */592#line 64 "Core/QueryParser/grammar.yy"
622#line 64 "grammar.yy"
623 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }593 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }
624 break;594 break;
625595
626 case 7:596 case 7:
627597/* Line 661 of lalr1.cc */
628/* Line 690 of lalr1.cc */598#line 65 "Core/QueryParser/grammar.yy"
629#line 65 "grammar.yy"
630 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }599 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }
631 break;600 break;
632601
633 case 8:602 case 8:
634603/* Line 661 of lalr1.cc */
635/* Line 690 of lalr1.cc */604#line 66 "Core/QueryParser/grammar.yy"
636#line 66 "grammar.yy"
637 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }605 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }
638 break;606 break;
639607
640 case 9:608 case 9:
641609/* Line 661 of lalr1.cc */
642/* Line 690 of lalr1.cc */610#line 67 "Core/QueryParser/grammar.yy"
643#line 67 "grammar.yy"
644 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }611 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }
645 break;612 break;
646613
647 case 10:614 case 10:
648615/* Line 661 of lalr1.cc */
649/* Line 690 of lalr1.cc */616#line 68 "Core/QueryParser/grammar.yy"
650#line 68 "grammar.yy"
651 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }617 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }
652 break;618 break;
653619
654 case 11:620 case 11:
655621/* Line 661 of lalr1.cc */
656/* Line 690 of lalr1.cc */622#line 69 "Core/QueryParser/grammar.yy"
657#line 69 "grammar.yy"
658 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }623 { (yyval.expr) = (yysemantic_stack_[(1) - (1)].expr); }
659 break;624 break;
660625
661 case 12:626 case 12:
662627/* Line 661 of lalr1.cc */
663/* Line 690 of lalr1.cc */628#line 75 "Core/QueryParser/grammar.yy"
664#line 75 "grammar.yy"
665 { (yyval.expr) = new VerifyTAPN::AST::ParExpression((yysemantic_stack_[(3) - (2)].expr)); }629 { (yyval.expr) = new VerifyTAPN::AST::ParExpression((yysemantic_stack_[(3) - (2)].expr)); }
666 break;630 break;
667631
668 case 13:632 case 13:
669633/* Line 661 of lalr1.cc */
670/* Line 690 of lalr1.cc */634#line 76 "Core/QueryParser/grammar.yy"
671#line 76 "grammar.yy"
672 { (yyval.expr) = new VerifyTAPN::AST::NotExpression((yysemantic_stack_[(2) - (2)].expr)); }635 { (yyval.expr) = new VerifyTAPN::AST::NotExpression((yysemantic_stack_[(2) - (2)].expr)); }
673 break;636 break;
674637
675 case 14:638 case 14:
676639/* Line 661 of lalr1.cc */
677/* Line 690 of lalr1.cc */640#line 77 "Core/QueryParser/grammar.yy"
678#line 77 "grammar.yy"
679 { (yyval.expr) = new VerifyTAPN::AST::OrExpression((yysemantic_stack_[(3) - (1)].expr), (yysemantic_stack_[(3) - (3)].expr)); }641 { (yyval.expr) = new VerifyTAPN::AST::OrExpression((yysemantic_stack_[(3) - (1)].expr), (yysemantic_stack_[(3) - (3)].expr)); }
680 break;642 break;
681643
682 case 15:644 case 15:
683645/* Line 661 of lalr1.cc */
684/* Line 690 of lalr1.cc */646#line 78 "Core/QueryParser/grammar.yy"
685#line 78 "grammar.yy"
686 { (yyval.expr) = new VerifyTAPN::AST::AndExpression((yysemantic_stack_[(3) - (1)].expr), (yysemantic_stack_[(3) - (3)].expr)); }647 { (yyval.expr) = new VerifyTAPN::AST::AndExpression((yysemantic_stack_[(3) - (1)].expr), (yysemantic_stack_[(3) - (3)].expr)); }
687 break;648 break;
688649
689 case 16:650 case 16:
690651/* Line 661 of lalr1.cc */
691/* Line 690 of lalr1.cc */652#line 79 "Core/QueryParser/grammar.yy"
692#line 79 "grammar.yy"
693 { (yyval.expr) = new VerifyTAPN::AST::BoolExpression(true); }653 { (yyval.expr) = new VerifyTAPN::AST::BoolExpression(true); }
694 break;654 break;
695655
696 case 17:656 case 17:
697657/* Line 661 of lalr1.cc */
698/* Line 690 of lalr1.cc */658#line 80 "Core/QueryParser/grammar.yy"
699#line 80 "grammar.yy"
700 { (yyval.expr) = new VerifyTAPN::AST::BoolExpression(false); }659 { (yyval.expr) = new VerifyTAPN::AST::BoolExpression(false); }
701 break;660 break;
702661
703 case 18:662 case 18:
704663/* Line 661 of lalr1.cc */
705/* Line 690 of lalr1.cc */664#line 82 "Core/QueryParser/grammar.yy"
706#line 82 "grammar.yy"
707 { 665 {
708 int placeIndex = driver.tapn().GetPlaceIndex(*(yysemantic_stack_[(3) - (1)].string));666 int placeIndex = driver.tapn().GetPlaceIndex(*(yysemantic_stack_[(3) - (1)].string));
709 if(placeIndex == -1) error((yylocation_stack_[(3) - (1)]), "unknown place"); 667 if(placeIndex == -1) error((yylocation_stack_[(3) - (1)]), "unknown place");
@@ -712,9 +670,8 @@
712 break;670 break;
713671
714672
715673/* Line 661 of lalr1.cc */
716/* Line 690 of lalr1.cc */674#line 675 "Core/QueryParser/Generated/parser.cpp"
717#line 718 "Generated/parser.cpp"
718 default:675 default:
719 break;676 break;
720 }677 }
@@ -956,7 +913,7 @@
956 }913 }
957 }914 }
958915
959 char const* yyformat = 0;916 char const* yyformat = YY_NULL;
960 switch (yycount)917 switch (yycount)
961 {918 {
962#define YYCASE_(N, S) \919#define YYCASE_(N, S) \
@@ -1086,7 +1043,7 @@
1086 1, 1, 1, 11043 1, 1, 1, 1
1087 };1044 };
10881045
1089#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE1046
1090 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.1047 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1091 First, the terminals, then, starting at \a yyntokens_, nonterminals. */1048 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
1092 const char*1049 const char*
@@ -1097,9 +1054,8 @@
1097 "LPARAN", "RPARAN", "OR", "AND", "NOT", "BOOL_TRUE", "BOOL_FALSE",1054 "LPARAN", "RPARAN", "OR", "AND", "NOT", "BOOL_TRUE", "BOOL_FALSE",
1098 "$accept", "query", "expression", "parExpression", "notExpression",1055 "$accept", "query", "expression", "parExpression", "notExpression",
1099 "orExpression", "andExpression", "boolExpression", "atomicProposition",1056 "orExpression", "andExpression", "boolExpression", "atomicProposition",
1100 "compareOp", 01057 "compareOp", YY_NULL
1101 };1058 };
1102#endif
11031059
1104#if YYDEBUG1060#if YYDEBUG
1105 /* YYRHS -- A `-1'-separated list of the rules' RHS. */1061 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
@@ -1217,17 +1173,13 @@
1217 const unsigned int Parser::yyuser_token_number_max_ = 275;1173 const unsigned int Parser::yyuser_token_number_max_ = 275;
1218 const Parser::token_number_type Parser::yyundef_token_ = 2;1174 const Parser::token_number_type Parser::yyundef_token_ = 2;
12191175
12201176/* Line 1106 of lalr1.cc */
1221/* Line 1136 of lalr1.cc */1177#line 5 "Core/QueryParser/grammar.yy"
1222#line 5 "grammar.yy"
1223} // VerifyTAPN1178} // VerifyTAPN
12241179/* Line 1106 of lalr1.cc */
1225/* Line 1136 of lalr1.cc */1180#line 1181 "Core/QueryParser/Generated/parser.cpp"
1226#line 1227 "Generated/parser.cpp"1181/* Line 1107 of lalr1.cc */
12271182#line 89 "Core/QueryParser/grammar.yy"
1228
1229/* Line 1138 of lalr1.cc */
1230#line 89 "grammar.yy"
12311183
12321184
1233void 1185void
@@ -1237,4 +1189,3 @@
1237 driver.error (l, m);1189 driver.error (l, m);
1238 exit(1);1190 exit(1);
1239}1191}
1240
12411192
=== modified file 'src/Core/QueryParser/Generated/parser.hpp'
--- src/Core/QueryParser/Generated/parser.hpp 2012-04-19 12:40:05 +0000
+++ src/Core/QueryParser/Generated/parser.hpp 2013-03-31 13:25:26 +0000
@@ -1,8 +1,8 @@
1/* A Bison parser, made by GNU Bison 2.5. */1/* A Bison parser, made by GNU Bison 2.6.5. */
22
3/* Skeleton interface for Bison LALR(1) parsers in C++3/* Skeleton interface for Bison LALR(1) parsers in C++
4 4
5 Copyright (C) 2002-2011 Free Software Foundation, Inc.5 Copyright (C) 2002-2012 Free Software Foundation, Inc.
6 6
7 This program is free software: you can redistribute it and/or modify7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by8 it under the terms of the GNU General Public License as published by
@@ -30,15 +30,19 @@
30 This special exception was added by the Free Software Foundation in30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */31 version 2.2 of Bison. */
3232
33/**
34 ** \file Core/QueryParser/Generated/parser.hpp
35 ** Define the VerifyTAPN::parser class.
36 */
37
33/* C++ LALR(1) parser skeleton written by Akim Demaille. */38/* C++ LALR(1) parser skeleton written by Akim Demaille. */
3439
35#ifndef PARSER_HEADER_H40#ifndef YY_YY_CORE_QUERYPARSER_GENERATED_PARSER_HPP_INCLUDED
36# define PARSER_HEADER_H41# define YY_YY_CORE_QUERYPARSER_GENERATED_PARSER_HPP_INCLUDED
3742
38/* "%code requires" blocks. */43/* "%code requires" blocks. */
3944/* Line 36 of lalr1.cc */
40/* Line 35 of lalr1.cc */45#line 7 "Core/QueryParser/grammar.yy"
41#line 7 "grammar.yy"
4246
43# include <string>47# include <string>
44#include "../AST.hpp"48#include "../AST.hpp"
@@ -47,9 +51,8 @@
47}51}
4852
4953
5054/* Line 36 of lalr1.cc */
51/* Line 35 of lalr1.cc */55#line 56 "Core/QueryParser/Generated/parser.hpp"
52#line 53 "Generated/parser.hpp"
5356
5457
55#include <string>58#include <string>
@@ -62,26 +65,11 @@
62# define YYDEBUG 065# define YYDEBUG 0
63#endif66#endif
6467
65/* Enabling verbose error messages. */68/* Line 36 of lalr1.cc */
66#ifdef YYERROR_VERBOSE69#line 5 "Core/QueryParser/grammar.yy"
67# undef YYERROR_VERBOSE
68# define YYERROR_VERBOSE 1
69#else
70# define YYERROR_VERBOSE 1
71#endif
72
73/* Enabling the token table. */
74#ifndef YYTOKEN_TABLE
75# define YYTOKEN_TABLE 0
76#endif
77
78
79/* Line 35 of lalr1.cc */
80#line 5 "grammar.yy"
81namespace VerifyTAPN {70namespace VerifyTAPN {
8271/* Line 36 of lalr1.cc */
83/* Line 35 of lalr1.cc */72#line 73 "Core/QueryParser/Generated/parser.hpp"
84#line 85 "Generated/parser.hpp"
8573
86 /// A Bison parser.74 /// A Bison parser.
87 class Parser75 class Parser
@@ -91,9 +79,8 @@
91#ifndef YYSTYPE79#ifndef YYSTYPE
92 union semantic_type80 union semantic_type
93 {81 {
9482/* Line 36 of lalr1.cc */
95/* Line 35 of lalr1.cc */83#line 30 "Core/QueryParser/grammar.yy"
96#line 30 "grammar.yy"
9784
98 int number;85 int number;
99 std::string* string;86 std::string* string;
@@ -101,9 +88,8 @@
101 VerifyTAPN::AST::Query* query;88 VerifyTAPN::AST::Query* query;
10289
10390
10491/* Line 36 of lalr1.cc */
105/* Line 35 of lalr1.cc */92#line 93 "Core/QueryParser/Generated/parser.hpp"
106#line 107 "Generated/parser.hpp"
107 };93 };
108#else94#else
109 typedef YYSTYPE semantic_type;95 typedef YYSTYPE semantic_type;
@@ -246,16 +232,14 @@
246 /// For a rule, its LHS.232 /// For a rule, its LHS.
247 static const unsigned char yyr1_[];233 static const unsigned char yyr1_[];
248 /// For a rule, its RHS length.234 /// For a rule, its RHS length.
249 static const unsigned char yyr2_[];235 static const unsigned char yyr2_[];
250236
251#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE237 /// Convert the symbol name \a n to a form suitable for a diagnostic.
238 static std::string yytnamerr_ (const char *n);
239
240
252 /// For a symbol, its name in clear.241 /// For a symbol, its name in clear.
253 static const char* const yytname_[];242 static const char* const yytname_[];
254#endif
255
256 /// Convert the symbol name \a n to a form suitable for a diagnostic.
257 static std::string yytnamerr_ (const char *n);
258
259#if YYDEBUG243#if YYDEBUG
260 /// A type to store symbol numbers and -1.244 /// A type to store symbol numbers and -1.
261 typedef signed char rhs_number_type;245 typedef signed char rhs_number_type;
@@ -309,14 +293,12 @@
309 /* User arguments. */293 /* User arguments. */
310 VerifyTAPN::TAPNQueryParser& driver;294 VerifyTAPN::TAPNQueryParser& driver;
311 };295 };
312296/* Line 36 of lalr1.cc */
313/* Line 35 of lalr1.cc */297#line 5 "Core/QueryParser/grammar.yy"
314#line 5 "grammar.yy"
315} // VerifyTAPN298} // VerifyTAPN
316299/* Line 36 of lalr1.cc */
317/* Line 35 of lalr1.cc */300#line 301 "Core/QueryParser/Generated/parser.hpp"
318#line 319 "Generated/parser.hpp"301
319302
320303
321304#endif /* !YY_YY_CORE_QUERYPARSER_GENERATED_PARSER_HPP_INCLUDED */
322#endif /* ! defined PARSER_HEADER_H */
323305
=== modified file 'src/Core/QueryParser/Generated/position.hh'
--- src/Core/QueryParser/Generated/position.hh 2012-04-19 12:40:05 +0000
+++ src/Core/QueryParser/Generated/position.hh 2013-03-31 13:25:26 +0000
@@ -1,8 +1,8 @@
1/* A Bison parser, made by GNU Bison 2.5. */1/* A Bison parser, made by GNU Bison 2.6.5. */
22
3/* Positions for Bison parsers in C++3/* Positions for Bison parsers in C++
4 4
5 Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc.5 Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc.
6 6
7 This program is free software: you can redistribute it and/or modify7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by8 it under the terms of the GNU General Public License as published by
@@ -31,62 +31,72 @@
31 version 2.2 of Bison. */31 version 2.2 of Bison. */
3232
33/**33/**
34 ** \file position.hh34 ** \file Core/QueryParser/Generated/position.hh
35 ** Define the VerifyTAPN::position class.35 ** Define the VerifyTAPN::position class.
36 */36 */
3737
38#ifndef BISON_POSITION_HH38#ifndef YY_YY_CORE_QUERYPARSER_GENERATED_POSITION_HH_INCLUDED
39# define BISON_POSITION_HH39# define YY_YY_CORE_QUERYPARSER_GENERATED_POSITION_HH_INCLUDED
4040
41# include <algorithm> // std::max
41# include <iostream>42# include <iostream>
42# include <string>43# include <string>
43# include <algorithm>44
4445# ifndef YY_NULL
4546# if defined __cplusplus && 201103L <= __cplusplus
46/* Line 37 of location.cc */47# define YY_NULL nullptr
47#line 5 "grammar.yy"48# else
49# define YY_NULL 0
50# endif
51# endif
52
53/* Line 38 of location.cc */
54#line 5 "Core/QueryParser/grammar.yy"
48namespace VerifyTAPN {55namespace VerifyTAPN {
4956/* Line 38 of location.cc */
50/* Line 37 of location.cc */57#line 58 "Core/QueryParser/Generated/position.hh"
51#line 52 "Generated/position.hh"
52 /// Abstract a position.58 /// Abstract a position.
53 class position59 class position
54 {60 {
55 public:61 public:
5662
57 /// Construct a position.63 /// Construct a position.
58 position ()64 explicit position (std::string* f = YY_NULL,
59 : filename (0), line (1), column (1)65 unsigned int l = 1u,
66 unsigned int c = 1u)
67 : filename (f)
68 , line (l)
69 , column (c)
60 {70 {
61 }71 }
6272
6373
64 /// Initialization.74 /// Initialization.
65 inline void initialize (std::string* fn)75 void initialize (std::string* fn = YY_NULL,
76 unsigned int l = 1u,
77 unsigned int c = 1u)
66 {78 {
67 filename = fn;79 filename = fn;
68 line = 1;80 line = l;
69 column = 1;81 column = c;
70 }82 }
7183
72 /** \name Line and Column related manipulators84 /** \name Line and Column related manipulators
73 ** \{ */85 ** \{ */
74 public:
75 /// (line related) Advance to the COUNT next lines.86 /// (line related) Advance to the COUNT next lines.
76 inline void lines (int count = 1)87 void lines (int count = 1)
77 {88 {
78 column = 1;89 column = 1u;
79 line += count;90 line += count;
80 }91 }
8192
82 /// (column related) Advance to the COUNT next columns.93 /// (column related) Advance to the COUNT next columns.
83 inline void columns (int count = 1)94 void columns (int count = 1)
84 {95 {
85 column = std::max (1u, column + count);96 column = std::max (1u, column + count);
86 }97 }
87 /** \} */98 /** \} */
8899
89 public:
90 /// File name to which this position refers.100 /// File name to which this position refers.
91 std::string* filename;101 std::string* filename;
92 /// Current line number.102 /// Current line number.
@@ -96,7 +106,7 @@
96 };106 };
97107
98 /// Add and assign a position.108 /// Add and assign a position.
99 inline const position&109 inline position&
100 operator+= (position& res, const int width)110 operator+= (position& res, const int width)
101 {111 {
102 res.columns (width);112 res.columns (width);
@@ -112,7 +122,7 @@
112 }122 }
113123
114 /// Add and assign a position.124 /// Add and assign a position.
115 inline const position&125 inline position&
116 operator-= (position& res, const int width)126 operator-= (position& res, const int width)
117 {127 {
118 return res += -width;128 return res += -width;
@@ -155,11 +165,9 @@
155 return ostr << pos.line << '.' << pos.column;165 return ostr << pos.line << '.' << pos.column;
156 }166 }
157167
158168/* Line 149 of location.cc */
159/* Line 144 of location.cc */169#line 5 "Core/QueryParser/grammar.yy"
160#line 5 "grammar.yy"
161} // VerifyTAPN170} // VerifyTAPN
162171/* Line 149 of location.cc */
163/* Line 144 of location.cc */172#line 173 "Core/QueryParser/Generated/position.hh"
164#line 165 "Generated/position.hh"173#endif /* !YY_YY_CORE_QUERYPARSER_GENERATED_POSITION_HH_INCLUDED */
165#endif // not BISON_POSITION_HH
166174
=== modified file 'src/Core/QueryParser/Generated/stack.hh'
--- src/Core/QueryParser/Generated/stack.hh 2012-04-19 12:40:05 +0000
+++ src/Core/QueryParser/Generated/stack.hh 2013-03-31 13:25:26 +0000
@@ -1,8 +1,8 @@
1/* A Bison parser, made by GNU Bison 2.5. */1/* A Bison parser, made by GNU Bison 2.6.5. */
22
3/* Stack handling for Bison parsers in C++3/* Stack handling for Bison parsers in C++
4 4
5 Copyright (C) 2002-2011 Free Software Foundation, Inc.5 Copyright (C) 2002-2012 Free Software Foundation, Inc.
6 6
7 This program is free software: you can redistribute it and/or modify7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by8 it under the terms of the GNU General Public License as published by
@@ -30,23 +30,25 @@
30 This special exception was added by the Free Software Foundation in30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */31 version 2.2 of Bison. */
3232
33#ifndef BISON_STACK_HH33/**
34# define BISON_STACK_HH34 ** \file Core/QueryParser/Generated/stack.hh
3535 ** Define the VerifyTAPN::stack class.
36#include <deque>36 */
3737
3838#ifndef YY_YY_CORE_QUERYPARSER_GENERATED_STACK_HH_INCLUDED
39/* Line 1149 of lalr1.cc */39# define YY_YY_CORE_QUERYPARSER_GENERATED_STACK_HH_INCLUDED
40#line 5 "grammar.yy"40
41# include <deque>
42
43/* Line 37 of stack.hh */
44#line 5 "Core/QueryParser/grammar.yy"
41namespace VerifyTAPN {45namespace VerifyTAPN {
4246/* Line 37 of stack.hh */
43/* Line 1149 of lalr1.cc */47#line 48 "Core/QueryParser/Generated/stack.hh"
44#line 45 "Generated/stack.hh"
45 template <class T, class S = std::deque<T> >48 template <class T, class S = std::deque<T> >
46 class stack49 class stack
47 {50 {
48 public:51 public:
49
50 // Hide our reversed order.52 // Hide our reversed order.
51 typedef typename S::reverse_iterator iterator;53 typedef typename S::reverse_iterator iterator;
52 typedef typename S::const_reverse_iterator const_iterator;54 typedef typename S::const_reverse_iterator const_iterator;
@@ -85,7 +87,7 @@
85 pop (unsigned int n = 1)87 pop (unsigned int n = 1)
86 {88 {
87 for (; n; --n)89 for (; n; --n)
88 seq_.pop_front ();90 seq_.pop_front ();
89 }91 }
9092
91 inline93 inline
@@ -99,7 +101,6 @@
99 inline const_iterator end () const { return seq_.rend (); }101 inline const_iterator end () const { return seq_.rend (); }
100102
101 private:103 private:
102
103 S seq_;104 S seq_;
104 };105 };
105106
@@ -108,10 +109,9 @@
108 class slice109 class slice
109 {110 {
110 public:111 public:
111112 slice (const S& stack, unsigned int range)
112 slice (const S& stack,113 : stack_ (stack)
113 unsigned int range) : stack_ (stack),114 , range_ (range)
114 range_ (range)
115 {115 {
116 }116 }
117117
@@ -123,17 +123,13 @@
123 }123 }
124124
125 private:125 private:
126
127 const S& stack_;126 const S& stack_;
128 unsigned int range_;127 unsigned int range_;
129 };128 };
130129/* Line 119 of stack.hh */
131/* Line 1235 of lalr1.cc */130#line 5 "Core/QueryParser/grammar.yy"
132#line 5 "grammar.yy"
133} // VerifyTAPN131} // VerifyTAPN
134132/* Line 119 of stack.hh */
135/* Line 1235 of lalr1.cc */133#line 134 "Core/QueryParser/Generated/stack.hh"
136#line 137 "Generated/stack.hh"134
137135#endif /* !YY_YY_CORE_QUERYPARSER_GENERATED_STACK_HH_INCLUDED */
138#endif // not BISON_STACK_HH[]dnl
139
140136
=== modified file 'src/Core/TAPN/TimedArcPetriNet.cpp'
--- src/Core/TAPN/TimedArcPetriNet.cpp 2012-07-12 15:47:35 +0000
+++ src/Core/TAPN/TimedArcPetriNet.cpp 2013-03-31 13:25:26 +0000
@@ -189,6 +189,15 @@
189 }189 }
190 }190 }
191 }191 }
192
193 for(TimedTransition::Vector::iterator iter = transitions.begin(); iter != transitions.end(); iter++){
194 for(OutputArc::WeakPtrVector::const_iterator place_iter = iter->get()->GetPostset().begin(); place_iter != iter->get()->GetPostset().end(); place_iter++){
195 if(place_iter->lock()->OutputPlace().GetMaxConstant() > -1){
196 iter->get()->setUntimedPostset(false);
197 break;
198 }
199 }
200 }
192 }201 }
193202
194 void TimedArcPetriNet::calculateCausality(TimedPlace& p, std::vector< TimedPlace* >* result) const203 void TimedArcPetriNet::calculateCausality(TimedPlace& p, std::vector< TimedPlace* >* result) const
195204
=== modified file 'src/Core/TAPN/TimedTransition.hpp'
--- src/Core/TAPN/TimedTransition.hpp 2012-03-02 10:59:16 +0000
+++ src/Core/TAPN/TimedTransition.hpp 2013-03-31 13:25:26 +0000
@@ -21,8 +21,8 @@
21 public: // typedefs21 public: // typedefs
22 typedef std::vector< boost::shared_ptr<TimedTransition> > Vector;22 typedef std::vector< boost::shared_ptr<TimedTransition> > Vector;
23 public:23 public:
24 TimedTransition(const std::string& name, const std::string& id) : name(name), id(id), preset(), postset(), transportArcs(), index(-1) { };24 TimedTransition(const std::string& name, const std::string& id) : name(name), id(id), preset(), postset(), transportArcs(), index(-1), untimedPostset(true) { };
25 TimedTransition() : name("*EMPTY*"), id("-1"), preset(), postset(), transportArcs(), index(-1) { };25 TimedTransition() : name("*EMPTY*"), id("-1"), preset(), postset(), transportArcs(), index(-1), untimedPostset(true) { };
26 virtual ~TimedTransition() { /* empty */ }26 virtual ~TimedTransition() { /* empty */ }
2727
28 public: // modifiers28 public: // modifiers
@@ -46,7 +46,9 @@
46 inline unsigned int NumberOfTransportArcs() const { return transportArcs.size(); };46 inline unsigned int NumberOfTransportArcs() const { return transportArcs.size(); };
47 // bool isEnabledBy(const TimedArcPetriNet& tapn, const VerifyTAPN::SymMarking& marking) const;47 // bool isEnabledBy(const TimedArcPetriNet& tapn, const VerifyTAPN::SymMarking& marking) const;
48 inline const bool isConservative() const { return preset.size() == postset.size(); }48 inline const bool isConservative() const { return preset.size() == postset.size(); }
49 inline unsigned int GetIndex() const { return index; };49 inline unsigned int GetIndex() const { return index; }
50 inline const bool hasUntimedPostset() const { return untimedPostset; }
51 inline void setUntimedPostset(bool untimed){ untimedPostset = untimed; }
5052
51 private: // data53 private: // data
52 std::string name;54 std::string name;
@@ -56,6 +58,7 @@
56 TransportArc::WeakPtrVector transportArcs;58 TransportArc::WeakPtrVector transportArcs;
57 InhibitorArc::WeakPtrVector inhibitorArcs;59 InhibitorArc::WeakPtrVector inhibitorArcs;
58 unsigned int index;60 unsigned int index;
61 bool untimedPostset;
59 };62 };
6063
61 inline std::ostream& operator<<(std::ostream& out, const TimedTransition& transition)64 inline std::ostream& operator<<(std::ostream& out, const TimedTransition& transition)
6265
=== modified file 'src/Core/VerificationOptions.cpp'
--- src/Core/VerificationOptions.cpp 2012-07-09 13:19:22 +0000
+++ src/Core/VerificationOptions.cpp 2013-03-31 13:25:26 +0000
@@ -25,22 +25,31 @@
25 }25 }
26 }26 }
2727
28 std::string FactoryEnumToString(Factory factory){28 std::string VerificationTypeEnumToString(VerificationType s){
29 switch(factory)29 switch(s){
30 {30 case TIMEDART:
31 case OLD_FACTORY:31 return "Time darts";
32 return "old DBM";32 default:
33 case DISCRETE_INCLUSION:33 return "Default (discrete)";
34 return "discrete inclusion";34 }
35 default:
36 return "default";
37 }35 }
38 }36
3937 std::string MemoryOptimizationEnumToString(MemoryOptimization m){
4038 switch(m){
39 case NONE:
40 return "None";
41 case PTRIE:
42 return "PTrie ";
43 default:
44 return "None";
45 }
46 }
47
41 std::ostream& operator<<(std::ostream& out, const VerificationOptions& options)48 std::ostream& operator<<(std::ostream& out, const VerificationOptions& options)
42 {49 {
43 out << "Using " << SearchTypeEnumToString(options.GetSearchType()) << std::endl;50 out << "Search type: " << SearchTypeEnumToString(options.GetSearchType()) << std::endl;
51 out << "Verification method: " << VerificationTypeEnumToString(options.GetVerificationType()) << std::endl;
52 out << "Memory optimization: " << MemoryOptimizationEnumToString(options.GetMemoryOptimization()) << std::endl;
44 out << "k-bound is: " << options.GetKBound() << std::endl;53 out << "k-bound is: " << options.GetKBound() << std::endl;
45 out << "Generating " << enumToString(options.GetTrace()) << " trace";54 out << "Generating " << enumToString(options.GetTrace()) << " trace";
46 if(options.GetTrace() != NONE) out << " in " << (options.XmlTrace() ? "xml format" : "human readable format");55 if(options.GetTrace() != NONE) out << " in " << (options.XmlTrace() ? "xml format" : "human readable format");
4756
=== modified file 'src/Core/VerificationOptions.hpp'
--- src/Core/VerificationOptions.hpp 2012-07-12 15:47:35 +0000
+++ src/Core/VerificationOptions.hpp 2013-03-31 13:25:26 +0000
@@ -8,14 +8,18 @@
8namespace VerifyTAPN {8namespace VerifyTAPN {
9 enum Trace { NONE, SOME };9 enum Trace { NONE, SOME };
10 enum SearchType { BREADTHFIRST, DEPTHFIRST, RANDOM, COVERMOST };10 enum SearchType { BREADTHFIRST, DEPTHFIRST, RANDOM, COVERMOST };
11 enum Factory { DEFAULT, DISCRETE_INCLUSION, OLD_FACTORY };11 enum VerificationType { DISCRETE, TIMEDART };
12 enum MemoryOptimization { NO_MEMORY_OPTIMIZATION, PTRIE };
1213
13 class VerificationOptions {14 class VerificationOptions {
14 public:15 public:
16 VerificationOptions(){}
15 VerificationOptions(17 VerificationOptions(
16 const std::string& inputFile,18 const std::string& inputFile,
17 const std::string& queryFile,19 const std::string& queryFile,
18 SearchType searchType,20 SearchType searchType,
21 VerificationType verificationType,
22 MemoryOptimization memOptimization,
19 unsigned int k_bound,23 unsigned int k_bound,
20 Trace trace,24 Trace trace,
21 bool xml_trace,25 bool xml_trace,
@@ -24,12 +28,16 @@
24 ) : inputFile(inputFile),28 ) : inputFile(inputFile),
25 queryFile(queryFile),29 queryFile(queryFile),
26 searchType(searchType),30 searchType(searchType),
31 verificationType(verificationType),
32 memOptimization(memOptimization),
27 k_bound(k_bound),33 k_bound(k_bound),
28 trace(trace),34 trace(trace),
29 xml_trace(xml_trace),35 xml_trace(xml_trace),
30 useGlobalMaxConstants(useGlobalMaxConstants),36 useGlobalMaxConstants(useGlobalMaxConstants),
31 keepDeadTokens(keepDeadTokens)37 keepDeadTokens(keepDeadTokens)
32 { };38 {
39
40 };
3341
34 public: // inspectors42 public: // inspectors
35 const std::string GetInputFile() const { return inputFile; }43 const std::string GetInputFile() const { return inputFile; }
@@ -39,19 +47,20 @@
39 inline const bool XmlTrace() const { return xml_trace; };47 inline const bool XmlTrace() const { return xml_trace; };
40 inline const bool GetGlobalMaxConstantsEnabled() const { return useGlobalMaxConstants; }48 inline const bool GetGlobalMaxConstantsEnabled() const { return useGlobalMaxConstants; }
41 inline const SearchType GetSearchType() const { return searchType; }49 inline const SearchType GetSearchType() const { return searchType; }
50 inline const VerificationType GetVerificationType() const { return verificationType; }
51 inline const MemoryOptimization GetMemoryOptimization() const { return memOptimization; }
42 inline const bool GetKeepDeadTokens() const { return keepDeadTokens; };52 inline const bool GetKeepDeadTokens() const { return keepDeadTokens; };
43 inline Factory GetFactory() const { return DEFAULT; };
44 inline void SetFactory(Factory f) { factory = f; };
45 private:53 private:
46 std::string inputFile;54 std::string inputFile;
47 std::string queryFile;55 std::string queryFile;
48 SearchType searchType;56 SearchType searchType;
57 VerificationType verificationType;
58 MemoryOptimization memOptimization;
49 unsigned int k_bound;59 unsigned int k_bound;
50 Trace trace;60 Trace trace;
51 bool xml_trace;61 bool xml_trace;
52 bool useGlobalMaxConstants;62 bool useGlobalMaxConstants;
53 bool keepDeadTokens;63 bool keepDeadTokens;
54 Factory factory;
55 };64 };
5665
57 std::ostream& operator<<(std::ostream& out, const VerificationOptions& options);66 std::ostream& operator<<(std::ostream& out, const VerificationOptions& options);
5867
=== added file 'src/DiscreteVerification/DataStructures/EncodingStructure.cpp'
--- src/DiscreteVerification/DataStructures/EncodingStructure.cpp 1970-01-01 00:00:00 +0000
+++ src/DiscreteVerification/DataStructures/EncodingStructure.cpp 2013-03-31 13:25:26 +0000
@@ -0,0 +1,14 @@
1/*
2 * File: Encoding.cpp
3 * Author: floop
4 *
5 * Created on 27. oktober 2012, 12:36
6 */
7
8#include "EncodingStructure.h"
9namespace VerifyTAPN {
10 namespace DiscreteVerification {
11
12
13 }
14}
0\ No newline at end of file15\ No newline at end of file
116
=== added file 'src/DiscreteVerification/DataStructures/EncodingStructure.h'
--- src/DiscreteVerification/DataStructures/EncodingStructure.h 1970-01-01 00:00:00 +0000
+++ src/DiscreteVerification/DataStructures/EncodingStructure.h 2013-03-31 13:25:26 +0000
@@ -0,0 +1,241 @@
1/*
2 * File: Encoding.h
3 * Author: Peter Gjøl Jense
4 *
5 * Created on 27. oktober 2012, 12:36
6 */
7
8#include <math.h>
9#include <stdio.h>
10#include <iostream>
11#include <string.h>
12
13#ifndef ENCODING_H
14#define ENCODING_H
15using namespace std;
16namespace VerifyTAPN {
17 namespace DiscreteVerification {
18
19 template<class T>
20 class EncodingStructure {
21 public:
22 typedef unsigned int uint;
23
24 EncodingStructure() {
25 };
26 EncodingStructure(uint size);
27 EncodingStructure(const EncodingStructure &other, uint offset);
28 EncodingStructure(const EncodingStructure &other, uint size, uint offset, uint encsize);
29 EncodingStructure(char* raw, uint size, uint offset, uint encsize);
30 EncodingStructure(char* raw, uint size){
31 shadow = raw;
32 rsize = size;
33 };
34 virtual ~EncodingStructure();
35
36 EncodingStructure Clone() {
37 EncodingStructure s;
38 s.rsize = rsize;
39 s.shadow = new char[rsize + sizeof (T)];
40 memcpy(s.shadow, shadow, rsize + sizeof (T));
41 return s;
42 }
43
44 void Copy(const EncodingStructure &other, unsigned int offset) {
45 memcpy(&(shadow[offset / 8]), other.shadow, other.rsize);
46 }
47
48 void Copy(const char* raw, unsigned int size){
49 shadow = new char[size + sizeof(T)];
50 memcpy(shadow, raw, size);
51 }
52
53 bool At(const uint place) const;
54 void Set(const uint place, const bool value) const;
55
56 void Zero() const {
57 memset(shadow, 0x0, rsize);
58 }
59
60 unsigned short int Size() const {
61 return rsize;
62 }
63
64 void Release() const {
65 delete[] shadow;
66 }
67
68 char* GetRaw() const {
69 return shadow;
70 }
71
72 void PrintEncoding() const {
73 for (unsigned short int i = 0; i < rsize * 8; i++)
74 cout << this->At(i);
75 cout << endl;
76 }
77
78 inline static uint Overhead(uint size) {
79 size = size % 8;
80 if (size == 0)
81 return 0;
82 else
83 return 8 - size;
84 }
85
86 inline void SetMetaData(T data) const {
87 memcpy(&(shadow[rsize]), &data, sizeof (T));
88 }
89
90 inline T GetMetaData() const {
91 T res;
92 memcpy(&res, &(shadow[rsize]), sizeof (T));
93 return res;
94 }
95
96 const char operator[](int i) {
97
98 if (i >= rsize) {
99 return 0x0;
100 }
101 return shadow[i];
102 }
103
104 friend bool operator==(const EncodingStructure &enc1, const EncodingStructure &enc2) {
105 if(enc1.rsize != enc2.rsize)
106 return false;
107 for(int i = 0; i < enc1.rsize; i++)
108 if(enc1.shadow[i] != enc2.shadow[i])
109 return false;
110 return true;
111 }
112
113
114 friend bool operator<(const EncodingStructure &enc1, const EncodingStructure &enc2) {
115 int count = enc1.rsize > enc2.rsize ? enc1.rsize : enc2.rsize;
116
117 for (int i = 0; i < count; i++) {
118 if (enc1.rsize > i && enc2.rsize > i && enc1.shadow[i] != enc2.shadow[i]) {
119 return ((unsigned short int) enc1.shadow[i]) < ((unsigned short int) enc2.shadow[i]);
120 }
121
122 }
123 if (enc1.rsize > enc2.rsize) {
124 return false;
125
126 } else if (enc1.rsize < enc2.rsize) {
127 return true;
128 }
129
130 return false;
131 }
132
133 private:
134 char* shadow;
135 unsigned short rsize;
136 const static char masks[8];
137 };
138
139 template<class T>
140 const char EncodingStructure<T>::masks[8] = {
141 0x01,
142 0x02,
143 0x04,
144 0x08,
145 0x10,
146 0x20,
147 0x40,
148 0x80
149 };
150
151 template<class T>
152 EncodingStructure<T>::EncodingStructure(uint size) {
153 rsize = (size + Overhead(size)) / 8;
154 shadow = new char[rsize + sizeof (T)];
155 memset(shadow, 0x0, rsize + sizeof (T));
156 }
157
158 template<class T>
159 EncodingStructure<T>::EncodingStructure(const EncodingStructure &other, uint offset) {
160 offset = offset / 8;
161
162 rsize = other.rsize;
163 if (rsize > offset)
164 rsize -= offset;
165 else {
166 rsize = 0;
167 }
168
169 shadow = new char[rsize + sizeof (T)];
170 memcpy(shadow, &(other.shadow[offset]), rsize);
171 SetMetaData(other.GetMetaData());
172 }
173
174 template<class T>
175 EncodingStructure<T>::EncodingStructure(const EncodingStructure &other, uint size, uint offset, uint encsize) {
176
177 uint so = size + offset;
178 offset = ((so - 1) / 8) - ((size - 1) / 8);
179
180 rsize = ((encsize + this->Overhead(encsize)) / 8);
181 if (rsize > offset)
182 rsize -= offset;
183 else {
184 rsize = 0;
185 }
186
187 shadow = new char[rsize + sizeof (T)];
188 memcpy(shadow, &(other.shadow[offset]), rsize);
189 SetMetaData(other.GetMetaData());
190 }
191
192 template<class T>
193 EncodingStructure<T>::EncodingStructure(char* raw, uint size, uint offset, uint encsize) {
194
195 uint so = size + offset;
196 offset = ((so - 1) / 8) - ((size - 1) / 8);
197
198 rsize = ((encsize + this->Overhead(encsize)) / 8);
199 if (rsize > offset)
200 rsize -= offset;
201 else {
202 rsize = 0;
203 }
204
205 shadow = &(raw[offset]);
206 }
207
208 template<class T>
209 EncodingStructure<T>::~EncodingStructure() {
210
211 }
212
213 template<class T>
214 bool EncodingStructure<T>::At(const uint place) const {
215 // return data[place];
216 uint offset = place % 8;
217 bool res2;
218 if (place / 8 < rsize)
219 res2 = (shadow[place / 8] & masks[offset]) != 0;
220 else
221 res2 = false;
222
223 return res2;
224 }
225
226 template<class T>
227 void EncodingStructure<T>::Set(const uint place, const bool value) const {
228 uint offset = place % 8;
229 uint theplace = place / 8;
230 if (value) {
231 shadow[theplace] |= masks[offset];
232 } else {
233 shadow[theplace] &= ~masks[offset];
234 }
235
236 }
237
238 }
239}
240#endif /* ENCODING_H */
241
0242
=== modified file 'src/DiscreteVerification/DataStructures/NonStrictMarking.cpp'
--- src/DiscreteVerification/DataStructures/NonStrictMarking.cpp 2012-07-13 17:50:33 +0000
+++ src/DiscreteVerification/DataStructures/NonStrictMarking.cpp 2013-03-31 13:25:26 +0000
@@ -11,245 +11,5 @@
1111
12namespace VerifyTAPN {12namespace VerifyTAPN {
13namespace DiscreteVerification {13namespace DiscreteVerification {
14
15NonStrictMarking::NonStrictMarking() : inTrace(false), children(0), passed(false){
16 // TODO Auto-generated constructor stub
17
18}
19
20NonStrictMarking::NonStrictMarking(const TAPN::TimedArcPetriNet& tapn, const std::vector<int>& v) : inTrace(false), children(0), passed(false){
21 int prevPlaceId = -1;
22 for(std::vector<int>::const_iterator iter = v.begin(); iter != v.end(); iter++){
23 if(*iter == prevPlaceId){
24 Place& p = places.back();
25 if(p.tokens.size() == 0){
26 Token t(0,1);
27 p.tokens.push_back(t);
28 }else{
29 p.tokens.begin()->add(1);
30 }
31 }else{
32
33 Place p(&tapn.GetPlace(*iter));
34 Token t(0,1);
35 p.tokens.push_back(t);
36 places.push_back(p);
37 }
38 prevPlaceId = *iter;
39 }
40}
41
42NonStrictMarking::NonStrictMarking(const NonStrictMarking& nsm) : inTrace(false), children(0), passed(false){
43 for(PlaceList::const_iterator it = nsm.places.begin(); it != nsm.places.end(); it++){
44 places.push_back(Place(*it));
45 }
46
47 parent = nsm.parent;
48 generatedBy = nsm.generatedBy;
49}
50
51unsigned int NonStrictMarking::size(){
52 int count = 0;
53 for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++){
54 for(TokenList::const_iterator it = iter->tokens.begin(); it != iter->tokens.end(); it++){
55 count += it->getCount();
56 }
57 }
58 return count;
59}
60
61//int NonStrictMarking::NumberOfTokensInPlace(const Place& place) const{
62// int count = 0;
63// for(TokenList::const_iterator it = place.tokens.begin(); it != place.tokens.end(); it++){
64// count = count + it->getCount();
65// }
66// return count;
67//}
68
69int NonStrictMarking::NumberOfTokensInPlace(int placeId) const{
70 int count = 0;
71 for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++){
72 if(iter->place->GetIndex() == placeId){
73 for(TokenList::const_iterator it = iter->tokens.begin(); it != iter->tokens.end(); it++){
74 count = count + it->getCount();
75 }
76 }
77 }
78 return count;
79}
80
81const TokenList& NonStrictMarking::GetTokenList(int placeId){
82 for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++){
83 if(iter->place->GetIndex() == placeId) return iter->tokens;
84 }
85 return emptyTokenList;
86}
87
88bool NonStrictMarking::RemoveToken(int placeId, int age){
89 for(PlaceList::iterator pit = places.begin(); pit != places.end(); pit++){
90 if(pit->place->GetIndex() == placeId){
91 for(TokenList::iterator tit = pit->tokens.begin(); tit != pit->tokens.end(); tit++){
92 if(tit->getAge() == age){
93 return RemoveToken(*pit, *tit);
94 }
95 }
96 }
97 }
98 return false;
99}
100
101void NonStrictMarking::RemoveRangeOfTokens(Place& place, TokenList::iterator begin, TokenList::iterator end){
102 place.tokens.erase(begin, end);
103}
104
105bool NonStrictMarking::RemoveToken(Place& place, Token& token){
106 if(token.getCount() > 1){
107 token.remove(1);
108 return true;
109 }else{
110 for(TokenList::iterator iter = place.tokens.begin(); iter != place.tokens.end(); iter++){
111 if(iter->getAge() == token.getAge()){
112 place.tokens.erase(iter);
113 if(place.tokens.empty()){
114 for(PlaceList::iterator it = places.begin(); it != places.end(); it++){
115 if(it->place->GetIndex() == place.place->GetIndex()){
116 places.erase(it);
117 return true;
118 }
119 }
120 }
121 return true;
122 }
123 }
124 }
125 return false;
126}
127
128void NonStrictMarking::AddTokenInPlace(TAPN::TimedPlace& place, int age){
129 for(PlaceList::iterator pit = places.begin(); pit != places.end(); pit++){
130 if(pit->place->GetIndex() == place.GetIndex()){
131 for(TokenList::iterator tit = pit->tokens.begin(); tit != pit->tokens.end(); tit++){
132 if(tit->getAge() == age){
133 Token t(age, 1);
134 AddTokenInPlace(*pit, t);
135 return;
136 }
137 }
138 Token t(age,1);
139 AddTokenInPlace(*pit, t);
140 return;
141 }
142 }
143 Token t(age,1);
144 Place p(&place);
145 AddTokenInPlace(p,t);
146
147 // Insert place
148 bool inserted = false;
149 for(PlaceList::iterator it = places.begin(); it != places.end(); it++){
150 if(it->place->GetIndex() > place.GetIndex()){
151 places.insert(it, p);
152 inserted = true;
153 break;
154 }
155 }
156 if(!inserted){
157 places.push_back(p);
158 }
159}
160
161void NonStrictMarking::AddTokenInPlace(TAPN::TimedPlace& place, Token& token){
162 for(PlaceList::iterator pit = places.begin(); pit != places.end(); pit++){
163 if(pit->place->GetIndex() == place.GetIndex()){
164 AddTokenInPlace(*pit, token);
165 return;
166 }
167 }
168
169 Place p(&place);
170 AddTokenInPlace(p,token);
171
172 // Insert place
173 bool inserted = false;
174 for(PlaceList::iterator it = places.begin(); it != places.end(); it++){
175 if(it->place->GetIndex() > place.GetIndex()){
176 places.insert(it, p);
177 inserted = true;
178 break;
179 }
180 }
181 if(!inserted){
182 places.push_back(p);
183 }
184}
185
186void NonStrictMarking::AddTokenInPlace(Place& place, Token& token){
187 if(token.getCount() == 0) return;
188 for(TokenList::iterator iter = place.tokens.begin(); iter != place.tokens.end(); iter++){
189 if(iter->getAge() == token.getAge()){
190 iter->add(token.getCount());
191 return;
192 }
193 }
194 // Insert token
195 bool inserted = false;
196 for(TokenList::iterator it = place.tokens.begin(); it != place.tokens.end(); it++){
197 if(it->getAge() > token.getAge()){
198 place.tokens.insert(it, token);
199 inserted = true;
200 break;
201 }
202 }
203 if(!inserted){
204 place.tokens.push_back(token);
205 }
206}
207
208void NonStrictMarking::incrementAge(){
209 for(PlaceList::iterator iter = places.begin(); iter != places.end(); iter++){
210 iter->incrementAge();
211 }
212}
213void NonStrictMarking::decrementAge(){
214 for(PlaceList::iterator iter = places.begin(); iter != places.end(); iter++){
215 iter->decrementAge();
216 }
217}
218
219NonStrictMarking::~NonStrictMarking() {
220 // TODO: Should we destruct something here? (places)
221}
222
223bool NonStrictMarking::equals(const NonStrictMarking &m1) const{
224 if(m1.places.size() != places.size()) return false;
225
226 PlaceList::const_iterator p_iter = m1.places.begin();
227 for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++, p_iter++){
228 if(iter->place->GetIndex() != p_iter->place->GetIndex()) return false;
229 if(iter->tokens.size() != p_iter->tokens.size()) return false;
230 TokenList::const_iterator pt_iter = p_iter->tokens.begin();
231 for(TokenList::const_iterator t_iter = iter->tokens.begin(); t_iter != iter->tokens.end(); t_iter++, pt_iter++){
232 if(!t_iter->equals(*pt_iter)) return false;
233 }
234 }
235
236 return true;
237}
238
239std::ostream& operator<<(std::ostream& out, NonStrictMarking& x ) {
240 out << "-";
241 for(PlaceList::iterator iter = x.places.begin(); iter != x.places.end(); iter++){
242 out << "place " << iter->place->GetId() << " has tokens (age, count): ";
243 for(TokenList::iterator it = iter->tokens.begin(); it != iter->tokens.end(); it++){
244 out << "(" << it->getAge() << ", " << it->getCount() << ") ";
245 }
246 if(iter != x.places.end()-1){
247 out << endl;
248 }
249 }
250
251 return out;
252}
253
254} /* namespace DiscreteVerification */14} /* namespace DiscreteVerification */
255} /* namespace VerifyTAPN */15} /* namespace VerifyTAPN */
25616
=== modified file 'src/DiscreteVerification/DataStructures/NonStrictMarking.hpp'
--- src/DiscreteVerification/DataStructures/NonStrictMarking.hpp 2012-09-10 18:54:32 +0000
+++ src/DiscreteVerification/DataStructures/NonStrictMarking.hpp 2013-03-31 13:25:26 +0000
@@ -11,171 +11,49 @@
11#include <assert.h>11#include <assert.h>
12#include <vector>12#include <vector>
13#include "boost/functional/hash.hpp"13#include "boost/functional/hash.hpp"
14#include "NonStrictMarking.hpp"14#include "NonStrictMarkingBase.hpp"
15#include <iostream>15#include <iostream>
16#include "../../Core/TAPN/TAPN.hpp"16#include "../../Core/TAPN/TAPN.hpp"
17#include <iostream>
1817
19using namespace std;18using namespace std;
2019
21namespace VerifyTAPN {20namespace VerifyTAPN {
22namespace DiscreteVerification {21namespace DiscreteVerification {
2322
24class Place;23 struct MetaData {
25class Token;24 public:
26typedef vector<Token> TokenList;25 MetaData() : passed(false), inTrace(false) {};
2726 bool passed;
28class Token {27 bool inTrace;
29private:28 };
30 int age;29
31 int count;30 struct MetaDataWithTrace : public MetaData {
32public:31 const TAPN::TimedTransition* generatedBy;
33 Token(int age, int count) : age(age), count(count) { };32 };
34 Token(const Token& t) : age(t.age), count(t.count) { };33
3534 // ugly forward declaration
36 bool equals(const Token &t) const { return (this->age == t.age && this->count == t.count); };35 template<class MetaData>
3736 class EncodingPointer;
38 void add(int num){ count = count + num; };37
39 int getCount() const { return count; };38 struct MetaDataWithTraceAndEncoding : public MetaDataWithTrace {
40 int getAge() const { return age; };39 EncodingPointer<MetaData>* ep;
41 void setAge(int i) { age = i; };40 MetaDataWithTraceAndEncoding* parent;
42 void setCount(int i) { count = i; };41 };
43 void remove(int num){ count = count - num; };42
4443 class NonStrictMarking : public NonStrictMarkingBase{
45 // Ages all tokens by 144 public:
46 inline void incrementAge(){45 NonStrictMarking():NonStrictMarkingBase(), meta(new MetaData()){}
47 age++;46 NonStrictMarking(const TAPN::TimedArcPetriNet& tapn, const std::vector<int>& v):NonStrictMarkingBase(tapn, v){}
48 }47 NonStrictMarking(const NonStrictMarkingBase& nsm):NonStrictMarkingBase(nsm){
49 inline void decrementAge(){48
50 age--;49 }
51 }50 NonStrictMarking(const NonStrictMarking& nsm):NonStrictMarkingBase(nsm){
5251
53 friend std::size_t hash_value(Token const& t)52 }
54 {53 public:
55 size_t seed = 0;54 MetaData* meta;
56 boost::hash_combine(seed, t.getAge());55 };
57 boost::hash_combine(seed, t.getCount());56
58 return seed;
59 }
60};
61
62class Place {
63public:
64 const TAPN::TimedPlace* place;
65 TokenList tokens;
66
67 Place(const TAPN::TimedPlace* place) : place(place){};
68 Place(const Place& p) : place(p.place){
69 for(TokenList::const_iterator it = p.tokens.begin(); it != p.tokens.end(); it++){
70 tokens.push_back(*it);
71 }
72 };
73
74 friend std::size_t hash_value(Place const& p)
75 {
76 std::size_t seed = boost::hash_range(p.tokens.begin(), p.tokens.end());
77 boost::hash_combine(seed, p.place->GetIndex());
78
79 return seed;
80 }
81
82 int NumberOfTokens() const{
83 int count = 0;
84 for(TokenList::const_iterator iter = tokens.begin(); iter != tokens.end(); iter++){
85 count += iter->getCount();
86 }
87 return count;
88 }
89
90 int MaxTokenAge() const{
91 int max = -1;
92 for(TokenList::const_iterator iter = tokens.begin(); iter != tokens.end(); iter++){
93 if(iter->getAge() > max) max = iter->getAge();
94 }
95 return max;
96 }
97
98 // Ages all tokens by 1
99 void incrementAge(){
100 for(TokenList::iterator iter = tokens.begin(); iter != tokens.end(); iter++){
101 iter->incrementAge();
102 }
103 }
104
105 void decrementAge(){
106 for(TokenList::iterator iter = tokens.begin(); iter != tokens.end(); iter++){
107 iter->decrementAge();
108 }
109 }
110};
111
112typedef vector<Place> PlaceList;
113
114class NonStrictMarking {
115public:
116 NonStrictMarking();
117 NonStrictMarking(const TAPN::TimedArcPetriNet& tapn, const std::vector<int>& v);
118 NonStrictMarking(const NonStrictMarking& nsm);
119
120public:
121 friend std::ostream& operator<<(std::ostream& out, NonStrictMarking& x );
122 friend class DiscreteVerification;
123
124 virtual ~NonStrictMarking();
125
126 virtual size_t HashKey() const { return boost::hash_range(places.begin(), places.end()); };
127
128 virtual NonStrictMarking& Clone()
129 {
130 NonStrictMarking* clone = new NonStrictMarking(*this);
131 return *clone;
132 };
133
134 public: // inspectors
135 //int NumberOfTokensInPlace(const Place& palce) const;
136 int NumberOfTokensInPlace(int placeId) const;
137 const TokenList& GetTokenList(int placeId);
138 const PlaceList& GetPlaceList() const{ return places; }
139 unsigned int size();
140 const NonStrictMarking* GetParent() const { return parent; }
141 const TAPN::TimedTransition* GetGeneratedBy() const { return generatedBy; }
142
143
144 public: // modifiers
145 bool RemoveToken(int placeId, int age);
146 bool RemoveToken(Place& place, Token& token);
147 void AddTokenInPlace(TAPN::TimedPlace& place, int age);
148 void AddTokenInPlace(Place& place, Token& token);
149 void AddTokenInPlace(TAPN::TimedPlace& place, Token& token);
150 void incrementAge(); // increment
151 void decrementAge(); // decrement
152 void RemoveRangeOfTokens(Place& place, TokenList::iterator begin, TokenList::iterator end);
153 void SetParent(NonStrictMarking* parent) { this->parent = parent; }
154 void SetGeneratedBy(const TAPN::TimedTransition* generatedBy) { this->generatedBy = generatedBy; }
155 void CleanUp() {
156 for(unsigned int i = 0; i < places.size(); i++){
157 if(places[i].tokens.empty()){
158 places.erase(places.begin()+i);
159 }
160 }
161 }
162
163 public:
164 bool equals(const NonStrictMarking &m1) const;
165
166 public:
167 bool inTrace;
168 int children;
169 bool passed;
170 PlaceList places;
171 TokenList emptyTokenList;
172
173 public:
174 NonStrictMarking* parent;
175 const TAPN::TimedTransition* generatedBy;
176};
177
178std::ostream& operator<<(std::ostream& out, NonStrictMarking& x);
17957
180} /* namespace DiscreteVerification */58} /* namespace DiscreteVerification */
181} /* namespace VerifyTAPN */59} /* namespace VerifyTAPN */
18260
=== added file 'src/DiscreteVerification/DataStructures/NonStrictMarkingBase.cpp'
--- src/DiscreteVerification/DataStructures/NonStrictMarkingBase.cpp 1970-01-01 00:00:00 +0000
+++ src/DiscreteVerification/DataStructures/NonStrictMarkingBase.cpp 2013-03-31 13:25:26 +0000
@@ -0,0 +1,339 @@
1/*
2 * NonStrictMarkingBase.cpp
3 *
4 * Created on: 29/02/2012
5 * Author: MathiasGS
6 */
7
8#include "NonStrictMarkingBase.hpp"
9
10using namespace std;
11
12namespace VerifyTAPN {
13namespace DiscreteVerification {
14
15NonStrictMarkingBase::NonStrictMarkingBase() : children(0), generatedBy(NULL){
16 // TODO Auto-generated constructor stub
17
18}
19
20NonStrictMarkingBase::NonStrictMarkingBase(const TAPN::TimedArcPetriNet& tapn, const std::vector<int>& v) :children(0), generatedBy(NULL){
21 int prevPlaceId = -1;
22 for(std::vector<int>::const_iterator iter = v.begin(); iter != v.end(); iter++){
23 if(*iter == prevPlaceId){
24 Place& p = places.back();
25 if(p.tokens.size() == 0){
26 Token t(0,1);
27 p.tokens.push_back(t);
28 }else{
29 p.tokens.begin()->add(1);
30 }
31 }else{
32
33 Place p(&tapn.GetPlace(*iter));
34 Token t(0,1);
35 p.tokens.push_back(t);
36 places.push_back(p);
37 }
38 prevPlaceId = *iter;
39 }
40}
41
42NonStrictMarkingBase::NonStrictMarkingBase(const NonStrictMarkingBase& nsm) : children(0), generatedBy(NULL){
43 //for(PlaceList::const_iterator it = nsm.places.begin(); it != nsm.places.end(); it++){
44 // places.push_back(Place(*it));
45 //}
46
47 places = nsm.places;
48
49 parent = nsm.parent;
50 generatedBy = nsm.generatedBy;
51}
52
53unsigned int NonStrictMarkingBase::size(){
54 int count = 0;
55 for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++){
56 for(TokenList::const_iterator it = iter->tokens.begin(); it != iter->tokens.end(); it++){
57 count += it->getCount();
58 }
59 }
60 return count;
61}
62
63//int NonStrictMarkingBase::NumberOfTokensInPlace(const Place& place) const{
64// int count = 0;
65// for(TokenList::const_iterator it = place.tokens.begin(); it != place.tokens.end(); it++){
66// count = count + it->getCount();
67// }
68// return count;
69//}
70
71int NonStrictMarkingBase::NumberOfTokensInPlace(int placeId) const{
72 int count = 0;
73 for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++){
74 if(iter->place->GetIndex() == placeId){
75 for(TokenList::const_iterator it = iter->tokens.begin(); it != iter->tokens.end(); it++){
76 count = count + it->getCount();
77 }
78 }
79 }
80 return count;
81}
82
83const TokenList& NonStrictMarkingBase::GetTokenList(int placeId) const{
84 for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++){
85 if(iter->place->GetIndex() == placeId) return iter->tokens;
86 }
87 return emptyTokenList;
88}
89
90bool NonStrictMarkingBase::RemoveToken(int placeId, int age){
91 for(PlaceList::iterator pit = places.begin(); pit != places.end(); pit++){
92 if(pit->place->GetIndex() == placeId){
93 for(TokenList::iterator tit = pit->tokens.begin(); tit != pit->tokens.end(); tit++){
94 if(tit->getAge() == age){
95 return RemoveToken(*pit, *tit);
96 }
97 }
98 }
99 }
100 return false;
101}
102
103void NonStrictMarkingBase::RemoveRangeOfTokens(Place& place, TokenList::iterator begin, TokenList::iterator end){
104 place.tokens.erase(begin, end);
105}
106
107bool NonStrictMarkingBase::RemoveToken(Place& place, Token& token){
108 if(token.getCount() > 1){
109 token.remove(1);
110 return true;
111 }else{
112 for(TokenList::iterator iter = place.tokens.begin(); iter != place.tokens.end(); iter++){
113 if(iter->getAge() == token.getAge()){
114 place.tokens.erase(iter);
115 if(place.tokens.empty()){
116 for(PlaceList::iterator it = places.begin(); it != places.end(); it++){
117 if(it->place->GetIndex() == place.place->GetIndex()){
118 places.erase(it);
119 return true;
120 }
121 }
122 }
123 return true;
124 }
125 }
126 }
127 return false;
128}
129
130void NonStrictMarkingBase::AddTokenInPlace(TAPN::TimedPlace& place, int age){
131 for(PlaceList::iterator pit = places.begin(); pit != places.end(); pit++){
132 if(pit->place->GetIndex() == place.GetIndex()){
133 for(TokenList::iterator tit = pit->tokens.begin(); tit != pit->tokens.end(); tit++){
134 if(tit->getAge() == age){
135 Token t(age, 1);
136 AddTokenInPlace(*pit, t);
137 return;
138 }
139 }
140 Token t(age,1);
141 AddTokenInPlace(*pit, t);
142 return;
143 }
144 }
145 Token t(age,1);
146 Place p(&place);
147 AddTokenInPlace(p,t);
148
149 // Insert place
150 bool inserted = false;
151 for(PlaceList::iterator it = places.begin(); it != places.end(); it++){
152 if(it->place->GetIndex() > place.GetIndex()){
153 places.insert(it, p);
154 inserted = true;
155 break;
156 }
157 }
158 if(!inserted){
159 places.push_back(p);
160 }
161}
162
163void NonStrictMarkingBase::AddTokenInPlace(const TAPN::TimedPlace& place, Token& token){
164 for(PlaceList::iterator pit = places.begin(); pit != places.end(); pit++){
165 if(pit->place->GetIndex() == place.GetIndex()){
166 AddTokenInPlace(*pit, token);
167 return;
168 }
169 }
170
171 Place p(&place);
172 AddTokenInPlace(p,token);
173
174 // Insert place
175 bool inserted = false;
176 for(PlaceList::iterator it = places.begin(); it != places.end(); it++){
177 if(it->place->GetIndex() > place.GetIndex()){
178 places.insert(it, p);
179 inserted = true;
180 break;
181 }
182 }
183 if(!inserted){
184 places.push_back(p);
185 }
186}
187
188void NonStrictMarkingBase::AddTokenInPlace(Place& place, Token& token){
189 if(token.getCount() == 0) return;
190 for(TokenList::iterator iter = place.tokens.begin(); iter != place.tokens.end(); iter++){
191 if(iter->getAge() == token.getAge()){
192 iter->add(token.getCount());
193 return;
194 }
195 }
196 // Insert token
197 bool inserted = false;
198 for(TokenList::iterator it = place.tokens.begin(); it != place.tokens.end(); it++){
199 if(it->getAge() > token.getAge()){
200 place.tokens.insert(it, token);
201 inserted = true;
202 break;
203 }
204 }
205 if(!inserted){
206 place.tokens.push_back(token);
207 }
208}
209
210void NonStrictMarkingBase::incrementAge(){
211 for(PlaceList::iterator iter = places.begin(); iter != places.end(); iter++){
212 iter->incrementAge();
213 }
214}
215
216void NonStrictMarkingBase::incrementAge(int age){
217 for(PlaceList::iterator iter = places.begin(); iter != places.end(); iter++){
218 iter->incrementAge(age);
219 }
220}
221
222void NonStrictMarkingBase::decrementAge(){
223 for(PlaceList::iterator iter = places.begin(); iter != places.end(); iter++){
224 iter->decrementAge();
225 }
226}
227
228NonStrictMarkingBase::~NonStrictMarkingBase() { }
229
230bool NonStrictMarkingBase::equals(const NonStrictMarkingBase &m1) const{
231 if(m1.places.size() != places.size()) return false;
232
233 PlaceList::const_iterator p_iter = m1.places.begin();
234 for(PlaceList::const_iterator iter = places.begin(); iter != places.end(); iter++, p_iter++){
235 if(iter->place->GetIndex() != p_iter->place->GetIndex()) return false;
236 if(iter->tokens.size() != p_iter->tokens.size()) return false;
237 TokenList::const_iterator pt_iter = p_iter->tokens.begin();
238 for(TokenList::const_iterator t_iter = iter->tokens.begin(); t_iter != iter->tokens.end(); t_iter++, pt_iter++){
239 if(!t_iter->equals(*pt_iter)) return false;
240 }
241 }
242
243 return true;
244}
245
246std::ostream& operator<<(std::ostream& out, NonStrictMarkingBase& x ) {
247 out << "-";
248 for(PlaceList::iterator iter = x.places.begin(); iter != x.places.end(); iter++){
249 out << "place " << iter->place->GetId() << " has tokens (age, count): ";
250 for(TokenList::iterator it = iter->tokens.begin(); it != iter->tokens.end(); it++){
251 out << "(" << it->getAge() << ", " << it->getCount() << ") ";
252 }
253 if(iter != x.places.end()-1){
254 out << endl;
255 }
256 }
257
258 return out;
259}
260
261void NonStrictMarkingBase::cut(){
262#ifdef DEBUG
263 std::cout << "Before cut: " << *this << std::endl;
264#endif
265 for(PlaceList::iterator place_iter = this->places.begin(); place_iter != this->places.end(); place_iter++){
266 //remove dead tokens
267 if (place_iter->place->GetType() == TAPN::Dead) {
268 for(TokenList::iterator token_iter = place_iter->tokens.begin(); token_iter != place_iter->tokens.end(); token_iter++){
269 if(token_iter->getAge() > place_iter->place->GetMaxConstant()){
270 token_iter->remove(token_iter->getCount());
271 }
272 }
273 }
274 //set age of too old tokens to max age
275 int count = 0;
276 for(TokenList::iterator token_iter = place_iter->tokens.begin(); token_iter != place_iter->tokens.end(); token_iter++){
277 if(token_iter->getAge() > place_iter->place->GetMaxConstant()){
278 TokenList::iterator beginDelete = token_iter;
279 if(place_iter->place->GetType() == TAPN::Std){
280 for(; token_iter != place_iter->tokens.end(); token_iter++){
281 count += token_iter->getCount();
282 }
283 }
284 this->RemoveRangeOfTokens(*place_iter, beginDelete, place_iter->tokens.end());
285 break;
286 }
287 }
288 Token t(place_iter->place->GetMaxConstant()+1,count);
289 this->AddTokenInPlace(*place_iter, t);
290 }
291 this->CleanUp();
292 #ifdef DEBUG
293 std::cout << "After cut: " << *this << std::endl;
294 #endif
295}
296
297int NonStrictMarkingBase::getYoungest(){
298 int youngest = INT_MAX;
299 for(PlaceList::const_iterator place_iter = GetPlaceList().begin(); place_iter != GetPlaceList().end(); place_iter++){
300 if(youngest > place_iter->tokens.front().getAge() && place_iter->tokens.front().getAge() <= place_iter->place->GetMaxConstant()){
301 youngest = place_iter->tokens.front().getAge();
302 }
303 }
304
305 if(youngest == INT_MAX){
306 youngest = 0;
307 }
308 return youngest;
309}
310
311int NonStrictMarkingBase::makeBase(TAPN::TimedArcPetriNet* tapn){
312 #ifdef DEBUG
313 std::cout << "Before makeBase: " << *this << std::endl;
314 #endif
315 int youngest = getYoungest();
316
317 for(PlaceList::iterator place_iter = places.begin(); place_iter != places.end(); place_iter++){
318 for(TokenList::iterator token_iter = place_iter->tokens.begin(); token_iter != place_iter->tokens.end(); token_iter++){
319 if(token_iter->getAge() != place_iter->place->GetMaxConstant() + 1){
320 token_iter->setAge(token_iter->getAge()-youngest);
321 }
322#ifdef DEBUG
323 else if(token_iter->getAge() > place_iter->place->GetMaxConstant() + 1){
324 assert(false);
325 }
326#endif
327 }
328 }
329
330 #ifdef DEBUG
331 std::cout << "After makeBase: " << *this << std::endl;
332 std::cout << "Youngest: " << youngest << std::endl;
333 #endif
334
335 return youngest;
336}
337
338} /* namespace DiscreteVerification */
339} /* namespace VerifyTAPN */
0340
=== added file 'src/DiscreteVerification/DataStructures/NonStrictMarkingBase.hpp'
--- src/DiscreteVerification/DataStructures/NonStrictMarkingBase.hpp 1970-01-01 00:00:00 +0000
+++ src/DiscreteVerification/DataStructures/NonStrictMarkingBase.hpp 2013-03-31 13:25:26 +0000
@@ -0,0 +1,196 @@
1/*
2 * NonStrictMarkingBase.hpp
3 *
4 * Created on: 29/02/2012
5 * Author: MathiasGS
6 */
7
8#ifndef NonStrictMarkingBase_HPP_
9#define NonStrictMarkingBase_HPP_
10
11#include <assert.h>
12#include <vector>
13#include "boost/functional/hash.hpp"
14#include <iostream>
15#include "../../Core/TAPN/TAPN.hpp"
16#include <iostream>
17
18using namespace std;
19
20namespace VerifyTAPN {
21namespace DiscreteVerification {
22
23class Place;
24class Token;
25typedef vector<Token> TokenList;
26
27class Token {
28private:
29 int age;
30 int count;
31public:
32 Token(int age, int count) : age(age), count(count) { };
33 Token(const Token& t) : age(t.age), count(t.count) { };
34
35 bool equals(const Token &t) const { return (this->age == t.age && this->count == t.count); };
36
37 void add(int num){ count = count + num; };
38 int getCount() const { return count; };
39 int getAge() const { return age; };
40 void setAge(int i) { age = i; };
41 void setCount(int i) { count = i; };
42 void remove(int num){ count = count - num; };
43
44 // Ages all tokens by 1
45 inline void incrementAge(){
46 age++;
47 }
48
49 inline void incrementAge(int x){
50 age += x;
51 }
52
53 inline void decrementAge(){
54 age--;
55 }
56
57 friend std::size_t hash_value(Token const& t)
58 {
59 size_t seed = 0;
60 boost::hash_combine(seed, t.getAge());
61 boost::hash_combine(seed, t.getCount());
62 return seed;
63 }
64};
65
66class Place {
67public:
68 const TAPN::TimedPlace* place;
69 TokenList tokens;
70
71 Place(const TAPN::TimedPlace* place) : place(place){};
72 Place(const Place& p) : place(p.place){
73 for(TokenList::const_iterator it = p.tokens.begin(); it != p.tokens.end(); it++){
74 tokens.push_back(*it);
75 }
76 };
77
78 friend std::size_t hash_value(Place const& p)
79 {
80 std::size_t seed = boost::hash_range(p.tokens.begin(), p.tokens.end());
81 boost::hash_combine(seed, p.place->GetIndex());
82
83 return seed;
84 }
85
86 int NumberOfTokens() const{
87 int count = 0;
88 for(TokenList::const_iterator iter = tokens.begin(); iter != tokens.end(); iter++){
89 count += iter->getCount();
90 }
91 return count;
92 }
93
94 int MaxTokenAge() const{
95 int max = -1;
96 for(TokenList::const_iterator iter = tokens.begin(); iter != tokens.end(); iter++){
97 if(iter->getAge() > max) max = iter->getAge();
98 }
99 return max;
100 }
101
102 // Ages all tokens by 1
103 void incrementAge(){
104 for(TokenList::iterator iter = tokens.begin(); iter != tokens.end(); iter++){
105 iter->incrementAge();
106 }
107 }
108
109 void incrementAge(int age){
110 for(TokenList::iterator iter = tokens.begin(); iter != tokens.end(); iter++){
111 iter->incrementAge(age);
112 }
113 }
114
115 void decrementAge(){
116 for(TokenList::iterator iter = tokens.begin(); iter != tokens.end(); iter++){
117 iter->decrementAge();
118 }
119 }
120};
121
122typedef vector<Place> PlaceList;
123
124class NonStrictMarkingBase {
125public:
126 NonStrictMarkingBase();
127 NonStrictMarkingBase(const TAPN::TimedArcPetriNet& tapn, const std::vector<int>& v);
128 NonStrictMarkingBase(const NonStrictMarkingBase& nsm);
129
130public:
131 friend std::ostream& operator<<(std::ostream& out, NonStrictMarkingBase& x );
132 friend class DiscreteVerification;
133
134 virtual ~NonStrictMarkingBase();
135
136 virtual size_t HashKey() const { return boost::hash_range(places.begin(), places.end()); };
137
138 virtual NonStrictMarkingBase& Clone()
139 {
140 NonStrictMarkingBase* clone = new NonStrictMarkingBase(*this);
141 return *clone;
142 };
143
144 public: // inspectors
145 //int NumberOfTokensInPlace(const Place& palce) const;
146 int NumberOfTokensInPlace(int placeId) const;
147 const TokenList& GetTokenList(int placeId) const;
148 const PlaceList& GetPlaceList() const{ return places; }
149 unsigned int size();
150 const NonStrictMarkingBase* GetParent() const { return parent; }
151 const TAPN::TimedTransition* GetGeneratedBy() const { return generatedBy; }
152
153
154 public: // modifiers
155 void cut();
156 bool RemoveToken(int placeId, int age);
157 bool RemoveToken(Place& place, Token& token);
158 void AddTokenInPlace(TAPN::TimedPlace& place, int age);
159 void AddTokenInPlace(Place& place, Token& token);
160 void AddTokenInPlace(const TAPN::TimedPlace& place, Token& token);
161 void incrementAge(); // increment
162 void incrementAge(int age);
163 void decrementAge(); // decrement
164 void RemoveRangeOfTokens(Place& place, TokenList::iterator begin, TokenList::iterator end);
165 void SetParent(NonStrictMarkingBase* parent) { this->parent = parent; }
166 void SetGeneratedBy(const TAPN::TimedTransition* generatedBy) { this->generatedBy = generatedBy; }
167 void CleanUp() {
168 for(unsigned int i = 0; i < places.size(); i++){
169 if(places[i].tokens.empty()){
170 places.erase(places.begin()+i);
171 i--;
172 }
173 }
174 }
175 int getYoungest();
176 int makeBase(TAPN::TimedArcPetriNet* tapn);
177
178 public:
179 bool equals(const NonStrictMarkingBase &m1) const;
180
181 public:
182 int children;
183 PlaceList places;
184 TokenList emptyTokenList;
185
186 public:
187 NonStrictMarkingBase* parent;
188 const TAPN::TimedTransition* generatedBy;
189};
190
191std::ostream& operator<<(std::ostream& out, NonStrictMarkingBase& x);
192
193} /* namespace DiscreteVerification */
194} /* namespace VerifyTAPN */
195
196#endif /* NonStrictMarkingBase_HPP_ */
0197
=== added file 'src/DiscreteVerification/DataStructures/PData.cpp'
--- src/DiscreteVerification/DataStructures/PData.cpp 1970-01-01 00:00:00 +0000
+++ src/DiscreteVerification/DataStructures/PData.cpp 2013-03-31 13:25:26 +0000
@@ -0,0 +1,16 @@
1/*
2 * File: PData.cpp
3 * Author: floop
4 *
5 * Created on 5. november 2012, 10:22
6 */
7
8#include <set>
9
10#include "PData.h"
11namespace VerifyTAPN {
12 namespace DiscreteVerification {
13
14
15 }
16}
0\ No newline at end of file17\ No newline at end of file
118
=== added file 'src/DiscreteVerification/DataStructures/PData.h'
--- src/DiscreteVerification/DataStructures/PData.h 1970-01-01 00:00:00 +0000
+++ src/DiscreteVerification/DataStructures/PData.h 2013-03-31 13:25:26 +0000
@@ -0,0 +1,427 @@
1/*
2 * File: PData.h
3 * Author: Peter Gjøl Jensen
4 *
5 * Created on 5. november 2012, 10:22
6 */
7
8
9#include "NonStrictMarking.hpp"
10#include "EncodingStructure.h"
11#include "TimeDart.hpp"
12
13#ifndef PDATA_H
14#define PDATA_H
15namespace VerifyTAPN {
16 namespace DiscreteVerification {
17
18 // pointer containing enough data to reconstruct the stored data at any time!
19 template<typename T>
20 struct EncodingPointer {
21 EncodingStructure<T*> encoding;
22 unsigned int node;
23
24 EncodingPointer() {
25 };
26
27 EncodingPointer(EncodingPointer<T> &en) : encoding(en.encoding.Clone()), node(en.node) {}; // possible mem-leak?
28
29 EncodingPointer(EncodingStructure<T*> &en, unsigned int n) : encoding(en.Clone()), node(n) {
30 }
31 };
32
33 template<typename T>
34 class PData {
35 public:
36 typedef unsigned int uint;
37 typedef EncodingStructure<T*> MarkingEncoding;
38
39 struct Result {
40 bool isNew;
41 MarkingEncoding encoding;
42 uint pos;
43
44 Result(bool ex, MarkingEncoding en, uint node) : isNew(ex), encoding(en), pos(node) {
45 };
46 };
47
48
49 PData(boost::shared_ptr<TAPN::TimedArcPetriNet>& tapn, int knumber, int nplaces, int mage) :
50 k(knumber),
51 maxAge(mage + 1),
52 numberOfPlaces(nplaces),
53 countSize(ceil(log2((knumber ? knumber : 1)) + 1)),
54 enumeratedOffset(ceil(log2((nplaces * (mage + 1))) + 1) + countSize),
55 numberOfVariables(enumeratedOffset * (knumber ? knumber : 1)),
56 cachesize(128),
57 tapn(tapn) {
58 overhead = MarkingEncoding::Overhead(this->numberOfVariables);
59 this->numberOfVariables += overhead;
60 stored = 0;
61 bddsize = cachesize;
62 this->BDDArr.push_back(new PNode[this->bddsize]);
63 memset(this->BDDArr[0], 0xffffffff, this->bddsize * sizeof (PNode));
64 BDDArr[0][0].shadow = NULL;
65 BDDArr[0][0].highCount = BDDArr[0][0].lowCount = 0;
66 BDDArr[0][0].lowpos = BDDArr[0][0].highpos = 0;
67 BDDArr[0][0].parent = 0;
68 bddnext = 1;
69 encoding = MarkingEncoding(this->numberOfVariables);
70 listcount = 0;
71 maxCount = sizeof (PNode) * 4 + sizeof (std::list<PNode>) * 4;
72
73 };
74 virtual ~PData();
75
76 uint maxCount;
77
78 struct PNode {
79 MarkingEncoding* shadow;
80 uint highpos;
81
82 uint lowpos;
83
84 short int highCount;
85 short int lowCount;
86 uint parent;
87 };
88
89 bool search(MarkingEncoding* arr, MarkingEncoding en, int size) {
90 for (int i = 0; i < size; i++) {
91 if (arr[i] == en)
92 return true;
93 }
94 return false;
95 }
96 /* bool equal(MarkingEncoding* arr, EncodingList* lst){
97 EncodingList::const_iterator it = lst->begin();
98 while(it != lst->end()){
99 if(!search(arr, *it, lst->size()))
100 return false;
101 it++;
102 }
103 return true;
104 }*/
105
106 Result Add(NonStrictMarkingBase* marking);
107
108 unsigned int size() {
109 return stored;
110 }
111 void PrintMemStats();
112 void PrintEncoding(bool* encoding, int length);
113
114 inline PNode* FetchNode(uint i) {
115 return &BDDArr[i / cachesize][i % cachesize];
116 }
117 NonStrictMarkingBase* EnumerateDecode(const EncodingPointer<T>& pointer);
118
119 int EnumeratedEncoding(NonStrictMarkingBase* marking);
120 const uint k;
121 const uint maxAge;
122 const uint numberOfPlaces;
123 const uint countSize;
124 const uint enumeratedOffset;
125 uint numberOfVariables;
126 const uint cachesize;
127
128 boost::shared_ptr<TAPN::TimedArcPetriNet>& tapn;
129
130 MarkingEncoding encoding;
131 vector<PNode*> BDDArr;
132 uint bddsize;
133 uint stored;
134 uint bddnext;
135 uint overhead;
136 uint listcount;
137 };
138
139 template<typename T>
140 PData<T>::~PData() {
141 }
142
143
144 template<typename T>
145 int PData<T>::EnumeratedEncoding(NonStrictMarkingBase* marking) {
146 encoding.Zero();
147
148 int tc = 0;
149 uint bitcount = 0;
150
151 for (vector<Place>::const_iterator pi = marking->places.begin();
152 pi != marking->places.end();
153 pi++) { // for each place
154
155 int pc = pi->place->GetIndex();
156
157 for (TokenList::const_iterator ti = pi->tokens.begin(); // for each token-element
158 ti != pi->tokens.end();
159 ti++) {
160
161 // for (int i = 0; i < ti->getCount(); i++) // for each ACTUAL token
162 // {
163 int offset = tc * this->enumeratedOffset; // the offset of the variables for this token
164 uint number = ti->getCount();
165 bitcount = 0;
166 while (number) { // set the vars while there are bits left
167 if (number & 1) {
168 this->encoding.Set(overhead + offset + bitcount, true);
169 }
170 bitcount++;
171 number = number >> 1;
172 }
173 uint pos = pc + this->numberOfPlaces * ti->getAge(); // the enumerated configuration of the token
174 bitcount = countSize;
175 /* binary */
176 while (pos) { // set the vars while there are bits left
177 if (pos & 1) {
178 this->encoding.Set(overhead + offset + bitcount, true);
179 }
180 bitcount++;
181 pos = pos >> 1;
182 }
183 tc++;
184 // }
185
186 }
187 }
188 if (tc == 0)
189 return 0;
190 else
191 return ((tc - 1) * this->enumeratedOffset) + bitcount;
192 }
193
194 template<typename T>
195 NonStrictMarkingBase* PData<T>::EnumerateDecode(const EncodingPointer<T> &pointer) {
196 NonStrictMarkingBase* m = new NonStrictMarkingBase();
197 this->encoding.Zero();
198
199 uint var = 0;
200 uint n = pointer.node;
201 while (n) {
202 n = FetchNode(n)->parent;
203 var++;
204 }
205 var += this->overhead;
206
207 // m->meta = pointer.encoding.GetMetaData();
208 this->encoding.Copy(pointer.encoding, var);
209 uint nbits = (var - (var % 8)) + pointer.encoding.Size()*8;
210 uint self = pointer.node;
211
212 while (self) {
213 var--;
214 n = FetchNode(self)->parent;
215 bool branch = FetchNode(n)->highpos == self;
216 this->encoding.Set(var, branch);
217 self = n;
218
219 }
220
221 var = this->numberOfVariables - 1;
222 // foreach token
223 uint data = 0;
224 uint count = 0;
225 for (int i = this->k - 1; i >= 0; i--) {
226 uint offset = (this->enumeratedOffset * i) + this->overhead + this->countSize;
227 while (nbits >= offset) {
228 data = data << 1;
229
230 if (encoding.At(nbits)) {
231 data = data | 1;
232 }
233 if (nbits == 0) {
234 break;
235 }
236 nbits--;
237 }
238 offset -= this->countSize;
239 while (nbits >= offset) {
240 count = count << 1;
241
242 if (encoding.At(nbits)) {
243 count = count | 1;
244 }
245 if (nbits == 0) {
246 break;
247 }
248 nbits--;
249 }
250
251 if (count) {
252 int age = floor(data / this->numberOfPlaces);
253 uint place = (data % this->numberOfPlaces);
254 Token t = Token(age, count);
255 m->AddTokenInPlace(tapn->GetPlace(place), t);
256 data = 0;
257 count = 0;
258 }
259 }
260 return m;
261 }
262
263 template<typename T>
264 typename PData<T>::Result PData<T>::Add(NonStrictMarkingBase* marking) {
265
266 int encsize = this->EnumeratedEncoding(marking) + overhead;
267 // go through the BDD as far as possible with the encoding of the marking
268 uint c_count = 0;
269 uint prev_count = 0;
270 int var = overhead;
271 do {
272
273 prev_count = c_count;
274 if (encoding.At(var)) {
275 c_count = BDDArr[c_count / cachesize][c_count % cachesize].highpos;
276
277 } else {
278 c_count = BDDArr[c_count / cachesize][c_count % cachesize].lowpos;
279 }
280
281 var++;
282
283 } while (c_count != 0);
284 var--;
285
286 PNode* prev_node = FetchNode(prev_count);
287
288 int listsize = 0;
289 if (prev_node->highCount >= 0) {
290 listsize += prev_node->highCount;
291 }
292 if (prev_node->lowCount >= 0) {
293 listsize += prev_node->lowCount;
294 }
295
296 int size = this->numberOfVariables - var;
297 MarkingEncoding en = MarkingEncoding(encoding.GetRaw(), size, var, encsize);
298
299 int ins = 0;
300
301 for (; ins < listsize; ins++) {
302 if (prev_node->shadow[ins] == en) {
303 break;
304 }
305 }
306 if (ins != listsize) {
307 return Result(false, prev_node->shadow[ins], prev_count);
308 }
309
310 en = MarkingEncoding(encoding, size, var, encsize);
311 short unsigned int count;
312
313 MarkingEncoding* nlist = new MarkingEncoding[listsize + 1];
314 nlist[listsize] = en;
315
316 for (int i = 0; i < listsize; i++) {
317 nlist[i] = prev_node->shadow[i];
318 }
319 delete[] prev_node->shadow;
320 prev_node->shadow = nlist;
321
322
323 bool branch = encoding.At(var);
324 if (branch) {
325 count = (++prev_node->highCount);
326 } else {
327 count = (++prev_node->lowCount);
328 }
329
330 if (count > maxCount) {
331
332 size--;
333 int testclist = 0;
334 int testnlist = 0;
335 PNode* c_node = &this->BDDArr[floor(this->bddnext / this->cachesize)][this->bddnext % this->cachesize];
336 if (branch) {
337 prev_node->highpos = this->bddnext;
338 c_node->shadow = new MarkingEncoding[testclist = prev_node->highCount];
339 prev_node->highCount = -1;
340 if (prev_node->lowCount > 0)
341 nlist = new MarkingEncoding[testnlist = prev_node->lowCount];
342 else
343 nlist = NULL;
344 } else {
345 prev_node->lowpos = this->bddnext;
346 c_node->shadow = new MarkingEncoding[testclist = prev_node->lowCount];
347 prev_node->lowCount = -1;
348 if (prev_node->highCount > 0)
349 nlist = new MarkingEncoding[testnlist = prev_node->highCount];
350 else
351 nlist = NULL;
352 }
353 c_node->parent = prev_count;
354 prev_count = this->bddnext;
355 listcount++;
356 c_node->lowCount = c_node->highCount = 0;
357 c_node->lowpos = c_node->highpos = 0;
358 uint npos = ((this->numberOfVariables - (size + 1)) % 8);
359
360 MarkingEncoding nee;
361 int clistcount = 0;
362 int nlistcount = 0;
363 for (int i = 0; i < listsize + 1; i++) {
364 if (prev_node->shadow[i].At(npos) == branch) {
365 if (!(size % 8)) {
366 nee = MarkingEncoding(prev_node->shadow[i], 8);
367 if (i == ins) {
368 en = nee;
369 }
370 prev_node->shadow[i].Release();
371 } else {
372 nee = prev_node->shadow[i];
373 }
374 if (nee.At((npos + 1) % 8)) {
375 c_node->highCount++;
376 } else {
377 c_node->lowCount++;
378 }
379 c_node->shadow[clistcount] = nee;
380 clistcount++;
381 } else {
382 nlist[nlistcount] = prev_node->shadow[i];
383 nlistcount++;
384 }
385
386 }
387 delete[] prev_node->shadow;
388 prev_node->shadow = nlist;
389
390 if (prev_node->highCount == -1 && prev_node->lowCount == -1) {
391 listcount--;
392 delete[] prev_node->shadow;
393 }
394
395 this->bddnext++;
396 if (this->bddnext == this->bddsize) {
397 this->bddsize += this->cachesize;
398 this->BDDArr.push_back(new PNode[this->cachesize]);
399 memset(this->BDDArr[floor(this->bddsize / this->cachesize) - 1], 0xffffffff, (this->cachesize) * sizeof (PNode));
400 }
401 }
402
403 stored++;
404 return Result(true, en, prev_count);
405
406 }
407
408 template<typename T>
409 void PData<T>::PrintMemStats() {
410 cout << endl << "Encoding size;" << endl <<
411 "\t\t\t" << this->numberOfVariables << endl;
412 cout << "Lists:" << endl <<
413 "\t count \t\t" << this->listcount << endl;
414 cout << "Nodes:" << endl <<
415 "\t count \t\t" << this->bddnext - 1 << endl;
416 }
417
418 template<typename T>
419 void PData<T>::PrintEncoding(bool* encoding, int length) {
420 for (int i = 0; i < length; i++)
421 cout << encoding[i];
422 cout << endl;
423 }
424 }
425}
426#endif /* PDATA_H */
427
0428
=== modified file 'src/DiscreteVerification/DataStructures/PWList.cpp' (properties changed: +x to -x)
--- src/DiscreteVerification/DataStructures/PWList.cpp 2012-11-24 11:35:27 +0000
+++ src/DiscreteVerification/DataStructures/PWList.cpp 2013-03-31 13:25:26 +0000
@@ -17,22 +17,26 @@
17 iter != m.end();17 iter != m.end();
18 iter++){18 iter++){
19 if((*iter)->equals(*marking)){19 if((*iter)->equals(*marking)){
20 if(!(*iter)->passed){20 if(isLiveness){
21 waiting_list->Add(*iter);21 marking->meta = (*iter)->meta;
22 return true;22 if(!marking->meta->passed){
23 }23 (*iter)->SetGeneratedBy(marking->GetGeneratedBy());
24 return false;24 waiting_list->Add(*iter, *iter);
25 return true;
26 }
27 }
28 return false;
25 }29 }
26 }30 }
27 stored++;31 stored++;
28 m.push_back(marking);32 m.push_back(marking);
29 waiting_list->Add(marking);33 marking->meta = new MetaData();
34 waiting_list->Add(marking, marking);
30 return true;35 return true;
31}36}
3237
33NonStrictMarking* PWList::GetNextUnexplored(){38NonStrictMarking* PWList::GetNextUnexplored(){
34 // TODO: Is this really it?39 return waiting_list->Pop();
35 return waiting_list->Next();
36}40}
3741
38PWList::~PWList() {42PWList::~PWList() {
@@ -50,5 +54,70 @@
50 return out;54 return out;
51}55}
5256
57 bool PWListHybrid::Add(NonStrictMarking* marking) {
58
59 discoveredMarkings++;
60 // reset the encoding array
61
62 PData<MetaData>::Result res = passed->Add(marking);
63 if(res.isNew){
64 if(isLiveness){
65 MetaData* meta;
66 if(this->makeTrace){
67 meta = new MetaDataWithTrace();
68 ((MetaDataWithTrace*)meta)->generatedBy = marking->generatedBy;
69 } else {
70 meta = new MetaData();
71 }
72 res.encoding.SetMetaData(meta);
73 marking->meta = meta;
74 } else if(this->makeTrace){
75 MetaDataWithTraceAndEncoding* meta = new MetaDataWithTraceAndEncoding();
76 meta->generatedBy = marking->generatedBy;
77 res.encoding.SetMetaData(meta);
78 meta->ep = new EncodingPointer<MetaData > (res.encoding, res.pos);
79 meta->parent = parent;
80 }
81 this->waiting_list->Add(marking, new EncodingPointer<MetaData > (res.encoding, res.pos));
82 } else{
83 if(isLiveness){
84 marking->meta = res.encoding.GetMetaData();
85 if(this->makeTrace){
86 ((MetaDataWithTrace*)marking->meta)->generatedBy = marking->generatedBy;
87 }
88 }
89 if(isLiveness && !marking->meta->passed){
90 this->waiting_list->Add(marking, new EncodingPointer<MetaData > (res.encoding, res.pos));
91 return true;
92 }
93 }
94 return res.isNew;
95 }
96
97 NonStrictMarking* PWListHybrid::GetNextUnexplored() {
98 // TODO: Is this really it?
99 EncodingPointer<MetaData>* p = waiting_list->Pop();
100 NonStrictMarkingBase* base = passed->EnumerateDecode(*p);
101 NonStrictMarking* m = new NonStrictMarking(*base);
102 delete base;
103
104 m->meta = p->encoding.GetMetaData();
105
106 if(this->makeTrace){
107 if(isLiveness){
108 m->generatedBy = ((MetaDataWithTrace*)(m->meta))->generatedBy;
109 } else {
110 this->parent = (MetaDataWithTraceAndEncoding*)(m->meta);
111 }
112 }
113 if(isLiveness || !this->makeTrace)
114 p->encoding.Release();
115 return m;
116 }
117
118 PWListHybrid::~PWListHybrid() {
119 // TODO Auto-generated destructor stub
120 }
121
53} /* namespace DiscreteVerification */122} /* namespace DiscreteVerification */
54} /* namespace VerifyTAPN */123} /* namespace VerifyTAPN */
55124
=== modified file 'src/DiscreteVerification/DataStructures/PWList.hpp' (properties changed: +x to -x)
--- src/DiscreteVerification/DataStructures/PWList.hpp 2012-11-24 11:35:27 +0000
+++ src/DiscreteVerification/DataStructures/PWList.hpp 2013-03-31 13:25:26 +0000
@@ -17,13 +17,31 @@
1717
18namespace VerifyTAPN {18namespace VerifyTAPN {
19namespace DiscreteVerification {19namespace DiscreteVerification {
20class PWList {20
21 class PWListBase {
22 public:
23 PWListBase() : stored(0), discoveredMarkings(0), maxNumTokensInAnyMarking(-1), isLiveness(false) {};
24 PWListBase(bool isLiveness) : stored(0), discoveredMarkings(0), maxNumTokensInAnyMarking(-1), isLiveness(isLiveness){};
25 int stored;
26 int discoveredMarkings;
27 int maxNumTokensInAnyMarking;
28 bool isLiveness;
29
30 virtual bool HasWaitingStates() = 0;
31 virtual long long Size() const = 0;
32 virtual bool Add(NonStrictMarking* marking) = 0;
33 virtual NonStrictMarking* GetNextUnexplored() = 0;
34 virtual long long Explored()= 0;
35 inline void SetMaxNumTokensIfGreater(int i){ if(i>maxNumTokensInAnyMarking) maxNumTokensInAnyMarking = i; };
36 };
37
38class PWList : public PWListBase {
21public:39public:
22 typedef std::vector<NonStrictMarking*> NonStrictMarkingList;40 typedef std::vector<NonStrictMarking*> NonStrictMarkingList;
23 typedef google::sparse_hash_map<size_t, NonStrictMarkingList> HashMap;41 typedef google::sparse_hash_map<size_t, NonStrictMarkingList> HashMap;
24public:42public:
25 PWList() : markings_storage(256000), waiting_list(), discoveredMarkings(0), maxNumTokensInAnyMarking(-1), stored(0) {};43 PWList() : PWListBase(false), markings_storage(256000), waiting_list(){};
26 PWList(WaitingList* w_l) : markings_storage(256000), waiting_list(w_l), discoveredMarkings(0), maxNumTokensInAnyMarking(-1), stored(0) {};44 PWList(WaitingList<NonStrictMarking>* w_l, bool isLiveness) :PWListBase(isLiveness), markings_storage(256000), waiting_list(w_l) {};
27 virtual ~PWList();45 virtual ~PWList();
28 friend std::ostream& operator<<(std::ostream& out, PWList& x);46 friend std::ostream& operator<<(std::ostream& out, PWList& x);
2947
@@ -36,18 +54,65 @@
36 return stored;54 return stored;
37 };55 };
3856
57 virtual long long Explored() {return waiting_list->Size();};
58
39public: // modifiers59public: // modifiers
40 virtual bool Add(NonStrictMarking* marking);60 virtual bool Add(NonStrictMarking* marking);
41 virtual NonStrictMarking* GetNextUnexplored();61 virtual NonStrictMarking* GetNextUnexplored();
42 inline void SetMaxNumTokensIfGreater(int i){ if(i>maxNumTokensInAnyMarking) maxNumTokensInAnyMarking = i; };
4362
44public:63public:
45 HashMap markings_storage;64 HashMap markings_storage;
46 WaitingList* waiting_list;65 WaitingList<NonStrictMarking>* waiting_list;
47 int discoveredMarkings;66};
48 int maxNumTokensInAnyMarking;67
49private:68class PWListHybrid : public PWListBase {
50 unsigned int stored;69 public:
70 typedef unsigned int uint;
71 // typedef google::sparse_hash_map<size_t, EncodingList> HashMap;
72 PData<MetaData>* passed;
73
74 public:
75
76 PWListHybrid(boost::shared_ptr<TAPN::TimedArcPetriNet>& tapn, WaitingList<EncodingPointer<MetaData> >* w_l, int knumber, int nplaces, int mage, bool isLiveness, bool makeTrace) :
77 PWListBase(isLiveness),
78 waiting_list(w_l),
79 makeTrace(makeTrace) {
80 discoveredMarkings = 0;
81 passed = new PData<MetaData>(tapn, knumber,nplaces,mage);
82 parent = NULL;
83 };
84 virtual ~PWListHybrid();
85 friend std::ostream& operator<<(std::ostream& out, PWListHybrid& x);
86
87 public: // inspectors
88 NonStrictMarking* Decode(EncodingPointer<MetaData>* ep){
89 NonStrictMarkingBase* base = this->passed->EnumerateDecode(*ep);
90 NonStrictMarking* m = new NonStrictMarking(*base);
91 delete base;
92 return m;
93 };
94 virtual bool HasWaitingStates() {
95 return (waiting_list->Size() > 0);
96 };
97
98 virtual long long Size() const {
99 return passed->stored;
100 };
101 virtual long long Explored() {return waiting_list->Size();};
102 void PrintMemStats() {
103 passed->PrintMemStats();
104 }
105
106 public: // modifiers
107 virtual bool Add(NonStrictMarking* marking);
108 virtual NonStrictMarking* GetNextUnexplored();
109
110 public:
111
112 WaitingList<EncodingPointer<MetaData> >* waiting_list;
113 bool makeTrace;
114 //ugly tracefix
115 MetaDataWithTraceAndEncoding* parent;
51};116};
52117
53std::ostream& operator<<(std::ostream& out, PWList& x);118std::ostream& operator<<(std::ostream& out, PWList& x);
54119
=== added file 'src/DiscreteVerification/DataStructures/TimeDart.hpp'
--- src/DiscreteVerification/DataStructures/TimeDart.hpp 1970-01-01 00:00:00 +0000
+++ src/DiscreteVerification/DataStructures/TimeDart.hpp 2013-03-31 13:25:26 +0000
@@ -0,0 +1,128 @@
1/*
2 * TimeDart.hpp
3 *
4 * Created on: 18/09/2012
5 * Author: MathiasGS
6 */
7
8#ifndef TIMEDART_HPP_
9#define TIMEDART_HPP_
10
11#include "NonStrictMarking.hpp"
12#include "PData.h"
13
14namespace VerifyTAPN {
15namespace DiscreteVerification {
16
17struct WaitingDart;
18struct TraceDart;
19class TimeDartBase;
20
21typedef EncodingPointer<TimeDartBase> TimeDartEncodingPointer; // used for memory-optimization for reachability
22typedef EncodingPointer<WaitingDart> WaitingDartEncodingPointer; // mem-optimization for liveness
23
24
25typedef vector<WaitingDart*> TraceMetaDataList;
26
27class TimeDartBase {
28public:
29 TimeDartBase(NonStrictMarkingBase* base, int waiting, int passed)
30 : base(base), waiting(waiting), passed(passed){
31 }
32 ~TimeDartBase(){
33 }
34
35 //Getters
36 inline NonStrictMarkingBase* getBase(){ return base; }
37 inline void setBase(NonStrictMarkingBase* newbase) { base = newbase;}
38 inline int getWaiting(){ return waiting; }
39 inline int getPassed(){ return passed; }
40
41 //Getters
42 inline void setWaiting(int w){ waiting = w; }
43 inline void setPassed(int p){ passed = p; }
44
45private:
46 NonStrictMarkingBase* base;
47 int waiting;
48 int passed;
49};
50
51
52class ReachabilityTraceableDart : public TimeDartBase {
53public:
54 ReachabilityTraceableDart(NonStrictMarkingBase* base, int waiting, int passed)
55 : TimeDartBase(base, waiting, passed), trace(NULL){
56 }
57 TraceDart* trace;
58};
59
60class EncodedReachabilityTraceableDart : public ReachabilityTraceableDart {
61public:
62 EncodedReachabilityTraceableDart(NonStrictMarkingBase* base, int waiting, int passed)
63 : ReachabilityTraceableDart(base, waiting, passed) {
64
65
66 }
67 TimeDartEncodingPointer* encoding;
68};
69
70class LivenessDart : public TimeDartBase {
71public:
72 LivenessDart(NonStrictMarkingBase* base, int waiting, int passed)
73 : TimeDartBase(base, waiting, passed), traceData(NULL){
74 }
75 TraceMetaDataList* traceData;
76};
77
78class EncodedLivenessDart : public LivenessDart {
79public:
80 EncodedLivenessDart(NonStrictMarkingBase* base, int waiting, int passed)
81 : LivenessDart(base, waiting, passed) {
82
83 }
84 WaitingDartEncodingPointer* encoding;
85};
86
87struct WaitingDart{
88 TimeDartBase* dart;
89 WaitingDart* parent;
90 int w;
91 int upper;
92
93 WaitingDart(TimeDartBase* dart, WaitingDart* parent, int w, int upper) : dart(dart), parent(parent), w(w), upper(upper){
94
95 }
96
97 ~WaitingDart(){
98
99 if(parent != NULL && ((LivenessDart*)parent->dart)->traceData != NULL){
100 for(TraceMetaDataList::iterator iter = ((LivenessDart*)parent->dart)->traceData->begin(); iter != ((LivenessDart*)parent->dart)->traceData->end(); iter++){
101 if((*iter) == this){
102 ((LivenessDart*)parent->dart)->traceData->erase(iter);
103 break;
104 }
105 }
106 if(((LivenessDart*)parent->dart)->traceData->empty()){
107 delete ((LivenessDart*)parent->dart)->traceData;
108 ((LivenessDart*)parent->dart)->traceData = NULL;
109 }
110 }
111 }
112};
113
114struct TraceDart : WaitingDart {
115 const TAPN::TimedTransition* generatedBy;
116 const int start;
117 TraceDart(TraceDart &t) : WaitingDart(t.dart, t.parent, t.w, t.upper), generatedBy(t.generatedBy), start(t.start){
118
119 };
120 TraceDart(TimeDartBase* dart, WaitingDart* parent, int w, int start, int upper, const TAPN::TimedTransition* GeneratedBy) : WaitingDart(dart, parent, w, upper), generatedBy(GeneratedBy), start(start){
121
122 }
123
124};
125}
126}
127
128#endif /* TIMEDART_HPP_ */
0129
=== added file 'src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.cpp'
--- src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.cpp 1970-01-01 00:00:00 +0000
+++ src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.cpp 2013-03-31 13:25:26 +0000
@@ -0,0 +1,164 @@
1/*
2 * PWList.cpp
3 *
4 * Created on: 01/03/2012
5 * Author: MathiasGS
6 */
7
8#include "TimeDartLivenessPWList.hpp"
9
10namespace VerifyTAPN {
11 namespace DiscreteVerification {
12
13 std::pair<LivenessDart*, bool> TimeDartLivenessPWHashMap::Add(TAPN::TimedArcPetriNet* tapn, NonStrictMarkingBase* marking, int youngest, WaitingDart* parent, int upper, int start) {
14 discoveredMarkings++;
15 TimeDartList& m = markings_storage[marking->HashKey()];
16 for (TimeDartList::const_iterator iter = m.begin();
17 iter != m.end();
18 iter++) {
19 if ((*iter)->getBase()->equals(*marking)) {
20 std::pair < LivenessDart*, bool> result(*iter, false);
21 (*iter)->setWaiting(min((*iter)->getWaiting(), youngest));
22
23 if ((*iter)->getWaiting() < (*iter)->getPassed()) {
24 if(options.GetTrace()){
25 waiting_list->Add((*iter)->getBase(), new TraceDart((*iter), parent, youngest, start, upper, marking->generatedBy));
26
27 } else {
28 waiting_list->Add((*iter)->getBase(), new WaitingDart((*iter), parent, youngest, upper));
29 }
30 result.second = true;
31 delete marking;
32 }
33
34 return result;
35 }
36 }
37 stored++;
38 LivenessDart* dart = new LivenessDart(marking, youngest, INT_MAX);
39 m.push_back(dart);
40 if(options.GetTrace()){
41
42 waiting_list->Add(dart->getBase(), new TraceDart(dart, parent, youngest, start, upper, marking->generatedBy));
43
44 } else {
45 waiting_list->Add(dart->getBase(), new WaitingDart(dart, parent, youngest, upper));
46 }
47 std::pair < LivenessDart*, bool> result(dart, true);
48 return result;
49 }
50
51 WaitingDart* TimeDartLivenessPWHashMap::GetNextUnexplored() {
52 return waiting_list->Peek();
53 }
54
55 void TimeDartLivenessPWHashMap::PopWaiting() {
56 delete waiting_list->Pop();
57 }
58
59 void TimeDartLivenessPWHashMap::flushBuffer() {
60 // Flush buffer if w has changed
61 waiting_list->flushBuffer();
62 }
63
64 std::pair<LivenessDart*, bool> TimeDartLivenessPWPData::Add(TAPN::TimedArcPetriNet* tapn, NonStrictMarkingBase* marking, int youngest, WaitingDart* parent, int upper, int start) {
65
66
67 discoveredMarkings++;
68 PData<LivenessDart>::Result res = passed.Add(marking);
69
70 if (!res.isNew) {
71 LivenessDart* td = res.encoding.GetMetaData();
72 td->setBase(marking);
73 std::pair < LivenessDart*, bool> result(td, false);
74 td->setWaiting(min(td->getWaiting(), youngest));
75
76 if (td->getWaiting() < td->getPassed()) {
77 EncodingStructure<WaitingDart*> es(res.encoding.GetRaw(), res.encoding.Size());
78
79 EncodingPointer<WaitingDart>* ewp = new EncodingPointer<WaitingDart > (es, res.pos);
80 WaitingDart *wd;
81 if(options.GetTrace()){
82 wd = new TraceDart(td, parent, youngest, start, upper, marking->generatedBy);
83
84 } else {
85 wd = new WaitingDart(td, parent, youngest, upper);
86 }
87 ewp->encoding.SetMetaData(wd);
88
89 waiting_list->Add(marking, ewp);
90 result.second = true;
91 } else {
92 if(options.GetTrace() == SOME){
93 EncodingStructure<WaitingDart*> es(res.encoding.GetRaw(), res.encoding.Size());
94 ((EncodedLivenessDart*)td)->encoding = new EncodingPointer<WaitingDart > (es, res.pos);
95 result.first = td;
96 }
97 }
98 return result;
99 }
100
101 stored++;
102 LivenessDart* dart;
103 if(options.GetTrace()){
104 dart= new EncodedLivenessDart(marking, youngest, INT_MAX);
105 } else {
106 dart = new LivenessDart(marking, youngest, INT_MAX);
107 }
108 res.encoding.SetMetaData(dart);
109
110 EncodingStructure<WaitingDart*> es(res.encoding.GetRaw(), res.encoding.Size());
111 EncodingPointer<WaitingDart>* ewp = new EncodingPointer<WaitingDart > (es, res.pos);
112
113 WaitingDart *wd;
114 if(options.GetTrace()){
115 wd = new TraceDart(dart, parent, youngest, start, upper, marking->generatedBy);
116 ((EncodedLivenessDart*)dart)->encoding = ewp;
117 } else {
118 wd = new WaitingDart(dart, parent, youngest, upper);
119 }
120 ewp->encoding.SetMetaData(wd);
121
122 waiting_list->Add(marking, ewp);
123 std::pair < LivenessDart*, bool> result(dart, true);
124 return result;
125 }
126
127 WaitingDart* TimeDartLivenessPWPData::GetNextUnexplored() {
128 EncodingPointer<WaitingDart>* ewp = waiting_list->Peek();
129 WaitingDart* wd = ewp->encoding.GetMetaData();
130 NonStrictMarkingBase* base = passed.EnumerateDecode(*((EncodingPointer<LivenessDart>*)ewp));
131 wd->dart->setBase(base);
132 if(options.GetTrace() == SOME){
133 ((EncodedLivenessDart*)wd->dart)->encoding = ewp;
134 }
135 return wd;
136 }
137
138 void TimeDartLivenessPWPData::PopWaiting() {
139 EncodingPointer<WaitingDart>* ewp = waiting_list->Pop();
140 WaitingDart* wd = ewp->encoding.GetMetaData();
141 delete wd->dart->getBase();
142 delete wd;
143 ewp->encoding.Release();
144 delete ewp;
145 }
146
147 void TimeDartLivenessPWPData::flushBuffer() {
148 // Flush buffer if w has changed
149 waiting_list->flushBuffer();
150 }
151
152 std::ostream& operator<<(std::ostream& out, TimeDartLivenessPWHashMap& x) {
153 out << "Passed and waiting:" << std::endl;
154 for (TimeDartLivenessPWHashMap::HashMap::iterator iter = x.markings_storage.begin(); iter != x.markings_storage.end(); iter++) {
155 for (TimeDartLivenessPWHashMap::TimeDartList::iterator m_iter = iter->second.begin(); m_iter != iter->second.end(); m_iter++) {
156 out << "- " << *m_iter << std::endl;
157 }
158 }
159 out << "Waiting:" << std::endl << x.waiting_list;
160 return out;
161 }
162
163 } /* namespace DiscreteVerification */
164} /* namespace VerifyTAPN */
0165
=== added file 'src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.hpp'
--- src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.hpp 1970-01-01 00:00:00 +0000
+++ src/DiscreteVerification/DataStructures/TimeDartLivenessPWList.hpp 2013-03-31 13:25:26 +0000
@@ -0,0 +1,118 @@
1/*
2 * PWList.hpp
3 *
4 * Created on: 01/03/2012
5 * Author: MathiasGS
6 */
7
8#ifndef TimeDartLivenessPWList_HPP_
9#define TimeDartLivenessPWList_HPP_
10
11#include "WaitingList.hpp"
12#include <iostream>
13#include "google/sparse_hash_map"
14#include "NonStrictMarkingBase.hpp"
15#include "WaitingList.hpp"
16#include "TimeDart.hpp"
17#include "PData.h"
18
19namespace VerifyTAPN {
20 namespace DiscreteVerification {
21 class TimeDartLivenessPWBase;
22 class TimeDartLivenessPWHashMap;
23 // class TimeDartPWPData;
24
25 class TimeDartLivenessPWBase {
26 public:
27 typedef std::vector<LivenessDart*> TimeDartList;
28 typedef google::sparse_hash_map<size_t, TimeDartList> HashMap;
29
30 public:
31
32 TimeDartLivenessPWBase() : discoveredMarkings(0), maxNumTokensInAnyMarking(-1), stored(0) {
33 };
34
35 virtual ~TimeDartLivenessPWBase() {
36 };
37
38
39 public: // inspectors
40 virtual bool HasWaitingStates() = 0;
41
42 virtual long long Size() const {
43 return stored;
44 };
45
46 public: // modifiers
47 virtual std::pair<LivenessDart*, bool> Add(TAPN::TimedArcPetriNet* tapn, NonStrictMarkingBase* base, int youngest, WaitingDart* parent, int upper, int start) = 0;
48 virtual WaitingDart* GetNextUnexplored() = 0;
49 virtual void PopWaiting() = 0;
50 virtual void flushBuffer() = 0;
51
52 inline void SetMaxNumTokensIfGreater(int i) {
53 if (i > maxNumTokensInAnyMarking) maxNumTokensInAnyMarking = i;
54 };
55
56 public:
57 int discoveredMarkings;
58 int maxNumTokensInAnyMarking;
59 long long stored;
60 };
61
62 class TimeDartLivenessPWHashMap : public TimeDartLivenessPWBase {
63 public:
64
65 TimeDartLivenessPWHashMap() : markings_storage(), waiting_list(){};
66
67 TimeDartLivenessPWHashMap(VerificationOptions options, WaitingList<WaitingDart>* w_l) : TimeDartLivenessPWBase(), options(options), markings_storage(256000), waiting_list(w_l) {
68 };
69
70 ~TimeDartLivenessPWHashMap() {
71 };
72 friend std::ostream& operator<<(std::ostream& out, TimeDartLivenessPWHashMap& x);
73 virtual std::pair<LivenessDart*, bool> Add(TAPN::TimedArcPetriNet* tapn, NonStrictMarkingBase* base, int youngest, WaitingDart* parent, int upper, int start);
74 virtual WaitingDart* GetNextUnexplored();
75 virtual void PopWaiting();
76
77 virtual bool HasWaitingStates() {
78 return (waiting_list->Size() > 0);
79 };
80 virtual void flushBuffer();
81 private:
82 VerificationOptions options;
83 HashMap markings_storage;
84 WaitingList<WaitingDart>* waiting_list;
85 };
86
87 class TimeDartLivenessPWPData : public TimeDartLivenessPWBase {
88 public:
89
90
91
92 TimeDartLivenessPWPData(VerificationOptions options, WaitingList<EncodingPointer<WaitingDart> >* w_l, boost::shared_ptr<TAPN::TimedArcPetriNet>& tapn, int nplaces, int mage) : TimeDartLivenessPWBase(), options(options), waiting_list(w_l), passed(tapn, options.GetKBound(), nplaces, mage) {
93 };
94
95 ~TimeDartLivenessPWPData() {
96 };
97 friend std::ostream& operator<<(std::ostream& out, TimeDartLivenessPWHashMap& x);
98 virtual std::pair<LivenessDart*, bool> Add(TAPN::TimedArcPetriNet* tapn, NonStrictMarkingBase* base, int youngest, WaitingDart* parent, int upper, int start);
99 virtual WaitingDart* GetNextUnexplored();
100 virtual void PopWaiting();
101
102 virtual bool HasWaitingStates() {
103 return (waiting_list->Size() > 0);
104 };
105 virtual void flushBuffer();
106 NonStrictMarkingBase* Decode(EncodingPointer<LivenessDart> *ewp){
107 return passed.EnumerateDecode(*ewp);
108 }
109
110 private:
111 VerificationOptions options;
112 WaitingList<EncodingPointer<WaitingDart> >* waiting_list;
113 PData<LivenessDart> passed;
114 };
115
116 } /* namespace DiscreteVerification */
117} /* namespace VerifyTAPN */
118#endif /* PWLIST_HPP_ */
0119
=== added file 'src/DiscreteVerification/DataStructures/TimeDartPWList.cpp'
--- src/DiscreteVerification/DataStructures/TimeDartPWList.cpp 1970-01-01 00:00:00 +0000
+++ src/DiscreteVerification/DataStructures/TimeDartPWList.cpp 2013-03-31 13:25:26 +0000
@@ -0,0 +1,126 @@
1/*
2 * PWList.cpp
3 *
4 * Created on: 01/03/2012
5 * Author: MathiasGS
6 */
7
8#include "TimeDartPWList.hpp"
9
10namespace VerifyTAPN {
11namespace DiscreteVerification {
12
13bool TimeDartPWHashMap::Add(TAPN::TimedArcPetriNet* tapn, NonStrictMarkingBase* marking, int youngest, WaitingDart* parent, int upper, int start){
14 discoveredMarkings++;
15 TimeDartList& m = markings_storage[marking->HashKey()];
16 for(TimeDartList::const_iterator iter = m.begin();
17 iter != m.end();
18 iter++){
19 if((*iter)->getBase()->equals(*marking)){
20 bool inWaiting = (*iter)->getWaiting() < (*iter)->getPassed();
21
22 (*iter)->setWaiting(min((*iter)->getWaiting(),youngest));
23
24 if((*iter)->getWaiting() < (*iter)->getPassed() && !inWaiting){
25 waiting_list->Add((*iter)->getBase(),(*iter));
26 if(this->trace){
27 ((ReachabilityTraceableDart*)(*iter))->trace = new TraceDart((*iter), parent, youngest, start, upper, marking->generatedBy);
28 this->last = ((ReachabilityTraceableDart*)(*iter))->trace;
29 }
30 }
31
32 delete marking;
33
34 return false;
35 }
36 }
37 TimeDartBase* dart;
38 if(this->trace){
39 dart = new ReachabilityTraceableDart(marking, youngest, INT_MAX);
40 ((ReachabilityTraceableDart*)dart)->trace = new TraceDart(dart, parent, youngest, start, upper, marking->generatedBy);
41 this->last = ((ReachabilityTraceableDart*)(dart))->trace;
42 } else {
43 dart = new TimeDartBase(marking, youngest, INT_MAX);
44 }
45 stored++;
46 m.push_back(dart);
47
48 waiting_list->Add(dart->getBase(), dart);
49 return true;
50}
51
52TimeDartBase* TimeDartPWHashMap::GetNextUnexplored(){
53 return waiting_list->Pop();
54}
55
56bool TimeDartPWPData::Add(TAPN::TimedArcPetriNet* tapn, NonStrictMarkingBase* marking, int youngest, WaitingDart* parent, int upper, int start){
57 discoveredMarkings++;
58 PData<TimeDartBase>::Result res = passed.Add(marking);
59
60 if(!res.isNew){
61 TimeDartBase* t = res.encoding.GetMetaData();
62 bool inWaiting = t->getWaiting() < t->getPassed();
63 t->setWaiting(min(t->getWaiting(),youngest));
64
65 if(t->getWaiting() < t->getPassed() && !inWaiting){
66 if(this->trace){
67 ((EncodedReachabilityTraceableDart*)t)->trace = new TraceDart(t, parent, youngest, start, upper, marking->generatedBy);
68 this->last = ((EncodedReachabilityTraceableDart*)t)->trace;
69 }
70 waiting_list->Add(marking, new EncodingPointer<TimeDartBase>(res.encoding, res.pos));
71 // waiting_list->Add(t->getBase(), t);
72 }
73 return false;
74 }
75
76
77 TimeDartBase* dart;
78 if (this->trace) {
79 dart = new EncodedReachabilityTraceableDart(marking, youngest, INT_MAX);
80 ((EncodedReachabilityTraceableDart*) dart)->trace = new TraceDart(dart, parent, youngest, start, upper, marking->generatedBy);
81 this->last = ((ReachabilityTraceableDart*) (dart))->trace;
82 } else {
83 dart = new TimeDartBase(marking, youngest, INT_MAX);
84 }
85 stored++;
86 res.encoding.SetMetaData(dart);
87 EncodingPointer<TimeDartBase>* ep = new EncodingPointer<TimeDartBase>(res.encoding, res.pos);
88 waiting_list->Add(marking, ep);
89 if (this->trace) {
90 // if trace, create new (persistent) encodingpointer as regular one gets deleted every time we pop from waiting.
91 ((EncodedReachabilityTraceableDart*) dart)->encoding = new EncodingPointer<TimeDartBase>(res.encoding, res.pos);
92 }
93// waiting_list->Add(dart->getBase(), dart);
94 return true;
95}
96
97TimeDartBase* TimeDartPWPData::GetNextUnexplored(){
98
99 EncodingPointer<TimeDartBase>* p = waiting_list->Pop();
100 NonStrictMarkingBase* m = passed.EnumerateDecode(*p);
101 TimeDartBase* dart = p->encoding.GetMetaData();
102 dart->setBase(m);
103
104 p->encoding.Release();
105 delete p;
106 return dart;
107}
108
109
110TimeDartPWHashMap::~TimeDartPWHashMap() {
111 // TODO Auto-generated destructor stub
112}
113
114std::ostream& operator<<(std::ostream& out, TimeDartPWHashMap& x){
115 out << "Passed and waiting:" << std::endl;
116 for(TimeDartPWHashMap::HashMap::iterator iter = x.markings_storage.begin(); iter != x.markings_storage.end(); iter++){
117 for(TimeDartPWHashMap::TimeDartList::iterator m_iter = iter->second.begin(); m_iter != iter->second.end(); m_iter++){
118 out << "- "<< *m_iter << std::endl;
119 }
120 }
121 out << "Waiting:" << std::endl << x.waiting_list;
122 return out;
123}
124
125} /* namespace DiscreteVerification */
126} /* namespace VerifyTAPN */
0127
=== added file 'src/DiscreteVerification/DataStructures/TimeDartPWList.hpp'
--- src/DiscreteVerification/DataStructures/TimeDartPWList.hpp 1970-01-01 00:00:00 +0000
+++ src/DiscreteVerification/DataStructures/TimeDartPWList.hpp 2013-03-31 13:25:26 +0000
@@ -0,0 +1,112 @@
1/*
2 * PWList.hpp
3 *
4 * Created on: 01/03/2012
5 * Author: MathiasGS
6 */
7
8#ifndef TIMEDARTPWLIST_HPP_
9#define TIMEDARTPWLIST_HPP_
10
11#include "WaitingList.hpp"
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches