Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
DotConverter.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <ext/ostream>
9#include <ext/sstream>
10
11#include <ext/utility>
12#include <ext/typeinfo>
13
14#include <alib/set>
15#include <alib/map>
16#include <alib/list>
17#include <alib/vector>
18
20#include <string/String.h>
21
22#include <automaton/FSM/NFA.h>
25#include <automaton/FSM/DFA.h>
28#include <automaton/TA/NFTA.h>
32#include <automaton/TA/DFTA.h>
35#include <automaton/PDA/NPDA.h>
43#include <automaton/PDA/DPDA.h>
46
48
52
55
56namespace convert {
57
59 static constexpr const size_t CAPTION_LENGTH_LIMIT = 100;
60
61 template < class SymbolType, class StateType >
62 static void transitions(const automaton::DFA < SymbolType, StateType > & fsm, const ext::map < StateType, int > & states, ext::ostream & out);
63
64 template < class SymbolType, class StateType >
65 static void transitions(const automaton::NFA < SymbolType, StateType > & fsm, const ext::map < StateType, int > & states, ext::ostream & out);
66
67 template < class SymbolType, class StateType >
68 static void transitions(const automaton::MultiInitialStateNFA < SymbolType, StateType > & fsm, const ext::map < StateType, int > & states, ext::ostream & out);
69
70 template < class SymbolType, class StateType >
71 static void transitions(const automaton::EpsilonNFA < SymbolType, StateType > & fsm, const ext::map < StateType, int > & states, ext::ostream & out);
72
73 template < class SymbolType, class StateType >
74 static void transitions(const automaton::ExtendedNFA < SymbolType, StateType > & fsm, const ext::map < StateType, int > & states, ext::ostream & out);
75
76 template < class SymbolType, class StateType >
77 static void transitions(const automaton::CompactNFA < SymbolType, StateType > & fsm, const ext::map < StateType, int > & states, ext::ostream & out);
78
79 template < class SymbolType, class StateType >
80 static void transitions(const automaton::NFTA < SymbolType, StateType > & fta, const ext::map < StateType, int > & states, ext::ostream & out);
81
82 template < class SymbolType, class StateType >
83 static void transitions(const automaton::EpsilonNFTA < SymbolType, StateType > & fta, const ext::map < StateType, int > & states, ext::ostream & out);
84
85 template < class SymbolType, class StateType >
86 static void transitions(const automaton::UnorderedNFTA < SymbolType, StateType > & fta, const ext::map < StateType, int > & states, ext::ostream & out);
87
88 template < class SymbolType, class StateType >
89 static void transitions(const automaton::ExtendedNFTA < SymbolType, StateType > & fta, const ext::map < StateType, int > & states, ext::ostream & out);
90
91 template < class SymbolType, class StateType >
92 static void transitions(const automaton::DFTA < SymbolType, StateType > & fta, const ext::map < StateType, int > & states, ext::ostream & out);
93
94 template < class SymbolType, class StateType >
96
97 template < class SymbolType, class StateType >
99
100 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
102
103 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
105
106 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
108
109 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
111
112 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
114
115 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
117
118 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
120
121 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
123
124 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
126
127 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
129
130 template < class SymbolType, class StateType >
131 static void transitions(const automaton::OneTapeDTM < SymbolType, StateType > & tm, const ext::map < StateType, int > & states, ext::ostream & out);
132public:
133 template < class SymbolType, class StateType >
135
136 template < class SymbolType, class StateType >
138
139 template < class SymbolType, class StateType >
141
142 template < class SymbolType, class StateType >
144
145 template < class SymbolType, class StateType >
147
148 template < class SymbolType, class StateType >
150
151 template < class SymbolType, class StateType >
153
154 template < class SymbolType, class StateType >
156
157 template < class SymbolType, class StateType >
159
160 template < class SymbolType, class StateType >
162
163 template < class SymbolType, class StateType >
165
166 template < class SymbolType, class StateType >
168
169 template < class SymbolType, class StateType >
171
172 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
174
175 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
177
178 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
180
181 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
183
184 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
186
187 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
189
190 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
192
193 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
195
196 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
198
199 template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
201
202 template < class SymbolType, class StateType >
204
205 template < class SymbolType >
206 static void convert(ext::ostream& out, const rte::FormalRTE < SymbolType > & e );
207
208 template < class SymbolType >
209 static void convert(ext::ostream& out, const tree::RankedTree < SymbolType > & e );
210
211 template < class T >
212 static std::string convert ( const T & automaton ) {
214 convert ( ss, automaton );
215 return ss.str ( );
216 }
217};
218
219template < class SymbolType, class StateType >
221 out << "digraph automaton {\n";
222 out << "rankdir=LR;\n";
223 int cnt = 1;
224
225 //Map states to indices
227 for (const StateType& state : a.getStates()) {
228 states.insert(std::make_pair(state, cnt++));
229 }
230
231 //Print final states
232 for (const StateType& state : a.getFinalStates()) {
233 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
234 }
235
236 //Print nonfinal states
237 for (const auto& state : states) {
238 if (!a.getFinalStates().count(state.first)) {
239 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
240 }
241 }
242
243 //Mark initial states
244 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
245 out << "0 -> " << states.find(a.getInitialState())->second << ";\n";
246
247 transitions(a, states, out);
248 out << "}";
249}
250
251template < class SymbolType, class StateType >
253 out << "digraph automaton {\n";
254 out << "rankdir=LR;\n";
255 int cnt = 1;
256
257 //Map states to indices
259 for (const StateType& state : a.getStates()) {
260 states.insert(std::make_pair(state, cnt++));
261 }
262
263 //Print final states
264 for (const StateType& state : a.getFinalStates()) {
265 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
266 }
267
268 //Print nonfinal states
269 for (const auto& state : states) {
270 if (!a.getFinalStates().count(state.first)) {
271 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
272 }
273 }
274
275 //Mark initial states
276 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
277 for (const StateType& state : a.getInitialStates()) {
278 out << "0 -> " << states.find(state)->second << ";\n";
279 }
280
281 transitions(a, states, out);
282 out << "}";
283}
284
285template < class SymbolType, class StateType >
287 out << "digraph automaton {\n";
288 out << "rankdir=LR;\n";
289 int cnt = 1;
290
291 //Map states to indices
293 for (const StateType& state : a.getStates()) {
294 states.insert(std::make_pair(state, cnt++));
295 }
296
297 //Print final states
298 for (const StateType& state : a.getFinalStates()) {
299 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
300 }
301
302 //Print nonfinal states
303 for (const auto& state : states) {
304 if (!a.getFinalStates().count(state.first)) {
305 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
306 }
307 }
308
309 //Mark initial states
310 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
311 out << "0 -> " << states.find(a.getInitialState())->second << ";\n";
312
313 transitions(a, states, out);
314 out << "}";
315}
316
317template < class SymbolType, class StateType >
319 out << "digraph automaton {\n";
320 out << "rankdir=LR;\n";
321 int cnt = 1;
322
323 //Map states to indices
325 for (const StateType& state : a.getStates()) {
326 states.insert(std::make_pair(state, cnt++));
327 }
328
329 //Print final states
330 for (const StateType& state : a.getFinalStates()) {
331 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
332 }
333
334 //Print nonfinal states
335 for (const auto& state : states) {
336 if (!a.getFinalStates().count(state.first)) {
337 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
338 }
339 }
340
341 //Mark initial states
342 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
343 out << "0 -> " << states.find(a.getInitialState())->second << ";\n";
344
345 transitions(a, states, out);
346 out << "}";
347}
348
349template < class SymbolType, class StateType >
351 out << "digraph automaton {\n";
352 out << "rankdir=LR;\n";
353 int cnt = 1;
354
355 //Map states to indices
357 for (const StateType& state : a.getStates()) {
358 states.insert(std::make_pair(state, cnt++));
359 }
360
361 //Print final states
362 for (const StateType& state : a.getFinalStates()) {
363 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
364 }
365
366 //Print nonfinal states
367 for (const auto& state : states) {
368 if (!a.getFinalStates().count(state.first)) {
369 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
370 }
371 }
372
373 //Mark initial states
374 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
375 out << "0 -> " << states.find(a.getInitialState())->second << ";\n";
376
377 transitions(a, states, out);
378 out << "}";
379}
380
381template < class SymbolType, class StateType >
383 out << "digraph automaton {\n";
384 out << "rankdir=LR;\n";
385 int cnt = 1;
386
387 //Map states to indices
389 for (const StateType& state : a.getStates()) {
390 states.insert(std::make_pair(state, cnt++));
391 }
392
393 //Print final states
394 for (const StateType& state : a.getFinalStates()) {
395 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
396 }
397
398 //Print nonfinal states
399 for (const auto& state : states) {
400 if (!a.getFinalStates().count(state.first)) {
401 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
402 }
403 }
404
405 //Mark initial states
406 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
407 out << "0 -> " << states.find(a.getInitialState())->second << ";\n";
408
409 transitions(a, states, out);
410 out << "}";
411}
412
413template < class SymbolType, class StateType >
415 out << "digraph automaton {\n";
416 out << "rankdir=LR;\n";
417 int cnt = 1;
418
419 //Map states to indices
421 for (const StateType& state : a.getStates()) {
422 states.insert(std::make_pair(state, cnt++));
423 }
424
425 //Print final states
426 for (const StateType& state : a.getFinalStates()) {
427 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
428 }
429
430 //Print nonfinal states
431 for (const auto& state : states) {
432 if (!a.getFinalStates().count(state.first)) {
433 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
434 }
435 }
436
437 transitions(a, states, out);
438 out << "}";
439}
440
441template < class SymbolType, class StateType >
443 out << "digraph automaton {\n";
444 out << "rankdir=LR;\n";
445 int cnt = 1;
446
447 //Map states to indices
449 for (const StateType& state : a.getStates()) {
450 states.insert(std::make_pair(state, cnt++));
451 }
452
453 //Print final states
454 for (const StateType& state : a.getFinalStates()) {
455 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
456 }
457
458 //Print nonfinal states
459 for (const auto& state : states) {
460 if (!a.getFinalStates().count(state.first)) {
461 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
462 }
463 }
464
465 transitions(a, states, out);
466 out << "}";
467}
468
469template < class SymbolType, class StateType >
471 out << "digraph automaton {\n";
472 out << "rankdir=LR;\n";
473 int cnt = 1;
474
475 //Map states to indices
477 for (const StateType& state : a.getStates()) {
478 states.insert(std::make_pair(state, cnt++));
479 }
480
481 //Print final states
482 for (const StateType& state : a.getFinalStates()) {
483 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
484 }
485
486 //Print nonfinal states
487 for (const auto& state : states) {
488 if (!a.getFinalStates().count(state.first)) {
489 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
490 }
491 }
492
493 transitions(a, states, out);
494 out << "}";
495}
496
497template < class SymbolType, class StateType >
499 out << "digraph automaton {\n";
500 out << "rankdir=TD;\n";
501 int cnt = 1;
502
503 //Map states to indices
505 for (const StateType& state : a.getStates()) {
506 states.insert(std::make_pair(state, cnt++));
507 }
508
509 //Print final states
510 for (const StateType& state : a.getFinalStates()) {
511 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; State" << states.find(state)->second << ";\n";
512 }
513
514 //Print nonfinal states
515 for (const auto& state : states) {
516 if (!a.getFinalStates().count(state.first)) {
517 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; State" << state.second << ";\n";
518 }
519 }
520
521 transitions(a, states, out);
522 out << "}";
523}
524
525template < class SymbolType, class StateType >
527 out << "digraph automaton {\n";
528 out << "rankdir=LR;\n";
529 int cnt = 1;
530
531 //Map states to indices
533 for (const StateType& state : a.getStates()) {
534 states.insert(std::make_pair(state, cnt++));
535 }
536
537 //Print final states
538 for (const StateType& state : a.getFinalStates()) {
539 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
540 }
541
542 //Print nonfinal states
543 for (const auto& state : states) {
544 if (!a.getFinalStates().count(state.first)) {
545 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
546 }
547 }
548
549 transitions(a, states, out);
550 out << "}";
551}
552
553template < class SymbolType, class StateType >
555 out << "digraph automaton {\n";
556 out << "rankdir=LR;\n";
557 int cnt = 1;
558
559 //Map states to indices
561 for (const StateType& state : a.getStates()) {
562 states.insert(std::make_pair(state, cnt++));
563 }
564
565 //Print final states
566 for (const StateType& state : a.getFinalStates()) {
567 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
568 }
569
570 //Print nonfinal states
571 for (const auto& state : states) {
572 if (!a.getFinalStates().count(state.first)) {
573 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
574 }
575 }
576
577 transitions(a, states, out);
578 out << "}";
579}
580
581template < class SymbolType, class StateType >
583 out << "digraph automaton {\n";
584 out << "rankdir=LR;\n";
585 int cnt = 1;
586
587 //Map states to indices
589 for (const StateType& state : a.getStates()) {
590 states.insert(std::make_pair(state, cnt++));
591 }
592
593 //Print final states
594 for (const StateType& state : a.getFinalStates()) {
595 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
596 }
597
598 //Print nonfinal states
599 for (const auto& state : states) {
600 if (!a.getFinalStates().count(state.first)) {
601 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
602 }
603 }
604
605 transitions(a, states, out);
606 out << "}";
607}
608
609template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
611 out << "digraph automaton {\n";
612 out << "rankdir=LR;\n";
613 int cnt = 1;
614
615 //Map states to indices
617 for (const StateType& state : a.getStates()) {
618 states.insert(std::make_pair(state, cnt++));
619 }
620
621 //Print final states
622 for (const StateType& state : a.getFinalStates()) {
623 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
624 }
625
626 //Print nonfinal states
627 for (const auto& state : states) {
628 if (!a.getFinalStates().count(state.first)) {
629 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
630 }
631 }
632
633 //Mark initial states
634 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
635 out << "0 -> " << states.find(a.getInitialState())->second << ";\n";
636
637 transitions(a, states, out);
638 out << "}";
639}
640
641template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
643 out << "digraph automaton {\n";
644 out << "rankdir=LR;\n";
645 int cnt = 1;
646
647 //Map states to indices
649 for (const StateType& state : a.getStates()) {
650 states.insert(std::make_pair(state, cnt++));
651 }
652
653 //Print final states
654 for (const StateType& state : a.getFinalStates()) {
655 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
656 }
657
658 //Print nonfinal states
659 for (const auto& state : states) {
660 if (!a.getFinalStates().count(state.first)) {
661 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
662 }
663 }
664
665 //Mark initial states
666 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
667 out << "0 -> " << states.find(a.getInitialState())->second << ";\n";
668
669 transitions(a, states, out);
670 out << "}";
671}
672
673template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
675 out << "digraph automaton {\n";
676 out << "rankdir=LR;\n";
677 int cnt = 1;
678
679 //Map states to indices
681 for (const StateType& state : a.getStates()) {
682 states.insert(std::make_pair(state, cnt++));
683 }
684
685 //Print final states
686 for (const StateType& state : a.getFinalStates()) {
687 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
688 }
689
690 //Print nonfinal states
691 for (const auto& state : states) {
692 if (!a.getFinalStates().count(state.first)) {
693 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
694 }
695 }
696
697 //Mark initial states
698 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
699 out << "0 -> " << states.find(a.getInitialState())->second << ";\n";
700
701 transitions(a, states, out);
702 out << "}";
703}
704
705template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
707 out << "digraph automaton {\n";
708 out << "rankdir=LR;\n";
709 int cnt = 1;
710
711 //Map states to indices
713 for (const StateType& state : a.getStates()) {
714 states.insert(std::make_pair(state, cnt++));
715 }
716
717 //Print final states
718 for (const StateType& state : a.getFinalStates()) {
719 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
720 }
721
722 //Print nonfinal states
723 for (const auto& state : states) {
724 if (!a.getFinalStates().count(state.first)) {
725 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
726 }
727 }
728
729 //Mark initial states
730 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
731 out << "0 -> " << states.find(a.getInitialState())->second << ";\n";
732
733 transitions(a, states, out);
734 out << "}";
735}
736
737template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
739 out << "digraph automaton {\n";
740 out << "rankdir=LR;\n";
741 int cnt = 1;
742
743 //Map states to indices
745 for (const StateType& state : a.getStates()) {
746 states.insert(std::make_pair(state, cnt++));
747 }
748
749 //Print final states
750 for (const StateType& state : a.getFinalStates()) {
751 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
752 }
753
754 //Print nonfinal states
755 for (const auto& state : states) {
756 if (!a.getFinalStates().count(state.first)) {
757 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
758 }
759 }
760
761 //Mark initial states
762 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
763 out << "0 -> " << states.find(a.getInitialState())->second << ";\n";
764
765 transitions(a, states, out);
766 out << "}";
767}
768
769template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
771 out << "digraph automaton {\n";
772 out << "rankdir=LR;\n";
773 int cnt = 1;
774
775 //Map states to indices
777 for (const StateType& state : a.getStates()) {
778 states.insert(std::make_pair(state, cnt++));
779 }
780
781 //Print final states
782 for (const StateType& state : a.getFinalStates()) {
783 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
784 }
785
786 //Print nonfinal states
787 for (const auto& state : states) {
788 if (!a.getFinalStates().count(state.first)) {
789 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
790 }
791 }
792
793 //Mark initial states
794 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
795 for (const StateType& state : a.getInitialStates()) {
796 out << "0 -> " << states.find(state)->second << ";\n";
797 }
798
799 transitions(a, states, out);
800 out << "}";
801}
802
803template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
805 out << "digraph automaton {\n";
806 out << "rankdir=LR;\n";
807 int cnt = 1;
808
809 //Map states to indices
811 for (const StateType& state : a.getStates()) {
812 states.insert(std::make_pair(state, cnt++));
813 }
814
815 //Print final states
816 for (const StateType& state : a.getFinalStates()) {
817 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
818 }
819
820 //Print nonfinal states
821 for (const auto& state : states) {
822 if (!a.getFinalStates().count(state.first)) {
823 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
824 }
825 }
826
827 //Mark initial states
828 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
829 out << "0 -> " << states.find(a.getInitialState())->second << ";\n";
830
831 transitions(a, states, out);
832 out << "}";
833}
834
835template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
837 out << "digraph automaton {\n";
838 out << "rankdir=LR;\n";
839 int cnt = 1;
840
841 //Map states to indices
843 for (const StateType& state : a.getStates()) {
844 states.insert(std::make_pair(state, cnt++));
845 }
846
847 //Print final states
848 for (const StateType& state : a.getFinalStates()) {
849 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
850 }
851
852 //Print nonfinal states
853 for (const auto& state : states) {
854 if (!a.getFinalStates().count(state.first)) {
855 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
856 }
857 }
858
859 //Mark initial states
860 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
861 for (const StateType& state : a.getInitialStates()) {
862 out << "0 -> " << states.find(state)->second << ";\n";
863 }
864
865 transitions(a, states, out);
866 out << "}";
867}
868
869template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
871 out << "digraph automaton {\n";
872 out << "rankdir=LR;\n";
873 int cnt = 1;
874
875 //Map states to indices
877 for (const StateType& state : a.getStates()) {
878 states.insert(std::make_pair(state, cnt++));
879 }
880
881 //Print final states
882 for (const StateType& state : a.getFinalStates()) {
883 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
884 }
885
886 //Print nonfinal states
887 for (const auto& state : states) {
888 if (!a.getFinalStates().count(state.first)) {
889 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
890 }
891 }
892
893 //Mark initial states
894 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
895 out << "0 -> " << states.find(a.getInitialState())->second << ";\n";
896
897 transitions(a, states, out);
898 out << "}";
899}
900
901template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
903 out << "digraph automaton {\n";
904 out << "rankdir=LR;\n";
905 int cnt = 1;
906
907 //Map states to indices
909 for (const StateType& state : a.getStates()) {
910 states.insert(std::make_pair(state, cnt++));
911 }
912
913 //Print final states
914 for (const StateType& state : a.getFinalStates()) {
915 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
916 }
917
918 //Print nonfinal states
919 for (const auto& state : states) {
920 if (!a.getFinalStates().count(state.first)) {
921 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
922 }
923 }
924
925 //Mark initial states
926 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
927 out << "0 -> " << states.find(a.getInitialState())->second << ";\n";
928
929 transitions(a, states, out);
930 out << "}";
931}
932
933template < class SymbolType, class StateType >
935 out << "digraph automaton {\n";
936 out << "rankdir=LR;\n";
937 int cnt = 1;
938
939 //Map states to indices
941 for (const StateType& state : a.getStates()) {
942 states.insert(std::make_pair(state, cnt++));
943 }
944
945 //Print final states
946 for (const StateType& state : a.getFinalStates()) {
947 out << "node [shape = doublecircle, label=\"" << replace ( factory::StringDataFactory::toString ( state ), "\"", "\\\"" ) << "\"]; " << states.find(state)->second << ";\n";
948 }
949
950 //Print nonfinal states
951 for (const auto& state : states) {
952 if (!a.getFinalStates().count(state.first)) {
953 out << "node [shape = circle, label=\"" << replace ( factory::StringDataFactory::toString ( state.first ), "\"", "\\\"" ) << "\" ]; " << state.second << ";\n";
954 }
955 }
956
957 //Mark initial states
958 out << "node [shape = plaintext, label=\"start\"]; 0; \n";
959 out << "0 -> " << states.find(a.getInitialState())->second << ";\n";
960
961 transitions(a, states, out);
962 out << "}";
963}
964
965template < class SymbolType, class StateType >
966void DotConverter::transitions(const automaton::EpsilonNFA < SymbolType, StateType > & fsm, const ext::map<StateType, int>& states, ext::ostream& out) {
967 ext::map<std::pair<int, int>, std::string> transitions;
968
969 //put transitions from automaton to "transitions"
970 for (const auto& transition : fsm.getTransitions()) {
971 std::string symbol;
972 if (transition.first.second.is_epsilon()) {
973 symbol = "&epsilon;";
974 } else {
975 symbol = replace ( factory::StringDataFactory::toString ( std::get<1>(transition.first ).getSymbol()), "\"", "\\\"" );
976 }
977
978 std::pair<int, int> key(states.find(transition.first.first)->second, states.find(transition.second)->second);
979 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
980
981 if (mapit == transitions.end()) {
982 transitions.insert(std::make_pair(key, symbol));
983 } else {
984 mapit->second += ",";
985
986 size_t pos = mapit->second.find_last_of("\n");
987 if(pos == std::string::npos) pos = 0;
988 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
989 else mapit->second += " ";
990
991 mapit->second += symbol;
992 }
993 }
994
995 //print the map
996 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
997 out << transition.first.first << " -> " << transition.first.second;
998 replaceInplace(transition.second, "\n", "\\n");
999 out << "[label=\"" << transition.second << "\"]\n";
1000 }
1001}
1002
1003template < class SymbolType >
1005 out << "digraph rte {\n";
1007 out << '\n' << "}" << std::endl;
1008}
1009
1010template < class SymbolType >
1012 out << "digraph tree {\n";
1014 out << '\n' << "}" << std::endl;
1015}
1016
1017template < class SymbolType, class StateType >
1018void DotConverter::transitions(const automaton::MultiInitialStateNFA < SymbolType, StateType >& fsm, const ext::map<StateType, int>& states, ext::ostream& out) {
1019 ext::map<std::pair<int, int>, std::string> transitions;
1020
1021 //put transitions from automaton to "transitions"
1022 for (const auto& transition : fsm.getTransitions()) {
1023 std::string symbol = replace ( factory::StringDataFactory::toString ( transition.first.second ), "\"", "\\\"" );
1024
1025 std::pair<int, int> key(states.find(transition.first.first)->second, states.find(transition.second)->second);
1026 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
1027
1028 if (mapit == transitions.end()) {
1029 transitions.insert(std::make_pair(key, symbol));
1030 } else {
1031 mapit->second += ",";
1032
1033 size_t pos = mapit->second.find_last_of("\n");
1034 if(pos == std::string::npos) pos = 0;
1035 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1036 else mapit->second += " ";
1037
1038 mapit->second += symbol;
1039 }
1040 }
1041
1042 //print the map
1043 for (std::pair< const std::pair<int, int>, std::string>& transition : transitions) {
1044 out << transition.first.first << " -> " << transition.first.second;
1045 replaceInplace(transition.second, "\n", "\\n");
1046 out << "[label=\"" << transition.second << "\"]\n";
1047 }
1048}
1049
1050template < class SymbolType, class StateType >
1051void DotConverter::transitions(const automaton::NFA < SymbolType, StateType > & fsm, const ext::map<StateType, int>& states, ext::ostream& out) {
1052 ext::map<std::pair<int, int>, std::string> transitions;
1053
1054 //put transitions from automaton to "transitions"
1055 for (const auto& transition : fsm.getTransitions()) {
1056 std::string symbol = replace ( factory::StringDataFactory::toString ( transition.first.second ), "\"", "\\\"" );
1057
1058 std::pair<int, int> key(states.find(transition.first.first)->second, states.find(transition.second)->second);
1059 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
1060
1061 if (mapit == transitions.end()) {
1062 transitions.insert(std::make_pair(key, symbol));
1063 } else {
1064 mapit->second += ",";
1065
1066 size_t pos = mapit->second.find_last_of("\n");
1067 if(pos == std::string::npos) pos = 0;
1068 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1069 else mapit->second += " ";
1070
1071 mapit->second += symbol;
1072 }
1073 }
1074
1075 //print the map
1076 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
1077 out << transition.first.first << " -> " << transition.first.second;
1078 replaceInplace(transition.second, "\n", "\\n");
1079 out << "[label=\"" << transition.second << "\"]\n";
1080 }
1081}
1082
1083template < class SymbolType, class StateType >
1084void DotConverter::transitions(const automaton::DFA < SymbolType, StateType > & fsm, const ext::map<StateType, int>& states, ext::ostream& out) {
1085 ext::map<std::pair<int, int>, std::string> transitions;
1086
1087 //put transitions from automaton to "transitions"
1088 for (const auto& transition : fsm.getTransitions()) {
1089 std::string symbol = replace ( factory::StringDataFactory::toString ( transition.first.second ), "\"", "\\\"" );
1090
1091 std::pair<int, int> key(states.find(transition.first.first)->second, states.find(transition.second)->second);
1092 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
1093
1094 if (mapit == transitions.end()) {
1095 transitions.insert(std::make_pair(key, symbol));
1096 } else {
1097 mapit->second += ",";
1098
1099 size_t pos = mapit->second.find_last_of("\n");
1100 if(pos == std::string::npos) pos = 0;
1101 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1102 else mapit->second += " ";
1103
1104 mapit->second += symbol;
1105 }
1106 }
1107
1108 //print the map
1109 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
1110 out << transition.first.first << " -> " << transition.first.second;
1111 replaceInplace(transition.second, "\n", "\\n");
1112 out << "[label=\"" << transition.second << "\"]\n";
1113 }
1114}
1115
1116template < class SymbolType, class StateType >
1117void DotConverter::transitions(const automaton::ExtendedNFA < SymbolType, StateType > & fsm, const ext::map<StateType, int>& states, ext::ostream& out) {
1118 ext::map<std::pair<int, int>, std::string> transitions;
1119
1120 //put transitions from automaton to "transitions"
1121 for (const auto& transition : fsm.getTransitions()) {
1122 std::string symbol = replace ( factory::StringDataFactory::toString ( transition.first.second ), "\"", "\\\"" );
1123
1124 std::pair<int, int> key(states.find(transition.first.first)->second, states.find ( transition.second )->second);
1125 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
1126
1127 if (mapit == transitions.end()) {
1128 transitions.insert(std::make_pair(key, symbol));
1129 } else {
1130 mapit->second += ",";
1131
1132 size_t pos = mapit->second.find_last_of("\n");
1133 if(pos == std::string::npos) pos = 0;
1134 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1135 else mapit->second += " ";
1136
1137 mapit->second += symbol;
1138 }
1139 }
1140
1141 //print the map
1142 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
1143 out << transition.first.first << " -> " << transition.first.second;
1144 replaceInplace(transition.second, "\n", "\\n");
1145 out << "[label=\"" << transition.second << "\"]\n";
1146 }
1147}
1148
1149template < class SymbolType, class StateType >
1150void DotConverter::transitions(const automaton::CompactNFA < SymbolType, StateType > & fsm, const ext::map<StateType, int>& states, ext::ostream& out) {
1151 ext::map<std::pair<int, int>, std::string> transitions;
1152
1153 //put transitions from automaton to "transitions"
1154 for (const auto& transition : fsm.getTransitions()) {
1155 std::string symbol = replace ( factory::StringDataFactory::toString ( string::stringFrom ( transition.first.second ) ), "\"", "\\\"" );
1156
1157 std::pair<int, int> key(states.find(transition.first.first)->second, states.find(transition.second)->second);
1158 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
1159
1160 if (mapit == transitions.end()) {
1161 transitions.insert(std::make_pair(key, symbol));
1162 } else {
1163 mapit->second += ",";
1164
1165 size_t pos = mapit->second.find_last_of("\n");
1166 if(pos == std::string::npos) pos = 0;
1167 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1168 else mapit->second += " ";
1169
1170 mapit->second += symbol;
1171 }
1172 }
1173
1174 //print the map
1175 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
1176 out << transition.first.first << " -> " << transition.first.second;
1177 replaceInplace(transition.second, "\n", "\\n");
1178 out << "[label=\"" << transition.second << "\"]\n";
1179 }
1180}
1181
1182template < class SymbolType, class StateType >
1183void DotConverter::transitions(const automaton::ExtendedNFTA < SymbolType, StateType > & fta, const ext::map<StateType, int>& states, ext::ostream& out) {
1184 //print the map
1185 unsigned auxNodeCnt = 1;
1186 for (const auto & transition : fta.getTransitions ( ) ) {
1187 // print subgraph with the rte
1188 out << '\n';
1189 out << "subgraph cluster_rte_" << auxNodeCnt << "{" << '\n';
1190 out << "label=\"rte_" << auxNodeCnt << "\"\n";
1191 out << "color = blue;\n";
1192 convert::DotConverterRTE::convertInternal ( out, rte::FormalRTE < ext::variant < SymbolType, StateType > > ( transition.first.first ), "x" + ext::to_string ( auxNodeCnt ) + "x" );
1193 out << "}\n" << std::endl;
1194
1195 out << "node [shape = point, label=\"\"]; Aux" << auxNodeCnt << ";\n";
1196 unsigned j = 1;
1197 for(const auto & state : transition.first.second) // from source states to connecting node
1198 out << "State" << states.at ( state ) << " -> " << "Aux" << auxNodeCnt << "[label=\"" << j++ << "\"];\n";
1199 for ( const auto & target : transition.second ) // from connecting node to target nodes
1200 out << "Aux" << auxNodeCnt << " -> State" << states.at ( target ) << "[label=\"" << "rte_" << auxNodeCnt << "\"];\n";
1201
1202 auxNodeCnt++;
1203 }
1204}
1205
1206template < class SymbolType, class StateType >
1207void DotConverter::transitions(const automaton::NFTA < SymbolType, StateType > & fta, const ext::map<StateType, int>& states, ext::ostream& out) {
1208 ext::map<std::pair<int, ext::vector<int>>, std::string> transitions;
1209
1210 //put transitions from automaton to "transitions"
1211 for (const auto& transition : fta.getTransitions()) {
1212 std::string symbol = replace ( factory::StringDataFactory::toString ( transition.first.first.getSymbol( )), "\"", "\\\"" );
1213 symbol += ext::to_string(transition.first.first.getRank());
1214
1215 std::pair<int, ext::vector<int>> key(states.find(transition.second)->second, {});
1216 for(const StateType& state : transition.first.second) {
1217 key.second.push_back(states.find(state)->second);
1218 }
1219 ext::map<std::pair<int, ext::vector<int>>, std::string>::iterator mapit = transitions.find(key);
1220
1221 if (mapit == transitions.end()) {
1222 transitions.insert(std::make_pair(key, symbol));
1223 } else {
1224 mapit->second += ",";
1225
1226 size_t pos = mapit->second.find_last_of("\n");
1227 if(pos == std::string::npos) pos = 0;
1228 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1229 else mapit->second += " ";
1230
1231 mapit->second += symbol;
1232 }
1233 }
1234
1235 //Print auxilary dots
1236 for (unsigned i = 1; i <= transitions.size(); i++) {
1237 out << "node [shape = point, label=\"\"]; " << states.size() + i << ";\n";
1238 }
1239
1240 //print the map
1241 unsigned i = states.size() + 1;
1242 for (std::pair<const std::pair<int, ext::vector<int>>, std::string>& transition : transitions) {
1243 out << i << " -> " << transition.first.first;
1244 replaceInplace(transition.second, "\n", "\\n");
1245 out << "[label=\"" << transition.second << "\"]\n";
1246 unsigned j = 0;
1247 for(int from : transition.first.second) {
1248 out << from << " -> " << i;
1249 out << "[label=\"" << j << "\"]\n";
1250 j++;
1251 }
1252 i++;
1253 }
1254}
1255
1256template < class SymbolType, class StateType >
1257void DotConverter::transitions(const automaton::EpsilonNFTA < SymbolType, StateType > & fta, const ext::map<StateType, int>& states, ext::ostream& out) {
1258 ext::map<std::pair<int, ext::vector<int>>, std::string> transitions;
1259 ext::multimap<int, int> epsilonTransitions;
1260
1261 //put transitions from automaton to "transitions"
1262 for (const auto& transition : fta.getTransitions()) {
1263 if ( transition.first.template is < StateType > ( ) ) {
1264 const StateType & source = transition.first.template get < StateType > ( );
1265 epsilonTransitions.insert ( states.find ( source )->second, states.find ( transition.second )->second );
1266 } else {
1267 const ext::pair < common::ranked_symbol < SymbolType >, ext::vector < StateType > > & source = transition.first.template get < ext::pair < common::ranked_symbol < SymbolType >, ext::vector < StateType > > > ( );
1268 std::string symbol = replace ( factory::StringDataFactory::toString ( source.first.getSymbol( )), "\"", "\\\"" );
1269 symbol += ext::to_string(source.first.getRank());
1270
1271 std::pair<int, ext::vector<int>> key(states.find(transition.second)->second, {});
1272 for(const StateType& state : source.second) {
1273 key.second.push_back(states.find(state)->second);
1274 }
1275 ext::map<std::pair<int, ext::vector<int>>, std::string>::iterator mapit = transitions.find(key);
1276
1277 if (mapit == transitions.end()) {
1278 transitions.insert(std::make_pair(key, symbol));
1279 } else {
1280 mapit->second += ",";
1281
1282 size_t pos = mapit->second.find_last_of("\n");
1283 if(pos == std::string::npos) pos = 0;
1284 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1285 else mapit->second += " ";
1286
1287 mapit->second += symbol;
1288 }
1289 }
1290 }
1291
1292 //Print auxilary dots
1293 for (unsigned i = 1; i <= transitions.size(); i++) {
1294 out << "node [shape = point, label=\"\"]; " << states.size() + i << ";\n";
1295 }
1296
1297 //print the map
1298 unsigned i = states.size() + 1;
1299 for (std::pair<const std::pair<int, ext::vector<int>>, std::string>& transition : transitions) {
1300 out << i << " -> " << transition.first.first;
1301 replaceInplace(transition.second, "\n", "\\n");
1302 out << "[label=\"" << transition.second << "\"]\n";
1303 unsigned j = 0;
1304 for(int from : transition.first.second) {
1305 out << from << " -> " << i;
1306 out << "[label=\"" << j << "\"]\n";
1307 j++;
1308 }
1309 i++;
1310 }
1311
1312 for ( const std::pair < const int, int > epsilonTransition : epsilonTransitions ) {
1313 out << epsilonTransition.first << " -> " << epsilonTransition.second;
1314 out << "[label=\"&epsilon;\"]\n";
1315 }
1316}
1317
1318template < class SymbolType, class StateType >
1319void DotConverter::transitions(const automaton::UnorderedNFTA < SymbolType, StateType > & fta, const ext::map<StateType, int>& states, ext::ostream& out) {
1320 ext::map<std::pair<int, ext::vector<int>>, std::string> transitions;
1321
1322 //put transitions from automaton to "transitions"
1323 for (const auto& transition : fta.getTransitions()) {
1324 std::string symbol = replace ( factory::StringDataFactory::toString ( transition.first.first.getSymbol( )), "\"", "\\\"" );
1325 symbol += ext::to_string(transition.first.first.getRank());
1326
1327 std::pair<int, ext::vector<int>> key(states.find(transition.second)->second, {});
1328 for(const StateType& state : transition.first.second) {
1329 key.second.push_back(states.find(state)->second);
1330 }
1331 ext::map<std::pair<int, ext::vector<int>>, std::string>::iterator mapit = transitions.find(key);
1332
1333 if (mapit == transitions.end()) {
1334 transitions.insert(std::make_pair(key, symbol));
1335 } else {
1336 mapit->second += ",";
1337
1338 size_t pos = mapit->second.find_last_of("\n");
1339 if(pos == std::string::npos) pos = 0;
1340 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1341 else mapit->second += " ";
1342
1343 mapit->second += symbol;
1344 }
1345 }
1346
1347 //Print auxilary dots
1348 for (unsigned i = 1; i <= transitions.size(); i++) {
1349 out << "node [shape = point, label=\"\"]; " << states.size() + i << ";\n";
1350 }
1351
1352 //print the map
1353 unsigned i = states.size() + 1;
1354 for (std::pair<const std::pair<int, ext::vector<int>>, std::string>& transition : transitions) {
1355 out << i << " -> " << transition.first.first;
1356 replaceInplace(transition.second, "\n", "\\n");
1357 out << "[label=\"" << transition.second << "\"]\n";
1358 unsigned j = 0;
1359 for(int from : transition.first.second) {
1360 out << from << " -> " << i << "\n";
1361 j++;
1362 }
1363 i++;
1364 }
1365}
1366
1367template < class SymbolType, class StateType >
1368void DotConverter::transitions(const automaton::DFTA < SymbolType, StateType > & fta, const ext::map<StateType, int>& states, ext::ostream& out) {
1369 ext::map<std::pair<int, ext::vector<int>>, std::string> transitions;
1370
1371 //put transitions from automaton to "transitions"
1372 for (const auto& transition : fta.getTransitions()) {
1373 std::string symbol = replace ( factory::StringDataFactory::toString ( transition.first.first.getSymbol( )), "\"", "\\\"" );
1374 symbol += ext::to_string(transition.first.first.getRank());
1375
1376 std::pair<int, ext::vector<int>> key(states.find(transition.second)->second, {});
1377 for(const StateType& state : transition.first.second) {
1378 key.second.push_back(states.find(state)->second);
1379 }
1380 ext::map<std::pair<int, ext::vector<int>>, std::string>::iterator mapit = transitions.find(key);
1381
1382 if (mapit == transitions.end()) {
1383 transitions.insert(std::make_pair(key, symbol));
1384 } else {
1385 mapit->second += ",";
1386
1387 size_t pos = mapit->second.find_last_of("\n");
1388 if(pos == std::string::npos) pos = 0;
1389 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1390 else mapit->second += " ";
1391
1392 mapit->second += symbol;
1393 }
1394 }
1395
1396 //Print auxilary dots
1397 for (unsigned i = 1; i <= transitions.size(); i++) {
1398 out << "node [shape = point, label=\"\"]; " << states.size() + i << ";\n";
1399 }
1400
1401 //print the map
1402 unsigned i = states.size() + 1;
1403 for (std::pair<const std::pair<int, ext::vector<int>>, std::string>& transition : transitions) {
1404 out << i << " -> " << transition.first.first;
1405 replaceInplace(transition.second, "\n", "\\n");
1406 out << "[label=\"" << transition.second << "\"]\n";
1407 unsigned j = 0;
1408 for(int from : transition.first.second) {
1409 out << from << " -> " << i;
1410 out << "[label=\"" << j << "\"]\n";
1411 j++;
1412 }
1413 i++;
1414 }
1415}
1416
1417template < class SymbolType, class StateType >
1418void DotConverter::transitions(const automaton::ArcFactoredNondeterministicZAutomaton < SymbolType, StateType > & afnza, const ext::map<StateType, int>& states, ext::ostream& out) {
1419 ext::set < std::tuple<int, int, int> > stateTransitions;
1420
1421 //put transitions from automaton to "transitions"
1422 for (const auto& transition : afnza.getTransitions()) {
1423 if ( transition.first.template is < ext::pair < StateType, StateType > > ( ) ) {
1424 const ext::pair < StateType, StateType > & trans = transition.first.template get < ext::pair < StateType, StateType > > ( );
1425
1426 std::tuple < int, int, int > key ( states.find ( trans.first )->second, states.find ( trans.second )->second, states.find ( transition.second )->second );
1427 stateTransitions.insert ( std::move ( key ) );
1428 }
1429 }
1430
1431 ext::map < int, std::string > symbolTransitions;
1432
1433 for (const auto& transition : afnza.getTransitions()) {
1434 if ( transition.first.template is < SymbolType > ( ) ) {
1435 int key = states.find ( transition.second )->second;
1436
1437 const SymbolType & trans = transition.first.template get < SymbolType > ( );
1438 std::string symbol = replace ( factory::StringDataFactory::toString ( trans ), "\"", "\\\"" );
1439
1440 ext::map < int, std::string >::iterator mapit = symbolTransitions.find ( key );
1441
1442 if (mapit == symbolTransitions.end()) {
1443 symbolTransitions.insert(std::make_pair(key, symbol));
1444 } else {
1445 mapit->second += ",";
1446
1447 size_t pos = mapit->second.find_last_of("\n");
1448 if(pos == std::string::npos) pos = 0;
1449 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1450 else mapit->second += " ";
1451
1452 mapit->second += symbol;
1453 }
1454 }
1455 }
1456
1457 //Print auxilary dots, symbols
1458 for (unsigned i = 1; i <= symbolTransitions.size(); i++) {
1459 out << "node [shape = point, label=\"\"]; " << states.size ( ) + i << ";\n";
1460 }
1461
1462 //print the symbol map
1463 {
1464 unsigned i = states.size ( ) + 1;
1465 for ( std::pair < const int, std::string > & transition : symbolTransitions ) {
1466 out << i << " -> " << transition.first;
1467 replaceInplace(transition.second, "\n", "\\n");
1468 out << "[label=\"" << transition.second << "\"]\n";
1469 i++;
1470 }
1471 }
1472
1473 //Print auxilary dots, state transitions
1474 for (unsigned i = 1; i <= stateTransitions.size(); i++) {
1475 out << "node [shape = point, label=\"\"]; " << states.size ( ) + symbolTransitions.size ( ) + i << ";\n";
1476 }
1477
1478 //print the map
1479 {
1480 unsigned i = states.size ( ) + symbolTransitions.size ( ) + 1;
1481 for ( const std::tuple < int, int, int > & transition : stateTransitions ) {
1482 out << i << " -> " << std::get < 2 > ( transition ) << "\n";
1483 out << std::get < 0 > ( transition ) << " -> " << i;
1484 out << "[label=\"" << 0 << "\"]\n";
1485 out << std::get < 1 > ( transition ) << " -> " << i;
1486 out << "[label=\"" << 1 << "\"]\n";
1487 i++;
1488 }
1489 }
1490}
1491
1492template < class SymbolType, class StateType >
1493void DotConverter::transitions(const automaton::NondeterministicZAutomaton < SymbolType, StateType > & nza, const ext::map<StateType, int>& states, ext::ostream& out) {
1494 ext::set < std::tuple < std::variant < int, std::string >, std::vector < std::variant < int, std::string > >, int > > transitions;
1495
1496 auto transform = [ & ] ( const ext::variant < SymbolType, StateType > & param ) -> std::variant < int, std::string > {
1497 if ( nza.getInputAlphabet ( ).contains ( param ) ) {
1498 return replace ( factory::StringDataFactory::toString ( param.template get < SymbolType > ( ) ), "\"", "\\\"" );
1499 } else {
1500 return states.find ( param.template get < StateType > ( ) )->second;
1501 }
1502 };
1503
1504 //put transitions from automaton to "transitions"
1505 for ( const std::pair < const ext::pair < ext::variant < SymbolType, StateType >, ext::vector < ext::variant < SymbolType, StateType > > >, StateType > & transition : nza.getTransitions ( ) ) {
1506 std::variant < int, std::string > sourcesFirst = transform ( transition.first.first );
1507 std::vector < std::variant < int, std::string > > sourcesSecond;
1508 for ( const ext::variant < SymbolType, StateType > & from : transition.first.second ) {
1509 sourcesSecond.push_back ( transform ( from ) );
1510 }
1511 int destination = states.find ( transition.second )->second;
1512
1513 transitions.insert ( std::make_tuple ( sourcesFirst, sourcesSecond, destination ) );
1514 }
1515
1516 // transition structs
1517 {
1518 out << "node[shape=record];\n";
1519 unsigned i = states.size ( ) + 1;
1520 for ( const std::tuple < std::variant < int, std::string >, std::vector < std::variant < int, std::string > >, int > & transition : transitions ) {
1521 const auto & firstSource = std::get < 0 > ( transition );
1522 out << "struct" << i<< "[ label =\"<head> " << ( std::holds_alternative < std::string > ( firstSource ) ? std::get < std::string > ( firstSource ) : "" );
1523 const auto & secondSource = std::get < 1 > ( transition );
1524 if ( ! secondSource.empty ( ) ) {
1525 out << "|{";
1526 for ( unsigned j = 0; j < secondSource.size ( ); ++ j ) {
1527 if ( j != 0 ) {
1528 out << "|";
1529 }
1530 out << "<" << j << "> " << ( std::holds_alternative < std::string > ( firstSource ) ? std::get < std::string > ( firstSource ) : "" );
1531 }
1532 out << "}";
1533 }
1534 out << "\"];\n";
1535 i++;
1536 }
1537 }
1538
1539 //print the symbol map
1540 {
1541 unsigned i = states.size ( ) + 1;
1542 for ( const std::tuple < std::variant < int, std::string >, std::vector < std::variant < int, std::string > >, int > & transition : transitions ) {
1543 out << "struct" << i << ":head:e -> " << std::get < 2 > ( transition ) << "\n";
1544 const auto & firstSource = std::get < 0 > ( transition );
1545 if ( std::holds_alternative < int > ( firstSource ) ) {
1546 out << std::get < int > ( firstSource ) << " -> struct" << i << ":head:w\n";
1547 }
1548 const auto & secondSource = std::get < 1 > ( transition );
1549 for ( unsigned j = 0; j < secondSource.size ( ); ++ j ) {
1550 if ( std::holds_alternative < int > ( secondSource [ j ] ) ) {
1551 out << std::get < int > ( secondSource [ j ] ) << " -> struct" << i << ":" << j << "\n";
1552 }
1553 }
1554 i++;
1555 }
1556 }
1557}
1558
1559template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
1560void DotConverter::transitions(const automaton::DPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & pda, const ext::map < StateType, int > & states, ext::ostream& out) {
1561 ext::map<std::pair<int, int>, std::string> transitions;
1562
1563 for (const auto& transition : pda.getTransitions()) {
1564 std::string symbol;
1565
1566 //input symbol
1567 if (std::get<1>(transition.first).is_epsilon ( ) ) {
1568 symbol = "&epsilon;";
1569 } else {
1570 symbol = replace ( factory::StringDataFactory::toString ( std::get<1>(transition.first ).getSymbol()), "\"", "\\\"" );
1571 }
1572
1573 symbol += " |";
1574
1575 //Pop part
1576 if (std::get<2>(transition.first).empty ( )) {
1577 symbol += " &epsilon;";
1578 } else {
1579 for ( const PushdownStoreSymbolType & symb : std::get<2>(transition.first)) {
1580 symbol += " " + replace ( factory::StringDataFactory::toString ( symb ), "\"", "\\\"" );
1581 }
1582
1583 }
1584
1585 symbol += " ->";
1586
1587 //Push part
1588 if (transition.second.second.empty ( )) {
1589 symbol += " &epsilon;";
1590 } else {
1591 for ( const PushdownStoreSymbolType & symb : transition.second.second) {
1592 symbol += " " + replace ( factory::StringDataFactory::toString ( symb ), "\"", "\\\"" );
1593 }
1594
1595 }
1596
1597 //Insert into map
1598 std::pair<int, int> key(states.find(std::get<0>(transition.first))->second, states.find(transition.second.first)->second);
1599 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
1600
1601 if (mapit == transitions.end()) {
1602 transitions.insert(std::make_pair(key, symbol));
1603 } else {
1604 mapit->second += ",";
1605
1606 size_t pos = mapit->second.find_last_of("\n");
1607 if(pos == std::string::npos) pos = 0;
1608 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1609 else mapit->second += " ";
1610
1611 mapit->second += symbol;
1612 }
1613 }
1614
1615 //print the map
1616 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
1617 out << transition.first.first << " -> " << transition.first.second;
1618 replaceInplace(transition.second, "\n", "\\n");
1619 out << "[label=\"" << transition.second << "\"]\n";
1620 }
1621}
1622
1623template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
1625 ext::map<std::pair<int, int>, std::string> transitions;
1626
1627 for (const auto& transition : pda.getTransitions()) {
1628 std::string symbol;
1629
1630 //input symbol
1631 if (std::get<1>(transition.first).is_epsilon ( )) {
1632 symbol = "&epsilon;";
1633 } else {
1634 symbol = replace ( factory::StringDataFactory::toString ( std::get<1>(transition.first ).getSymbol ( )), "\"", "\\\"" );
1635 }
1636
1637 symbol += " |";
1638
1639 //Pop part
1640 symbol += " " + replace ( factory::StringDataFactory::toString ( std::get<2>(transition.first )), "\"", "\\\"" );
1641
1642 symbol += " ->";
1643
1644 //Push part
1645 if (transition.second.second.empty ( )) {
1646 symbol += " &epsilon;";
1647 } else {
1648 for ( const PushdownStoreSymbolType & symb : transition.second.second) {
1649 symbol += " " + replace ( factory::StringDataFactory::toString ( symb ), "\"", "\\\"" );
1650 }
1651
1652 }
1653
1654 //Insert into map
1655 std::pair<int, int> key(states.find(std::get<0>(transition.first))->second, states.find(transition.second.first)->second);
1656 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
1657
1658 if (mapit == transitions.end()) {
1659 transitions.insert(std::make_pair(key, symbol));
1660 } else {
1661 mapit->second += ",";
1662
1663 size_t pos = mapit->second.find_last_of("\n");
1664 if(pos == std::string::npos) pos = 0;
1665 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1666 else mapit->second += " ";
1667
1668 mapit->second += symbol;
1669 }
1670 }
1671
1672 //print the map
1673 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
1674 out << transition.first.first << " -> " << transition.first.second;
1675 replaceInplace(transition.second, "\n", "\\n");
1676 out << "[label=\"" << transition.second << "\"]\n";
1677 }
1678}
1679
1680template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
1682 ext::map<std::pair<int, int>, std::string> transitions;
1683
1684 const auto& symbolToPDSOperation = pda.getPushdownStoreOperations();
1685 for (const auto& transition : pda.getTransitions()) {
1686 const auto& pop = symbolToPDSOperation.find(transition.first.second)->second.first;
1687 const auto& push = symbolToPDSOperation.find(transition.first.second)->second.second;
1688
1689 std::string symbol;
1690
1691 //input symbol
1692 symbol = replace ( factory::StringDataFactory::toString ( transition.first.second ), "\"", "\\\"" );
1693
1694 symbol += " |";
1695
1696 //Pop part
1697 if (pop.empty ( )) {
1698 symbol += " &epsilon;";
1699 } else {
1700 for ( const PushdownStoreSymbolType & symb : pop) {
1701 symbol += " " + replace ( factory::StringDataFactory::toString ( symb ), "\"", "\\\"" );
1702 }
1703
1704 }
1705
1706 symbol += " ->";
1707
1708 const auto& to = transition.second;
1709 //Push part
1710 if (push.empty ( )) {
1711 symbol += " &epsilon;";
1712 } else {
1713 for ( const PushdownStoreSymbolType & symb : push) {
1714 symbol += " " + replace ( factory::StringDataFactory::toString ( symb ), "\"", "\\\"" );
1715 }
1716
1717 }
1718
1719 //Insert into map
1720 std::pair<int, int> key(states.find(transition.first.first)->second, states.find(to)->second);
1721 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
1722
1723 if (mapit == transitions.end()) {
1724 transitions.insert(std::make_pair(key, symbol));
1725 } else {
1726 mapit->second += ",";
1727
1728 size_t pos = mapit->second.find_last_of("\n");
1729 if(pos == std::string::npos) pos = 0;
1730 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1731 else mapit->second += " ";
1732
1733 mapit->second += symbol;
1734 }
1735 }
1736
1737 //print the map
1738 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
1739 out << transition.first.first << " -> " << transition.first.second;
1740 replaceInplace(transition.second, "\n", "\\n");
1741 out << "[label=\"" << transition.second << "\"]\n";
1742 }
1743}
1744
1745template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
1747 ext::map<std::pair<int, int>, std::string> transitions;
1748
1749 const auto& symbolToPDSOperation = pda.getPushdownStoreOperations();
1750 for (const auto& transition : pda.getTransitions()) {
1751 const auto& pop = symbolToPDSOperation.find(transition.first.second)->second.first;
1752 const auto& push = symbolToPDSOperation.find(transition.first.second)->second.second;
1753
1754 std::string symbol;
1755
1756 //input symbol
1757 symbol = replace ( factory::StringDataFactory::toString ( transition.first.second ), "\"", "\\\"" );
1758
1759 symbol += " |";
1760
1761 //Pop part
1762 if (pop.empty ( )) {
1763 symbol += " &epsilon;";
1764 } else {
1765 for ( const PushdownStoreSymbolType & symb : pop) {
1766 symbol += " " + replace ( factory::StringDataFactory::toString ( symb ), "\"", "\\\"" );
1767 }
1768
1769 }
1770
1771 symbol += " ->";
1772
1773 //Push part
1774 if (push.empty ( )) {
1775 symbol += " &epsilon;";
1776 } else {
1777 for ( const PushdownStoreSymbolType & symb : push) {
1778 symbol += " " + replace ( factory::StringDataFactory::toString ( symb ), "\"", "\\\"" );
1779 }
1780
1781 }
1782
1783 //Insert into map
1784 std::pair<int, int> key(states.find(transition.first.first)->second, states.find( transition.second )->second);
1785 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
1786
1787 if (mapit == transitions.end()) {
1788 transitions.insert(std::make_pair(key, symbol));
1789 } else {
1790 mapit->second += ",";
1791
1792 size_t pos = mapit->second.find_last_of("\n");
1793 if(pos == std::string::npos) pos = 0;
1794 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1795 else mapit->second += " ";
1796
1797 mapit->second += symbol;
1798 }
1799 }
1800
1801 //print the map
1802 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
1803 out << transition.first.first << " -> " << transition.first.second;
1804 replaceInplace(transition.second, "\n", "\\n");
1805 out << "[label=\"" << transition.second << "\"]\n";
1806 }
1807}
1808
1809template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
1811 ext::map<std::pair<int, int>, std::string> transitions;
1812
1813 for (const auto& transition : pda.getCallTransitions()) {
1814 std::string symbol;
1815
1816 //input symbol
1817 symbol = replace ( factory::StringDataFactory::toString ( transition.first.second ), "\"", "\\\"" );
1818
1819 symbol += " |";
1820
1821 //Pop part
1822 symbol += " &epsilon;";
1823 symbol += " ->";
1824
1825 symbol += " " + replace ( factory::StringDataFactory::toString ( transition.second.second ), "\"", "\\\"" );
1826
1827 //Insert into map
1828 std::pair<int, int> key(states.find(transition.first.first)->second, states.find(transition.second.first)->second);
1829 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
1830
1831 if (mapit == transitions.end()) {
1832 transitions.insert(std::make_pair(key, symbol));
1833 } else {
1834 mapit->second += ",";
1835
1836 size_t pos = mapit->second.find_last_of("\n");
1837 if(pos == std::string::npos) pos = 0;
1838 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1839 else mapit->second += " ";
1840
1841 mapit->second += symbol;
1842 }
1843 }
1844
1845 for (const auto& transition : pda.getReturnTransitions()) {
1846 std::string symbol;
1847
1848 //input symbol
1849 symbol = replace ( factory::StringDataFactory::toString ( std::get<1>(transition.first )), "\"", "\\\"" );
1850
1851 symbol += " |";
1852
1853 //Pop part
1854 symbol += " " + replace ( factory::StringDataFactory::toString ( std::get<2>(transition.first )), "\"", "\\\"" );
1855 symbol += " ->";
1856
1857 symbol += " &epsilon;";
1858
1859 //Insert into map
1860 std::pair<int, int> key(states.find(std::get<0>(transition.first))->second, states.find(transition.second)->second);
1861 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
1862
1863 if (mapit == transitions.end()) {
1864 transitions.insert(std::make_pair(key, symbol));
1865 } else {
1866 mapit->second += ",";
1867
1868 size_t pos = mapit->second.find_last_of("\n");
1869 if(pos == std::string::npos) pos = 0;
1870 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1871 else mapit->second += " ";
1872
1873 mapit->second += symbol;
1874 }
1875 }
1876
1877 for (const auto& transition : pda.getLocalTransitions()) {
1878 std::string symbol;
1879
1880 //input symbol
1881 symbol = replace ( factory::StringDataFactory::toString ( transition.first.second ), "\"", "\\\"" );
1882
1883 symbol += " |";
1884
1885 //Pop part
1886 symbol += " &epsilon;";
1887 symbol += " ->";
1888
1889 symbol += " &epsilon;";
1890
1891 //Insert into map
1892 std::pair<int, int> key(states.find(transition.first.first)->second, states.find(transition.second)->second);
1893 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
1894
1895 if (mapit == transitions.end()) {
1896 transitions.insert(std::make_pair(key, symbol));
1897 } else {
1898 mapit->second += ",";
1899
1900 size_t pos = mapit->second.find_last_of("\n");
1901 if(pos == std::string::npos) pos = 0;
1902 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1903 else mapit->second += " ";
1904
1905 mapit->second += symbol;
1906 }
1907 }
1908
1909 //print the map
1910 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
1911 out << transition.first.first << " -> " << transition.first.second;
1912 replaceInplace(transition.second, "\n", "\\n");
1913 out << "[label=\"" << transition.second << "\"]\n";
1914 }
1915}
1916
1917template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
1919 ext::map<std::pair<int, int>, std::string> transitions;
1920
1921 for (const auto& transition : pda.getCallTransitions()) {
1922 std::string symbol;
1923
1924 //input symbol
1925 symbol = replace ( factory::StringDataFactory::toString ( transition.first.second ), "\"", "\\\"" );
1926
1927 symbol += " |";
1928
1929 //Pop part
1930 symbol += " &epsilon;";
1931 symbol += " ->";
1932
1933 symbol += " " + replace ( factory::StringDataFactory::toString ( transition.second.second ), "\"", "\\\"" );
1934
1935 //Insert into map
1936 std::pair<int, int> key(states.find(transition.first.first)->second, states.find(transition.second.first)->second);
1937 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
1938
1939 if (mapit == transitions.end()) {
1940 transitions.insert(std::make_pair(key, symbol));
1941 } else {
1942 mapit->second += ",";
1943
1944 size_t pos = mapit->second.find_last_of("\n");
1945 if(pos == std::string::npos) pos = 0;
1946 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1947 else mapit->second += " ";
1948
1949 mapit->second += symbol;
1950 }
1951 }
1952
1953 for (const auto& transition : pda.getReturnTransitions()) {
1954 std::string symbol;
1955
1956 //input symbol
1957 symbol = replace ( factory::StringDataFactory::toString ( std::get<1>(transition.first )), "\"", "\\\"" );
1958
1959 symbol += " |";
1960
1961 //Pop part
1962 symbol += " " + replace ( factory::StringDataFactory::toString ( std::get<2>(transition.first )), "\"", "\\\"" );
1963 symbol += " ->";
1964
1965 symbol += " &epsilon;";
1966
1967 //Insert into map
1968 std::pair<int, int> key(states.find(std::get<0>(transition.first))->second, states.find(transition.second)->second);
1969 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
1970
1971 if (mapit == transitions.end()) {
1972 transitions.insert(std::make_pair(key, symbol));
1973 } else {
1974 mapit->second += ",";
1975
1976 size_t pos = mapit->second.find_last_of("\n");
1977 if(pos == std::string::npos) pos = 0;
1978 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
1979 else mapit->second += " ";
1980
1981 mapit->second += symbol;
1982 }
1983 }
1984
1985 for (const auto& transition : pda.getLocalTransitions()) {
1986 std::string symbol;
1987
1988 //input symbol
1989 symbol = replace ( factory::StringDataFactory::toString ( transition.first.second ), "\"", "\\\"" );
1990
1991 symbol += " |";
1992
1993 //Pop part
1994 symbol += " &epsilon;";
1995 symbol += " ->";
1996
1997 symbol += " &epsilon;";
1998
1999 //Insert into map
2000 std::pair<int, int> key(states.find(transition.first.first)->second, states.find(transition.second)->second);
2001 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
2002
2003 if (mapit == transitions.end()) {
2004 transitions.insert(std::make_pair(key, symbol));
2005 } else {
2006 mapit->second += ",";
2007
2008 size_t pos = mapit->second.find_last_of("\n");
2009 if(pos == std::string::npos) pos = 0;
2010 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
2011 else mapit->second += " ";
2012
2013 mapit->second += symbol;
2014 }
2015 }
2016
2017 //print the map
2018 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
2019 out << transition.first.first << " -> " << transition.first.second;
2020 replaceInplace(transition.second, "\n", "\\n");
2021 out << "[label=\"" << transition.second << "\"]\n";
2022 }
2023}
2024
2025template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
2027 ext::map<std::pair<int, int>, std::string> transitions;
2028
2029 for (const auto& transition : pda.getCallTransitions()) {
2030 std::string symbol;
2031
2032 //input symbol
2033 if(transition.first.second.is_epsilon ( ) )
2034 symbol = "&epsilon";
2035 else
2036 symbol = replace ( factory::StringDataFactory::toString ( transition.first.second.getSymbol ( ) ), "\"", "\\\"" );
2037
2038 symbol += " |";
2039
2040 //Pop part
2041 symbol += " &epsilon;";
2042 symbol += " ->";
2043
2044 symbol += " " + replace ( factory::StringDataFactory::toString ( transition.second.second ), "\"", "\\\"" );
2045
2046 //Insert into map
2047 std::pair<int, int> key(states.find(transition.first.first)->second, states.find(transition.second.first)->second);
2048 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
2049
2050 if (mapit == transitions.end()) {
2051 transitions.insert(std::make_pair(key, symbol));
2052 } else {
2053 mapit->second += ",";
2054
2055 size_t pos = mapit->second.find_last_of("\n");
2056 if(pos == std::string::npos) pos = 0;
2057 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
2058 else mapit->second += " ";
2059
2060 mapit->second += symbol;
2061 }
2062 }
2063
2064 for (const auto& transition : pda.getReturnTransitions()) {
2065 std::string symbol;
2066
2067 //input symbol
2068 if(std::get<1>(transition.first).is_epsilon ( ) )
2069 symbol = "&epsilon";
2070 else
2071 symbol = replace ( factory::StringDataFactory::toString ( std::get<1>(transition.first ).getSymbol ( ) ), "\"", "\\\"" );
2072
2073 symbol += " |";
2074
2075 //Pop part
2076 symbol += " " + replace ( factory::StringDataFactory::toString ( std::get<2>(transition.first )), "\"", "\\\"" );
2077 symbol += " ->";
2078
2079 symbol += " &epsilon;";
2080
2081 //Insert into map
2082 std::pair<int, int> key(states.find(std::get<0>(transition.first))->second, states.find(transition.second)->second);
2083 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
2084
2085 if (mapit == transitions.end()) {
2086 transitions.insert(std::make_pair(key, symbol));
2087 } else {
2088 mapit->second += ",";
2089
2090 size_t pos = mapit->second.find_last_of("\n");
2091 if(pos == std::string::npos) pos = 0;
2092 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
2093 else mapit->second += " ";
2094
2095 mapit->second += symbol;
2096 }
2097 }
2098
2099 for (const auto& transition : pda.getLocalTransitions()) {
2100 std::string symbol;
2101
2102 //input symbol
2103 if(transition.first.second.is_epsilon ( ) )
2104 symbol = "&epsilon";
2105 else
2106 symbol = replace ( factory::StringDataFactory::toString ( transition.first.second.getSymbol ( ) ), "\"", "\\\"" );
2107
2108 symbol += " |";
2109
2110 //Pop part
2111 symbol += " &epsilon;";
2112 symbol += " ->";
2113
2114 symbol += " &epsilon;";
2115
2116 //Insert into map
2117 std::pair<int, int> key(states.find(transition.first.first)->second, states.find(transition.second)->second);
2118 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
2119
2120 if (mapit == transitions.end()) {
2121 transitions.insert(std::make_pair(key, symbol));
2122 } else {
2123 mapit->second += ",";
2124
2125 size_t pos = mapit->second.find_last_of("\n");
2126 if(pos == std::string::npos) pos = 0;
2127 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
2128 else mapit->second += " ";
2129
2130 mapit->second += symbol;
2131 }
2132 }
2133
2134 //print the map
2135 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
2136 out << transition.first.first << " -> " << transition.first.second;
2137 replaceInplace(transition.second, "\n", "\\n");
2138 out << "[label=\"" << transition.second << "\"]\n";
2139 }
2140}
2141
2142template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
2144 ext::map<std::pair<int, int>, std::string> transitions;
2145
2146 for (const auto& transition : pda.getCallTransitions()) {
2147 std::string symbol;
2148
2149 //input symbol
2150 if(transition.first.second.is_epsilon ( ) )
2151 symbol = "&epsilon";
2152 else
2153 symbol = replace ( factory::StringDataFactory::toString ( transition.first.second.getSymbol ( ) ), "\"", "\\\"" );
2154
2155 symbol += " |";
2156
2157 //Pop part
2158 symbol += " &epsilon;";
2159 symbol += " ->";
2160
2161 symbol += " " + replace ( factory::StringDataFactory::toString ( transition.second.second ), "\"", "\\\"" );
2162
2163 //Insert into map
2164 std::pair<int, int> key(states.find(transition.first.first)->second, states.find(transition.second.first)->second);
2165 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
2166
2167 if (mapit == transitions.end()) {
2168 transitions.insert(std::make_pair(key, symbol));
2169 } else {
2170 mapit->second += ",";
2171
2172 size_t pos = mapit->second.find_last_of("\n");
2173 if(pos == std::string::npos) pos = 0;
2174 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
2175 else mapit->second += " ";
2176
2177 mapit->second += symbol;
2178 }
2179 }
2180
2181 for (const auto& transition : pda.getReturnTransitions()) {
2182 std::string symbol;
2183
2184 //input symbol
2185 if(std::get<1>(transition.first).is_epsilon ( ) )
2186 symbol = "&epsilon;";
2187 else
2188 symbol = replace ( factory::StringDataFactory::toString ( std::get<1>(transition.first ).getSymbol ( ) ), "\"", "\\\"" );
2189
2190 symbol += " |";
2191
2192 //Pop part
2193 symbol += " " + replace ( factory::StringDataFactory::toString ( std::get<2>(transition.first ) ), "\"", "\\\"" );
2194 symbol += " ->";
2195
2196 symbol += " &epsilon;";
2197
2198 //Insert into map
2199 std::pair<int, int> key(states.find(std::get<0>(transition.first))->second, states.find(transition.second)->second);
2200 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
2201
2202 if (mapit == transitions.end()) {
2203 transitions.insert(std::make_pair(key, symbol));
2204 } else {
2205 mapit->second += ",";
2206
2207 size_t pos = mapit->second.find_last_of("\n");
2208 if(pos == std::string::npos) pos = 0;
2209 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
2210 else mapit->second += " ";
2211
2212 mapit->second += symbol;
2213 }
2214 }
2215
2216 for (const auto& transition : pda.getLocalTransitions()) {
2217 std::string symbol;
2218
2219 //input symbol
2220 if(transition.first.second.is_epsilon ( ) )
2221 symbol = "&epsilon;";
2222 else
2223 symbol = replace ( factory::StringDataFactory::toString ( transition.first.second.getSymbol ( ) ), "\"", "\\\"" );
2224
2225 symbol += " |";
2226
2227 //Pop part
2228 symbol += " &epsilon;";
2229 symbol += " ->";
2230
2231 symbol += " &epsilon;";
2232
2233 //Insert into map
2234 std::pair<int, int> key(states.find(transition.first.first)->second, states.find(transition.second)->second);
2235 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
2236
2237 if (mapit == transitions.end()) {
2238 transitions.insert(std::make_pair(key, symbol));
2239 } else {
2240 mapit->second += ",";
2241
2242 size_t pos = mapit->second.find_last_of("\n");
2243 if(pos == std::string::npos) pos = 0;
2244 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
2245 else mapit->second += " ";
2246
2247 mapit->second += symbol;
2248 }
2249 }
2250
2251 //print the map
2252 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
2253 out << transition.first.first << " -> " << transition.first.second;
2254 replaceInplace(transition.second, "\n", "\\n");
2255 out << "[label=\"" << transition.second << "\"]\n";
2256 }
2257}
2258
2259template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
2260void DotConverter::transitions(const automaton::NPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & pda, const ext::map<StateType, int>& states, ext::ostream& out) {
2261 ext::map<std::pair<int, int>, std::string> transitions;
2262
2263 for (const auto& transition : pda.getTransitions()) {
2264 std::string symbol;
2265
2266 //input symbol
2267 if (std::get<1>(transition.first).is_epsilon ( ) ) {
2268 symbol = "&epsilon;";
2269 } else {
2270 symbol = replace ( factory::StringDataFactory::toString ( std::get<1>(transition.first ).getSymbol ( ) ), "\"", "\\\"" );
2271 }
2272
2273 symbol += " |";
2274
2275 //Pop part
2276 if (std::get<2>(transition.first).empty ( )) {
2277 symbol += " &epsilon;";
2278 } else {
2279 for ( const PushdownStoreSymbolType & symb : std::get<2>(transition.first)) {
2280 symbol += " " + replace ( factory::StringDataFactory::toString ( symb ), "\"", "\\\"" );
2281 }
2282
2283 }
2284
2285 symbol += " ->";
2286
2287 //Push part
2288 if (transition.second.second.empty ( )) {
2289 symbol += " &epsilon;";
2290 } else {
2291 for ( const PushdownStoreSymbolType & symb : transition.second.second) {
2292 symbol += " " + replace ( factory::StringDataFactory::toString ( symb ), "\"", "\\\"" );
2293 }
2294
2295 }
2296
2297 //Insert into map
2298 std::pair<int, int> key(states.find(std::get<0>(transition.first))->second, states.find(transition.second.first)->second);
2299 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
2300
2301 if (mapit == transitions.end()) {
2302 transitions.insert(std::make_pair(key, symbol));
2303 } else {
2304 mapit->second += ",";
2305
2306 size_t pos = mapit->second.find_last_of("\n");
2307 if(pos == std::string::npos) pos = 0;
2308 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
2309 else mapit->second += " ";
2310
2311 mapit->second += symbol;
2312 }
2313 }
2314
2315 //print the map
2316 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
2317 out << transition.first.first << " -> " << transition.first.second;
2318 replaceInplace(transition.second, "\n", "\\n");
2319 out << "[label=\"" << transition.second << "\"]\n";
2320 }
2321}
2322
2323template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
2325 ext::map<std::pair<int, int>, std::string> transitions;
2326
2327 for (const auto& transition : pda.getTransitions()) {
2328 std::string symbol;
2329
2330 //input symbol
2331 if (std::get<1>(transition.first).is_epsilon ( )) {
2332 symbol = "&epsilon;";
2333 } else {
2334 symbol = replace ( factory::StringDataFactory::toString ( std::get<1>(transition.first ).getSymbol ( )), "\"", "\\\"" );
2335 }
2336
2337 symbol += " |";
2338
2339 //Pop part
2340 symbol += " " + replace ( factory::StringDataFactory::toString ( std::get<2>(transition.first )), "\"", "\\\"" );
2341
2342 symbol += " ->";
2343
2344 //Push part
2345 if (transition.second.second.empty ( )) {
2346 symbol += " &epsilon;";
2347 } else {
2348 for ( const PushdownStoreSymbolType & symb : transition.second.second) {
2349 symbol += " " + replace ( factory::StringDataFactory::toString ( symb ), "\"", "\\\"" );
2350 }
2351
2352 }
2353
2354 //Insert into map
2355 std::pair<int, int> key(states.find(std::get<0>(transition.first))->second, states.find(transition.second.first)->second);
2356 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
2357
2358 if (mapit == transitions.end()) {
2359 transitions.insert(std::make_pair(key, symbol));
2360 } else {
2361 mapit->second += ",";
2362
2363 size_t pos = mapit->second.find_last_of("\n");
2364 if(pos == std::string::npos) pos = 0;
2365 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
2366 else mapit->second += " ";
2367
2368 mapit->second += symbol;
2369 }
2370 }
2371
2372 //print the map
2373 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
2374 out << transition.first.first << " -> " << transition.first.second;
2375 replaceInplace(transition.second, "\n", "\\n");
2376 out << "[label=\"" << transition.second << "\"]\n";
2377 }
2378}
2379
2380template < class SymbolType, class StateType >
2381void DotConverter::transitions(const automaton::OneTapeDTM < SymbolType, StateType > & tm, const ext::map < StateType, int > & states, ext::ostream& out) {
2382 ext::map<std::pair<int, int>, std::string> transitions;
2383 for (const auto& transition : tm.getTransitions()) {
2384 std::string symbol;
2385
2386 //input symbol
2387 symbol = "(";
2388 symbol += replace ( factory::StringDataFactory::toString ( transition.first.second ), "\"", "\\\"" );
2389 symbol += ", ";
2390 symbol += replace ( factory::StringDataFactory::toString ( std::get<1>(transition.second )), "\"", "\\\"" );
2391 symbol += " ";
2392 switch(std::get<2>(transition.second)) {
2394 symbol += "&larr;";
2395 break;
2397 symbol += "&rarr;";
2398 break;
2400 symbol += "&times;";
2401 break;
2402 default:
2403 throw exception::CommonException("Unexpected shift direction");
2404 }
2405
2406 //Insert into map
2407 std::pair<int, int> key(states.find(transition.first.first)->second, states.find(std::get<0>(transition.second))->second);
2408 ext::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key);
2409
2410 if (mapit == transitions.end()) {
2411 transitions.insert(std::make_pair(key, symbol));
2412 } else {
2413 mapit->second += ",";
2414
2415 size_t pos = mapit->second.find_last_of("\n");
2416 if(pos == std::string::npos) pos = 0;
2417 if(mapit->second.size() - pos > CAPTION_LENGTH_LIMIT) mapit->second += "\n";
2418 else mapit->second += " ";
2419
2420 mapit->second += symbol;
2421 }
2422 }
2423
2424 //print the map
2425 for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) {
2426 out << transition.first.first << " -> " << transition.first.second;
2427 replaceInplace(transition.second, "\n", "\\n");
2428 out << "[label=\"" << transition.second << "\"]\n";
2429 }
2430}
2431
2432} /* namespace convert */
2433
Nondeterministic Z-Automaton in Arc-Factored Normal Form. Computation model for unranked regular tree...
Definition: ArcFactoredNondeterministicZAutomaton.h:67
const ext::set< StateType > & getFinalStates() const &
Definition: ArcFactoredNondeterministicZAutomaton.h:154
const ext::multimap< ext::variant< SymbolType, ext::pair< StateType, StateType > >, StateType > & getTransitions() const &
Definition: ArcFactoredNondeterministicZAutomaton.h:293
const ext::set< StateType > & getStates() const &
Definition: ArcFactoredNondeterministicZAutomaton.h:105
Compact nondeterministic finite automaton. Accepts regular languages. The automaton has a list of sym...
Definition: CompactNFA.h:78
const ext::set< StateType > & getFinalStates() const &
Definition: CompactNFA.h:232
const ext::multimap< ext::pair< StateType, ext::vector< SymbolType > >, StateType > & getTransitions() const &
Definition: CompactNFA.h:555
const ext::set< StateType > & getStates() const &
Definition: CompactNFA.h:183
const StateType & getInitialState() const &
Definition: CompactNFA.h:154
Deterministic finite automaton. Accepts regular languages.
Definition: DFA.h:71
const ext::set< StateType > & getFinalStates() const &
Definition: DFA.h:183
const ext::map< ext::pair< StateType, SymbolType >, StateType > & getTransitions() const &
Definition: DFA.h:473
const StateType & getInitialState() const &
Definition: DFA.h:105
const ext::set< StateType > & getStates() const &
Definition: DFA.h:134
Nondeterministic finite tree automaton without epsilon transitions. Accepts regular tree languages.
Definition: DFTA.h:74
const ext::map< ext::pair< common::ranked_symbol< SymbolType >, ext::vector< StateType > >, StateType > & getTransitions() const &
Definition: DFTA.h:289
const ext::set< StateType > & getFinalStates() const &
Definition: DFTA.h:154
const ext::set< StateType > & getStates() const &
Definition: DFTA.h:105
Deterministic pushdown automaton. Accepts subset of context free languages.
Definition: DPDA.h:78
const ext::set< StateType > & getStates() const &
Definition: DPDA.h:145
const ext::map< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, ext::vector< PushdownStoreSymbolType > >, ext::pair< StateType, ext::vector< PushdownStoreSymbolType > > > & getTransitions() const &
Definition: DPDA.h:682
const ext::set< StateType > & getFinalStates() const &
Definition: DPDA.h:194
const StateType & getInitialState() const &
Definition: DPDA.h:116
Epsilon nondeterministic finite automaton. Accepts regular languages.
Definition: EpsilonNFA.h:74
const ext::set< StateType > & getStates() const &
Definition: EpsilonNFA.h:158
const ext::set< StateType > & getFinalStates() const &
Definition: EpsilonNFA.h:207
const ext::multimap< ext::pair< StateType, common::symbol_or_epsilon< SymbolType > >, StateType > & getTransitions() const &
Definition: EpsilonNFA.h:666
const StateType & getInitialState() const &
Definition: EpsilonNFA.h:129
Epsilon nondeterministic finite tree automaton. Accepts regular tree languages.
Definition: EpsilonNFTA.h:73
const ext::set< StateType > & getFinalStates() const &
Definition: EpsilonNFTA.h:167
const ext::set< StateType > & getStates() const &
Definition: EpsilonNFTA.h:118
const ext::multimap< ext::variant< StateType, ext::pair< common::ranked_symbol< SymbolType >, ext::vector< StateType > > >, StateType > & getTransitions() const &
Definition: EpsilonNFTA.h:354
Extended nondeterministic finite automaton. Accepts regular languages. The automaton has a regular ex...
Definition: ExtendedNFA.h:80
const StateType & getInitialState() const &
Definition: ExtendedNFA.h:156
const ext::multimap< ext::pair< StateType, regexp::UnboundedRegExpStructure< SymbolType > >, StateType > & getTransitions() const &
Definition: ExtendedNFA.h:581
const ext::set< StateType > & getStates() const &
Definition: ExtendedNFA.h:185
const ext::set< StateType > & getFinalStates() const &
Definition: ExtendedNFA.h:234
Nondeterministic finite tree automaton without epsilon transitions. Accepts regular tree languages.
Definition: ExtendedNFTA.h:75
const ext::set< StateType > & getStates() const &
Definition: ExtendedNFTA.h:115
const ext::map< ext::pair< rte::FormalRTEStructure< ext::variant< SymbolType, StateType > >, ext::vector< StateType > >, ext::set< StateType > > & getTransitions() const &
Definition: ExtendedNFTA.h:314
const ext::set< StateType > & getFinalStates() const &
Definition: ExtendedNFTA.h:164
Deterministic input driven pushdown automaton. Accepts subset of context free languages.
Definition: InputDrivenDPDA.h:79
const ext::map< ext::pair< StateType, InputSymbolType >, StateType > & getTransitions() const &
Definition: InputDrivenDPDA.h:655
const ext::set< StateType > & getStates() const &
Definition: InputDrivenDPDA.h:160
const ext::set< StateType > & getFinalStates() const &
Definition: InputDrivenDPDA.h:209
const ext::map< InputSymbolType, ext::pair< ext::vector< PushdownStoreSymbolType >, ext::vector< PushdownStoreSymbolType > > > & getPushdownStoreOperations() const &
Definition: InputDrivenDPDA.h:604
const StateType & getInitialState() const &
Definition: InputDrivenDPDA.h:131
Nondeterministic input driven pushdown automaton. Accepts subset of context free languages.
Definition: InputDrivenNPDA.h:79
const ext::map< InputSymbolType, ext::pair< ext::vector< PushdownStoreSymbolType >, ext::vector< PushdownStoreSymbolType > > > & getPushdownStoreOperations() const &
Definition: InputDrivenNPDA.h:614
const ext::multimap< ext::pair< StateType, InputSymbolType >, StateType > & getTransitions() const &
Definition: InputDrivenNPDA.h:661
const ext::set< StateType > & getFinalStates() const &
Definition: InputDrivenNPDA.h:209
const StateType & getInitialState() const &
Definition: InputDrivenNPDA.h:131
const ext::set< StateType > & getStates() const &
Definition: InputDrivenNPDA.h:160
Nondeterministic finite automaton with multiple initial states. Accepts regular languages.
Definition: MultiInitialStateNFA.h:69
const ext::set< StateType > & getInitialStates() const &
Definition: MultiInitialStateNFA.h:117
const ext::set< StateType > & getStates() const &
Definition: MultiInitialStateNFA.h:166
const ext::multimap< ext::pair< StateType, SymbolType >, StateType > & getTransitions() const &
Definition: MultiInitialStateNFA.h:520
const ext::set< StateType > & getFinalStates() const &
Definition: MultiInitialStateNFA.h:215
Nondeterministic finite automaton. Accepts regular languages.
Definition: NFA.h:66
const ext::set< StateType > & getStates() const &
Definition: NFA.h:136
const StateType & getInitialState() const &
Definition: NFA.h:107
const ext::multimap< ext::pair< StateType, SymbolType >, StateType > & getTransitions() const &
Definition: NFA.h:484
const ext::set< StateType > & getFinalStates() const &
Definition: NFA.h:185
Nondeterministic finite tree automaton without epsilon transitions. Accepts regular tree languages.
Definition: NFTA.h:72
const ext::set< StateType > & getFinalStates() const &
Definition: NFTA.h:159
const ext::multimap< ext::pair< common::ranked_symbol< SymbolType >, ext::vector< StateType > >, StateType > & getTransitions() const &
Definition: NFTA.h:294
const ext::set< StateType > & getStates() const &
Definition: NFTA.h:110
Definition: NPDA.h:74
const ext::set< StateType > & getFinalStates() const &
Definition: NPDA.h:197
const StateType & getInitialState() const &
Definition: NPDA.h:119
const ext::set< StateType > & getStates() const &
Definition: NPDA.h:148
const ext::multimap< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, ext::vector< PushdownStoreSymbolType > >, ext::pair< StateType, ext::vector< PushdownStoreSymbolType > > > & getTransitions() const &
Definition: NPDA.h:644
Nondeterministic Z-Automaton. Computation model for unranked regular tree languages.
Definition: NondeterministicZAutomaton.h:68
const ext::multimap< ext::pair< ext::variant< SymbolType, StateType >, ext::vector< ext::variant< SymbolType, StateType > > >, StateType > & getTransitions() const &
Definition: NondeterministicZAutomaton.h:283
const ext::set< StateType > & getStates() const &
Definition: NondeterministicZAutomaton.h:99
const ext::set< StateType > & getFinalStates() const &
Definition: NondeterministicZAutomaton.h:148
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: NondeterministicZAutomaton.h:197
Deterministic single tape turing machine. Accepts recursive languages.
Definition: OneTapeDTM.h:71
const StateType & getInitialState() const &
Definition: OneTapeDTM.h:108
const ext::set< StateType > & getFinalStates() const &
Definition: OneTapeDTM.h:186
const ext::map< ext::pair< StateType, SymbolType >, ext::tuple< StateType, SymbolType, Shift > > & getTransitions() const &
Definition: OneTapeDTM.h:526
const ext::set< StateType > & getStates() const &
Definition: OneTapeDTM.h:137
Deterministic real time height deterministic pushdown automaton. Accepts subset of context free langu...
Definition: RealTimeHeightDeterministicDPDA.h:89
const StateType & getInitialState() const &
Definition: RealTimeHeightDeterministicDPDA.h:149
const ext::map< ext::pair< StateType, common::symbol_or_epsilon< InputSymbolType > >, ext::pair< StateType, PushdownStoreSymbolType > > & getCallTransitions() const &
Definition: RealTimeHeightDeterministicDPDA.h:1062
const ext::map< ext::pair< StateType, common::symbol_or_epsilon< InputSymbolType > >, StateType > & getLocalTransitions() const &
Definition: RealTimeHeightDeterministicDPDA.h:1082
const ext::map< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, PushdownStoreSymbolType >, StateType > & getReturnTransitions() const &
Definition: RealTimeHeightDeterministicDPDA.h:1072
const ext::set< StateType > & getStates() const &
Definition: RealTimeHeightDeterministicDPDA.h:178
const ext::set< StateType > & getFinalStates() const &
Definition: RealTimeHeightDeterministicDPDA.h:227
Nondeterministic real time height deterministic pushdown automaton. Accepts subset of context free la...
Definition: RealTimeHeightDeterministicNPDA.h:76
const ext::set< StateType > & getInitialStates() const &
Definition: RealTimeHeightDeterministicNPDA.h:175
const ext::set< StateType > & getStates() const &
Definition: RealTimeHeightDeterministicNPDA.h:126
const ext::multimap< ext::pair< StateType, common::symbol_or_epsilon< InputSymbolType > >, StateType > & getLocalTransitions() const &
Definition: RealTimeHeightDeterministicNPDA.h:1004
const ext::multimap< ext::pair< StateType, common::symbol_or_epsilon< InputSymbolType > >, ext::pair< StateType, PushdownStoreSymbolType > > & getCallTransitions() const &
Definition: RealTimeHeightDeterministicNPDA.h:984
const ext::set< StateType > & getFinalStates() const &
Definition: RealTimeHeightDeterministicNPDA.h:224
const ext::multimap< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, PushdownStoreSymbolType >, StateType > & getReturnTransitions() const &
Definition: RealTimeHeightDeterministicNPDA.h:994
Deterministic pushdown automaton requiring a symbol pop from pushdown store on each transition use....
Definition: SinglePopDPDA.h:78
const StateType & getInitialState() const &
Definition: SinglePopDPDA.h:116
const ext::set< StateType > & getFinalStates() const &
Definition: SinglePopDPDA.h:194
const ext::set< StateType > & getStates() const &
Definition: SinglePopDPDA.h:145
const ext::map< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, PushdownStoreSymbolType >, ext::pair< StateType, ext::vector< PushdownStoreSymbolType > > > & getTransitions() const &
Definition: SinglePopDPDA.h:639
Definition: SinglePopNPDA.h:72
const StateType & getInitialState() const &
Definition: SinglePopNPDA.h:110
const ext::multimap< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, PushdownStoreSymbolType >, ext::pair< StateType, ext::vector< PushdownStoreSymbolType > > > & getTransitions() const &
Definition: SinglePopNPDA.h:617
const ext::set< StateType > & getStates() const &
Definition: SinglePopNPDA.h:139
const ext::set< StateType > & getFinalStates() const &
Definition: SinglePopNPDA.h:188
Nondeterministic unordered finite tree automaton without epsilon transitions. Accepts regular tree la...
Definition: UnorderedNFTA.h:72
const ext::set< StateType > & getStates() const &
Definition: UnorderedNFTA.h:110
const ext::set< StateType > & getFinalStates() const &
Definition: UnorderedNFTA.h:159
const ext::multimap< ext::pair< common::ranked_symbol< SymbolType >, ext::multiset< StateType > >, StateType > & getTransitions() const &
Definition: UnorderedNFTA.h:294
Deterministic visibly pushdown automaton. Accepts subset of context free languages.
Definition: VisiblyPushdownDPDA.h:86
const ext::map< ext::tuple< StateType, InputSymbolType, PushdownStoreSymbolType >, StateType > & getReturnTransitions() const &
Definition: VisiblyPushdownDPDA.h:899
const ext::map< ext::pair< StateType, InputSymbolType >, StateType > & getLocalTransitions() const &
Definition: VisiblyPushdownDPDA.h:909
const ext::set< StateType > & getFinalStates() const &
Definition: VisiblyPushdownDPDA.h:224
const ext::map< ext::pair< StateType, InputSymbolType >, ext::pair< StateType, PushdownStoreSymbolType > > & getCallTransitions() const &
Definition: VisiblyPushdownDPDA.h:889
const ext::set< StateType > & getStates() const &
Definition: VisiblyPushdownDPDA.h:175
const StateType & getInitialState() const &
Definition: VisiblyPushdownDPDA.h:146
Nondeterministic visibly pushdown automaton. Accepts subset of context free languages.
Definition: VisiblyPushdownNPDA.h:81
const ext::set< StateType > & getInitialStates() const &
Definition: VisiblyPushdownNPDA.h:131
const ext::set< StateType > & getStates() const &
Definition: VisiblyPushdownNPDA.h:180
const ext::multimap< ext::pair< StateType, InputSymbolType >, StateType > & getLocalTransitions() const &
Definition: VisiblyPushdownNPDA.h:884
const ext::set< StateType > & getFinalStates() const &
Definition: VisiblyPushdownNPDA.h:229
const ext::multimap< ext::tuple< StateType, InputSymbolType, PushdownStoreSymbolType >, StateType > & getReturnTransitions() const &
Definition: VisiblyPushdownNPDA.h:874
const ext::multimap< ext::pair< StateType, InputSymbolType >, ext::pair< StateType, PushdownStoreSymbolType > > & getCallTransitions() const &
Definition: VisiblyPushdownNPDA.h:864
static void convertInternal(ext::ostream &oss, const rte::FormalRTE< SymbolType > &rte, const std::string &nodePrefix="")
Definition: DotConverterRTEPart.hxx:31
static void convertInternal(ext::ostream &oss, const tree::RankedTree< SymbolType > &tree)
Definition: DotConverterTreePart.hxx:24
Definition: DotConverter.h:58
static std::string convert(const T &automaton)
Definition: DotConverter.h:212
static void convert(ext::ostream &out, const automaton::DFA< SymbolType, StateType > &a)
Definition: DotConverter.h:318
Basic exception from which all other exceptions are derived.
Definition: CommonException.h:21
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
R & at(const T &key, R &defaultValue)
Definition: map.hpp:163
std::pair< iterator, bool > insert(const T &key, const R &value)
Insert variant with explicit key and value parameters.
Definition: map.hpp:118
auto end() &
Inherited behavior of end for non-const instance.
Definition: map.hpp:215
typename std::map< T, R, Cmp, Alloc >::iterator iterator
The iterator type is inheried.
Definition: map.hpp:101
Class extending the multimap class from the standard library. Original reason is to allow printing of...
Definition: multimap.hpp:48
iterator insert(const T &key, const R &value)
Insert variant with explicit key and value parameters.
Definition: multimap.hpp:118
Definition: ostream.h:14
Definition: sstream.h:15
std::string str() const &
Definition: sstream.cpp:29
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
Definition: set.hpp:44
Implementation of the variant class allowing to store any type of those listed in the template parame...
Definition: variant.hpp:98
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
static std::string toString(const T &data)
Definition: StringDataFactory.hpp:89
Formal regular tree expression represents regular tree expression. It describes regular tree language...
Definition: FormalRTE.h:71
Tree structure represented in its natural representation. The representation is so called ranked,...
Definition: RankedTree.h:72
typename T::StateType StateType
Definition: ToGrammarLeftRG.h:64
int i
Definition: AllEpsilonClosure.h:118
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
Definition: ToGrammar.h:31
Definition: converterCommon.hpp:8
auto replaceInplace
Definition: converterCommon.hpp:10
auto replace
Definition: converterCommon.hpp:19
ContainerType< ResType > transform(const ContainerType< InType, Ts ... > &in, Callback transform)
In container tranformation of all elements according to the tranform.
Definition: algorithm.hpp:150
std::string to_string(const T &value)
To string method designated for objects that can be casted to string.
Definition: string.hpp:131
constexpr auto make_tuple(Elements &&... args)
Helper of extended tuple construction. The tuple is constructed from values pack, types are deduced.
Definition: tuple.hpp:203
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
string::LinearString< char > stringFrom(const std::string &string)
Definition: String.cpp:10