11 #include "utilities.hh" 38 const static char OPT_EPSILON;
59 case type_stack_operation::PUSH:
62 case type_stack_operation::POP:
90 case type_synchronization::FORK:
93 case type_synchronization::BRCT:
109 src(src), dst(dst), op(op) {
138 template<
typename T1,
typename T2>
inline ostream&
operator<<(ostream& os,
140 os << r.get_src() <<
" ";
142 os <<
" " << r.get_dst();
194 os << alphabet::OPT_EPSILON;
257 inline sstack(
const deque<T>& worklist) :
265 return worklist.front();
269 if (worklist.empty())
271 return worklist.front();
274 void push(
const T& _value) {
275 worklist.emplace_front(_value);
278 size_t size()
const {
279 return worklist.size();
283 if (worklist.empty())
285 worklist.pop_front();
289 bool overwrite(
const T& _value) {
290 if (worklist.empty())
292 worklist[0] = _value;
297 return worklist.empty();
300 const deque<T>& get_worklist()
const {
317 os << alphabet::OPT_EPSILON;
319 for (
const T& s : a.get_worklist()) {
320 if (s == alphabet::EPSILON)
321 os << alphabet::OPT_EPSILON;
335 template<
typename T>
inline bool operator<(const sstack<T>& a1,
337 if (a1.get_worklist().size() == a2.get_worklist().size()) {
338 auto ia1 = a1.get_worklist().cbegin();
339 auto ia2 = a2.get_worklist().cbegin();
340 while (ia1 != a1.get_worklist().cend()) {
343 }
else if (*ia1 > *ia2) {
351 return a1.get_worklist().size() < a2.get_worklist().size();
373 if (a1.get_worklist().size() != a2.get_worklist().size())
375 auto ia1 = a1.get_worklist().cbegin();
376 auto ia2 = a2.get_worklist().cbegin();
377 while (ia1 != a1.get_worklist().cend()) {
438 os <<
"(" << c.get_state() <<
"," << c.get_stack() <<
")";
449 if (c1.get_state() == c2.get_state())
450 return c1.get_stack() < c2.get_stack();
451 return c1.get_state() < c2.get_state();
471 return (c1.get_state() == c2.get_state())
472 && (c1.get_stack() == c2.get_stack());
491 using adj_list = map<thread_visible_state, deque<id_action>>;
501 const set<pda_alpha>& alphas,
502 const vector<pda_action>& actions,
503 const adj_list& program);
506 const set<pda_state>& get_states()
const {
510 const set<pda_alpha>& get_alphas()
const {
514 const vector<pda_action>& get_actions()
const {
518 const adj_list& get_program()
const {
523 set<pda_state> states;
524 set<pda_alpha> alphas;
525 vector<pda_action> actions;
536 for (
auto s : PDA.get_states()) {
540 for (
auto r : PDA.get_actions()) {
uint pda_alpha
define the stack symbol of PDSs
Definition: pda.hh:19
~thread_visible_state()
Definition: cpda.cc:34
customized runtime error class
Definition: excep.hh:24
~thread_state()
Definition: cpda.cc:82
uint id_action
Definition: pda.hh:490
bool operator>(const visible_state &s1, const visible_state &s2)
Definition: cpda.hh:108
bool operator==(const visible_state &s1, const visible_state &s2)
Definition: cpda.hh:118
pda_alpha get_alpha() const
Definition: pda.hh:169
pushdown_automaton()
Definition: pda.cc:19
bool operator!=(const visible_state &s1, const visible_state &s2)
Definition: cpda.hh:131
thread_state()
Definition: cpda.cc:40
pda_state get_state() const
Definition: pda.hh:176
ostream & operator<<(ostream &os, const visible_state &s)
Definition: cpda.hh:70
uint pda_state
define the control state of PDSs
Definition: pda.hh:17
bool operator<(const visible_state &s1, const visible_state &s2)
Definition: cpda.hh:95
type_synchronization
Definition: pda.hh:78
type_stack_operation
Definition: pda.hh:47
~pushdown_automaton()
Definition: pda.cc:41
thread_visible_state()
Definition: cpda.cc:17