Skip to content
Snippets Groups Projects
Commit acb5c1e5 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

make RHPDAToPDA real inverse to PDAToRHPDA

by removing all transitions that use BottomOfTheStack symbol
parent bd392ea0
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,8 @@
#include <queue>
#include <iostream>
 
#include <std/map.hpp>
namespace automaton {
 
automaton::DPDA RHPDAToPDA::convert( const automaton::RealTimeHeightDeterministicDPDA & pda ) {
......@@ -30,7 +32,6 @@ automaton::DPDA RHPDAToPDA::convert( const automaton::RealTimeHeightDeterministi
if(std::get<1>(transition.first).is<string::Epsilon>()) {
auto& epsT = epsilonTransitions[std::get<0>(transition.first)];
const auto& to = transition.second;
if(to.second.getData() == alphabet::BottomOfTheStackSymbol::BOTTOM_OF_THE_STACK) throw exception::AlibException("Cannot convert");
epsT.insert(std::make_tuple(std::vector<alphabet::Symbol>{}, to.first, std::vector<alphabet::Symbol>{to.second}));
} else {
auto& readT = readingTransitions[std::make_tuple(std::get<0>(transition.first), std::get<1>(transition.first).get<alphabet::Symbol>(), std::vector<alphabet::Symbol>{})];
......@@ -52,10 +53,10 @@ automaton::DPDA RHPDAToPDA::convert( const automaton::RealTimeHeightDeterministi
}
 
for(const auto& transition : pda.getReturnTransitions()) {
if(std::get<2>(transition.first).getData() == alphabet::BottomOfTheStackSymbol::BOTTOM_OF_THE_STACK) continue;
if(std::get<1>(transition.first).is<string::Epsilon>()) {
auto& epsT = epsilonTransitions[std::get<0>(transition.first)];
const auto& to = transition.second;
if(std::get<2>(transition.first).getData() == alphabet::BottomOfTheStackSymbol::BOTTOM_OF_THE_STACK) throw exception::AlibException("Cannot convert");
epsT.insert(std::make_tuple(std::vector<alphabet::Symbol>{std::get<2>(transition.first)}, to, std::vector<alphabet::Symbol>{}));
} else {
auto& readT = readingTransitions[std::make_tuple(std::get<0>(transition.first), std::get<1>(transition.first).get<alphabet::Symbol>(), std::vector<alphabet::Symbol>{std::get<2>(transition.first)})];
......@@ -98,6 +99,7 @@ automaton::DPDA RHPDAToPDA::convert( const automaton::RealTimeHeightDeterministi
res.setInputSymbols(pda.getInputAlphabet());
res.setStackSymbols(pda.getStackAlphabet());
res.removeStackSymbol(alphabet::Symbol { alphabet::BottomOfTheStackSymbol::BOTTOM_OF_THE_STACK });
 
for(const auto& st : readingTransitions) {
for(const auto& to : st.second) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment