diff --git a/alib2algo/src/automaton/transform/PDAToRHPDA.cpp b/alib2algo/src/automaton/transform/PDAToRHPDA.cpp index c1e6d7b0b859e9851839bbaaf8fdde8b960f92cc..5b050b24264cc4a3b73d1a78b5501c7bf7b07e40 100644 --- a/alib2algo/src/automaton/transform/PDAToRHPDA.cpp +++ b/alib2algo/src/automaton/transform/PDAToRHPDA.cpp @@ -36,9 +36,9 @@ automaton::RealTimeHeightDeterministicNPDA < > PDAToRHPDA::convert ( const autom auto PDAToRHPDARealTimeHeightDeterministicNPDA = PDAToRHPDA::RegistratorWrapper < automaton::RealTimeHeightDeterministicNPDA < >, automaton::RealTimeHeightDeterministicNPDA < > > ( PDAToRHPDA::convert ); automaton::RealTimeHeightDeterministicDPDA < > PDAToRHPDA::convert ( const automaton::DPDA < > & pda ) { - label::Label q0 = common::createUnique ( label::InitialStateLabel::instance < label::Label > ( ), pda.getStates ( ) ); + DefaultStateType q0 = common::createUnique ( label::InitialStateLabel::instance < DefaultStateType > ( ), pda.getStates ( ) ); - RealTimeHeightDeterministicDPDA < > res ( q0, alphabet::BottomOfTheStackSymbol::instance < alphabet::Symbol > ( ) ); + RealTimeHeightDeterministicDPDA < > res ( q0, alphabet::BottomOfTheStackSymbol::instance < DefaultSymbolType > ( ) ); res.setInputAlphabet ( pda.getInputAlphabet ( ) ); @@ -46,8 +46,8 @@ automaton::RealTimeHeightDeterministicDPDA < > PDAToRHPDA::convert ( const autom res.addState ( state ); res.setFinalStates ( pda.getFinalStates ( ) ); - std::set < alphabet::Symbol > pushdownStoreAlphabet = pda.getPushdownStoreAlphabet ( ); - pushdownStoreAlphabet.insert ( alphabet::BottomOfTheStackSymbol::instance < alphabet::Symbol > ( ) ); + std::set < DefaultSymbolType > pushdownStoreAlphabet = pda.getPushdownStoreAlphabet ( ); + pushdownStoreAlphabet.insert ( alphabet::BottomOfTheStackSymbol::instance < DefaultSymbolType > ( ) ); res.setPushdownStoreAlphabet ( pushdownStoreAlphabet ); res.addCallTransition ( q0, pda.getInitialState ( ), pda.getInitialSymbol ( ) ); @@ -68,13 +68,13 @@ automaton::RealTimeHeightDeterministicDPDA < > PDAToRHPDA::convert ( const autom int popPushIndex = 0; int popPushSymbols = std::get < 2 > ( transition.first ).size ( ) + to.second.size ( ); - label::Label lastUS = common::createUnique ( label::Label ( us + std::to_string ( i ) ), res.getStates ( ) ); - for ( const alphabet::Symbol & pop :std::get < 2 > ( transition.first ) ) { - label::Label fromState = ( popPushIndex == 0 ) ? std::get < 0 > ( transition.first ) : lastUS; + DefaultStateType lastUS = common::createUnique ( DefaultStateType ( us + std::to_string ( i ) ), res.getStates ( ) ); + for ( const DefaultSymbolType & pop :std::get < 2 > ( transition.first ) ) { + DefaultStateType fromState = ( popPushIndex == 0 ) ? std::get < 0 > ( transition.first ) : lastUS; - if ( popPushIndex != 0 ) lastUS = common::createUnique ( label::Label ( us + std::to_string ( ++i ) ), res.getStates ( ) ); + if ( popPushIndex != 0 ) lastUS = common::createUnique ( DefaultStateType ( us + std::to_string ( ++i ) ), res.getStates ( ) ); - label::Label toState = ( popPushIndex == popPushSymbols - 1 ) ? to.first : lastUS; + DefaultStateType toState = ( popPushIndex == popPushSymbols - 1 ) ? to.first : lastUS; res.addState ( fromState ); res.addState ( toState ); @@ -86,12 +86,12 @@ automaton::RealTimeHeightDeterministicDPDA < > PDAToRHPDA::convert ( const autom popPushIndex++; } - for ( const alphabet::Symbol & push : std::make_reverse ( to.second ) ) { - label::Label fromState = ( popPushIndex == 0 ) ? std::get < 0 > ( transition.first ) : lastUS; + for ( const DefaultSymbolType & push : std::make_reverse ( to.second ) ) { + DefaultStateType fromState = ( popPushIndex == 0 ) ? std::get < 0 > ( transition.first ) : lastUS; - if ( popPushIndex != 0 ) lastUS = common::createUnique ( label::Label ( us + std::to_string ( ++i ) ), res.getStates ( ) ); + if ( popPushIndex != 0 ) lastUS = common::createUnique ( DefaultStateType ( us + std::to_string ( ++i ) ), res.getStates ( ) ); - label::Label toState = ( popPushIndex == popPushSymbols - 1 ) ? to.first : lastUS; + DefaultStateType toState = ( popPushIndex == popPushSymbols - 1 ) ? to.first : lastUS; res.addState ( fromState ); res.addState ( toState ); @@ -112,16 +112,16 @@ automaton::RealTimeHeightDeterministicDPDA < > PDAToRHPDA::convert ( const autom auto PDAToRHPDADPDA = PDAToRHPDA::RegistratorWrapper < automaton::RealTimeHeightDeterministicDPDA < >, automaton::DPDA < > > ( PDAToRHPDA::convert ); automaton::RealTimeHeightDeterministicNPDA < > PDAToRHPDA::convert ( const automaton::NPDA < > & pda ) { - RealTimeHeightDeterministicNPDA < > res ( alphabet::BottomOfTheStackSymbol::instance < alphabet::Symbol > ( ) ); + RealTimeHeightDeterministicNPDA < > res ( alphabet::BottomOfTheStackSymbol::instance < DefaultSymbolType > ( ) ); res.setInputAlphabet ( pda.getInputAlphabet ( ) ); res.setStates ( pda.getStates ( ) ); res.setFinalStates ( pda.getFinalStates ( ) ); - std::set < alphabet::Symbol > pushdownStoreAlphabet = pda.getPushdownStoreAlphabet ( ); - pushdownStoreAlphabet.insert ( alphabet::BottomOfTheStackSymbol::instance < alphabet::Symbol > ( ) ); + std::set < DefaultSymbolType > pushdownStoreAlphabet = pda.getPushdownStoreAlphabet ( ); + pushdownStoreAlphabet.insert ( alphabet::BottomOfTheStackSymbol::instance < DefaultSymbolType > ( ) ); res.setPushdownStoreAlphabet ( pushdownStoreAlphabet ); - label::Label q0 = common::createUnique ( label::InitialStateLabel::instance < label::Label > ( ), res.getStates ( ) ); + DefaultStateType q0 = common::createUnique ( label::InitialStateLabel::instance < DefaultStateType > ( ), res.getStates ( ) ); res.addState ( q0 ); res.addInitialState ( q0 ); @@ -142,13 +142,13 @@ automaton::RealTimeHeightDeterministicNPDA < > PDAToRHPDA::convert ( const autom int popPushIndex = 0; int popPushSymbols = std::get < 2 > ( transition.first ).size ( ) + to.second.size ( ); - label::Label lastUS = common::createUnique ( label::Label ( us + std::to_string ( i ) ), res.getStates ( ) ); - std::for_each ( std::get < 2 > ( transition.first ).begin ( ), std::get < 2 > ( transition.first ).end ( ), [&] ( const alphabet::Symbol & pop ) { - label::Label fromState = ( popPushIndex == 0 ) ? std::get < 0 > ( transition.first ) : lastUS; + DefaultStateType lastUS = common::createUnique ( DefaultStateType ( us + std::to_string ( i ) ), res.getStates ( ) ); + std::for_each ( std::get < 2 > ( transition.first ).begin ( ), std::get < 2 > ( transition.first ).end ( ), [&] ( const DefaultSymbolType & pop ) { + DefaultStateType fromState = ( popPushIndex == 0 ) ? std::get < 0 > ( transition.first ) : lastUS; - if ( popPushIndex != 0 ) lastUS = common::createUnique ( label::Label ( us + std::to_string ( ++i ) ), res.getStates ( ) ); + if ( popPushIndex != 0 ) lastUS = common::createUnique ( DefaultStateType ( us + std::to_string ( ++i ) ), res.getStates ( ) ); - label::Label toState = ( popPushIndex == popPushSymbols - 1 ) ? to.first : lastUS; + DefaultStateType toState = ( popPushIndex == popPushSymbols - 1 ) ? to.first : lastUS; res.addState ( fromState ); res.addState ( toState ); @@ -160,12 +160,12 @@ automaton::RealTimeHeightDeterministicNPDA < > PDAToRHPDA::convert ( const autom popPushIndex++; } ); - std::for_each ( to.second.rbegin ( ), to.second.rend ( ), [&] ( const alphabet::Symbol & push ) { - label::Label fromState = ( popPushIndex == 0 ) ? std::get < 0 > ( transition.first ) : lastUS; + std::for_each ( to.second.rbegin ( ), to.second.rend ( ), [&] ( const DefaultSymbolType & push ) { + DefaultStateType fromState = ( popPushIndex == 0 ) ? std::get < 0 > ( transition.first ) : lastUS; - if ( popPushIndex != 0 ) lastUS = common::createUnique ( label::Label ( us + std::to_string ( ++i ) ), res.getStates ( ) ); + if ( popPushIndex != 0 ) lastUS = common::createUnique ( DefaultStateType ( us + std::to_string ( ++i ) ), res.getStates ( ) ); - label::Label toState = ( popPushIndex == popPushSymbols - 1 ) ? to.first : lastUS; + DefaultStateType toState = ( popPushIndex == popPushSymbols - 1 ) ? to.first : lastUS; res.addState ( fromState ); res.addState ( toState ); @@ -189,10 +189,11 @@ automaton::Automaton PDAToRHPDA::convert ( const Automaton & automaton ) { return dispatch ( automaton.getData ( ) ); } -} +} /* namespace automaton */ namespace alib { auto RealTimeHeightDeterministicDPDAFromDPDA = castApi::CastRegister < automaton::RealTimeHeightDeterministicDPDA < >, automaton::DPDA < > > ( automaton::PDAToRHPDA::convert ); auto RealTimeHeightDeterministicNPDAFromNPDA = castApi::CastRegister < automaton::RealTimeHeightDeterministicNPDA < >, automaton::NPDA < > > ( automaton::PDAToRHPDA::convert ); -} + +} /* namespace alib */ diff --git a/alib2algo/src/automaton/transform/PDAToRHPDA.h b/alib2algo/src/automaton/transform/PDAToRHPDA.h index 932f0e78bcd0f0615a7f2959cbcfdedb54b00a9c..33188bf941170cdce636d6ec5898af9e8ee1adeb 100644 --- a/alib2algo/src/automaton/transform/PDAToRHPDA.h +++ b/alib2algo/src/automaton/transform/PDAToRHPDA.h @@ -31,6 +31,6 @@ public: static automaton::Automaton convert( const automaton::Automaton & automaton ); }; -} +} /* namespace automaton */ #endif /* PDA_TO_RHPDA_H_ */ diff --git a/alib2algo/src/automaton/transform/RHPDAToPDA.cpp b/alib2algo/src/automaton/transform/RHPDAToPDA.cpp index aaa663cf717ad4155bbedac357b8c07a796d3d24..550d7ffa5472fb5acb8889e5787aed384b264257 100644 --- a/alib2algo/src/automaton/transform/RHPDAToPDA.cpp +++ b/alib2algo/src/automaton/transform/RHPDAToPDA.cpp @@ -23,7 +23,7 @@ namespace automaton { template < class T > -void constructTransitions ( const std::tuple < label::Label, alphabet::Symbol, std::vector < alphabet::Symbol > > & stFirst, const std::map < label::Label, std::set < std::tuple < std::vector < alphabet::Symbol >, label::Label, std::vector < alphabet::Symbol > > > > & epsilonTransitions, const label::Label & toState, std::vector < alphabet::Symbol > pops, std::vector < alphabet::Symbol > pushes, T & res ) { +void constructTransitions ( const std::tuple < DefaultStateType, DefaultSymbolType, std::vector < DefaultSymbolType > > & stFirst, const std::map < DefaultStateType, std::set < std::tuple < std::vector < DefaultSymbolType >, DefaultStateType, std::vector < DefaultSymbolType > > > > & epsilonTransitions, const DefaultStateType & toState, std::vector < DefaultSymbolType > pops, std::vector < DefaultSymbolType > pushes, T & res ) { auto epsIter = epsilonTransitions.find ( toState ); if ( ( epsIter != epsilonTransitions.end ( ) ) && !epsIter->second.empty ( ) ) { @@ -36,8 +36,8 @@ void constructTransitions ( const std::tuple < label::Label, alphabet::Symbol, s constructTransitions ( stFirst, epsilonTransitions, std::get < 1 > ( epsilonT ), std::move ( pops ), std::move ( pushes ), res ); } else { for ( const auto & epsilonT : epsIter->second ) { - std::vector < alphabet::Symbol > popsCopy = pops; - std::vector < alphabet::Symbol > pushesCopy = pushes; + std::vector < DefaultSymbolType > popsCopy = pops; + std::vector < DefaultSymbolType > pushesCopy = pushes; popsCopy.insert ( popsCopy.end ( ), std::get < 0 > ( epsilonT ).begin ( ), std::get < 0 > ( epsilonT ).end ( ) ); pushesCopy.insert ( pushesCopy.begin ( ), std::get < 2 > ( epsilonT ).rbegin ( ), std::get < 2 > ( epsilonT ).rend ( ) ); @@ -54,44 +54,44 @@ void constructTransitions ( const std::tuple < label::Label, alphabet::Symbol, s } automaton::DPDA < > RHPDAToPDA::convert ( const automaton::RealTimeHeightDeterministicDPDA < > & pda ) { - std::map < std::tuple < label::Label, alphabet::Symbol, std::vector < alphabet::Symbol > >, std::set < std::pair < label::Label, std::vector < alphabet::Symbol > > > > readingTransitions; - std::map < label::Label, std::set < std::tuple < std::vector < alphabet::Symbol >, label::Label, std::vector < alphabet::Symbol > > > > epsilonTransitions; + std::map < std::tuple < DefaultStateType, DefaultSymbolType, std::vector < DefaultSymbolType > >, std::set < std::pair < DefaultStateType, std::vector < DefaultSymbolType > > > > readingTransitions; + std::map < DefaultStateType, std::set < std::tuple < std::vector < DefaultSymbolType >, DefaultStateType, std::vector < DefaultSymbolType > > > > epsilonTransitions; for ( const auto & transition : pda.getCallTransitions ( ) ) { - if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) { + if ( std::get < 1 > ( transition.first ).is < DefaultEpsilonType > ( ) ) { auto & epsT = epsilonTransitions[std::get < 0 > ( transition.first )]; const auto & to = transition.second; - epsT.insert ( std::make_tuple ( std::vector < alphabet::Symbol > { }, to.first, std::vector < alphabet::Symbol > { to.second } ) ); + epsT.insert ( std::make_tuple ( std::vector < DefaultSymbolType > { }, to.first, std::vector < DefaultSymbolType > { 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 > { } )]; + auto & readT = readingTransitions[std::make_tuple ( std::get < 0 > ( transition.first ), std::get < 1 > ( transition.first ).get < DefaultSymbolType > ( ), std::vector < DefaultSymbolType > { } )]; const auto & to = transition.second; - readT.insert ( std::make_pair ( to.first, std::vector < alphabet::Symbol > { to.second } ) ); + readT.insert ( std::make_pair ( to.first, std::vector < DefaultSymbolType > { to.second } ) ); } } for ( const auto & transition : pda.getLocalTransitions ( ) ) { - if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) { + if ( std::get < 1 > ( transition.first ).is < DefaultEpsilonType > ( ) ) { auto & epsT = epsilonTransitions[std::get < 0 > ( transition.first )]; const auto & to = transition.second; - epsT.insert ( std::make_tuple ( std::vector < alphabet::Symbol > { }, to, std::vector < alphabet::Symbol > { } ) ); + epsT.insert ( std::make_tuple ( std::vector < DefaultSymbolType > { }, to, std::vector < DefaultSymbolType > { } ) ); } else { - auto & readT = readingTransitions[std::make_tuple ( std::get < 0 > ( transition.first ), std::get < 1 > ( transition.first ).get < alphabet::Symbol > ( ), std::vector < alphabet::Symbol > { } )]; + auto & readT = readingTransitions[std::make_tuple ( std::get < 0 > ( transition.first ), std::get < 1 > ( transition.first ).get < DefaultSymbolType > ( ), std::vector < DefaultSymbolType > { } )]; const auto & to = transition.second; - readT.insert ( std::make_pair ( to, std::vector < alphabet::Symbol > { } ) ); + readT.insert ( std::make_pair ( to, std::vector < DefaultSymbolType > { } ) ); } } for ( const auto & transition : pda.getReturnTransitions ( ) ) { - if ( std::get < 2 > ( transition.first ) == alphabet::BottomOfTheStackSymbol::instance < alphabet::Symbol > ( ) ) continue; + if ( std::get < 2 > ( transition.first ) == alphabet::BottomOfTheStackSymbol::instance < DefaultSymbolType > ( ) ) continue; - if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) { + if ( std::get < 1 > ( transition.first ).is < DefaultEpsilonType > ( ) ) { auto & epsT = epsilonTransitions[std::get < 0 > ( transition.first )]; const auto & to = transition.second; - epsT.insert ( std::make_tuple ( std::vector < alphabet::Symbol > { std::get < 2 > ( transition.first ) }, to, std::vector < alphabet::Symbol > { } ) ); + epsT.insert ( std::make_tuple ( std::vector < DefaultSymbolType > { std::get < 2 > ( transition.first ) }, to, std::vector < DefaultSymbolType > { } ) ); } 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 ) } )]; + auto & readT = readingTransitions[std::make_tuple ( std::get < 0 > ( transition.first ), std::get < 1 > ( transition.first ).get < DefaultSymbolType > ( ), std::vector < DefaultSymbolType > { std::get < 2 > ( transition.first ) } )]; const auto & to = transition.second; - readT.insert ( std::make_pair ( to, std::vector < alphabet::Symbol > { } ) ); + readT.insert ( std::make_pair ( to, std::vector < DefaultSymbolType > { } ) ); } } @@ -115,10 +115,10 @@ automaton::DPDA < > RHPDAToPDA::convert ( const automaton::RealTimeHeightDetermi const auto & st = * epsilonTransitions[pda.getInitialState ( )].begin ( ); - std::vector < alphabet::Symbol > pops ( std::get < 0 > ( st ).begin ( ), std::get < 0 > ( st ).end ( ) ); - std::vector < alphabet::Symbol > pushes ( std::get < 2 > ( st ).rbegin ( ), std::get < 2 > ( st ).rend ( ) ); + std::vector < DefaultSymbolType > pops ( std::get < 0 > ( st ).begin ( ), std::get < 0 > ( st ).end ( ) ); + std::vector < DefaultSymbolType > pushes ( std::get < 2 > ( st ).rbegin ( ), std::get < 2 > ( st ).rend ( ) ); - label::Label toState = std::get < 1 > ( st ); + DefaultStateType toState = std::get < 1 > ( st ); while ( !epsilonTransitions[toState].empty ( ) ) { const auto & epsilonT = * epsilonTransitions[toState].begin ( ); @@ -142,8 +142,8 @@ automaton::DPDA < > RHPDAToPDA::convert ( const automaton::RealTimeHeightDetermi for ( const auto & transition : readingTransitions ) for ( const auto & to : transition.second ) { - pops = std::vector < alphabet::Symbol > ( std::get < 2 > ( transition.first ).begin ( ), std::get < 2 > ( transition.first ).end ( ) ); - pushes = std::vector < alphabet::Symbol > ( to.second.rbegin ( ), to.second.rend ( ) ); + pops = std::vector < DefaultSymbolType > ( std::get < 2 > ( transition.first ).begin ( ), std::get < 2 > ( transition.first ).end ( ) ); + pushes = std::vector < DefaultSymbolType > ( to.second.rbegin ( ), to.second.rend ( ) ); constructTransitions ( transition.first, epsilonTransitions, to.first, std::move ( pops ), std::move ( pushes ), res ); } @@ -157,55 +157,55 @@ auto RHPDAToPDARealTimeHeightDeterministicDPDA = RHPDAToPDA::RegistratorWrapper // This may not work correctly -- generation of initial state and initial symbol automaton::NPDA < > RHPDAToPDA::convert ( const automaton::RealTimeHeightDeterministicNPDA < > & pda ) { - std::map < std::tuple < label::Label, alphabet::Symbol, std::vector < alphabet::Symbol > >, std::set < std::pair < label::Label, std::vector < alphabet::Symbol > > > > readingTransitions; - std::map < label::Label, std::set < std::tuple < std::vector < alphabet::Symbol >, label::Label, std::vector < alphabet::Symbol > > > > epsilonTransitions; + std::map < std::tuple < DefaultStateType, DefaultSymbolType, std::vector < DefaultSymbolType > >, std::set < std::pair < DefaultStateType, std::vector < DefaultSymbolType > > > > readingTransitions; + std::map < DefaultStateType, std::set < std::tuple < std::vector < DefaultSymbolType >, DefaultStateType, std::vector < DefaultSymbolType > > > > epsilonTransitions; for ( const auto & transition : pda.getCallTransitions ( ) ) { - if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) { + if ( std::get < 1 > ( transition.first ).is < DefaultEpsilonType > ( ) ) { auto & epsT = epsilonTransitions[std::get < 0 > ( transition.first )]; for ( const auto & to : transition.second ) { - epsT.insert ( std::make_tuple ( std::vector < alphabet::Symbol > { }, to.first, std::vector < alphabet::Symbol > { to.second } ) ); + epsT.insert ( std::make_tuple ( std::vector < DefaultSymbolType > { }, to.first, std::vector < DefaultSymbolType > { 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 > { } )]; + auto & readT = readingTransitions[std::make_tuple ( std::get < 0 > ( transition.first ), std::get < 1 > ( transition.first ).get < DefaultSymbolType > ( ), std::vector < DefaultSymbolType > { } )]; for ( const auto & to : transition.second ) { - readT.insert ( std::make_pair ( to.first, std::vector < alphabet::Symbol > { to.second } ) ); + readT.insert ( std::make_pair ( to.first, std::vector < DefaultSymbolType > { to.second } ) ); } } } for ( const auto & transition : pda.getLocalTransitions ( ) ) { - if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) { + if ( std::get < 1 > ( transition.first ).is < DefaultEpsilonType > ( ) ) { auto & epsT = epsilonTransitions[std::get < 0 > ( transition.first )]; for ( const auto & to : transition.second ) { - epsT.insert ( std::make_tuple ( std::vector < alphabet::Symbol > { }, to, std::vector < alphabet::Symbol > { } ) ); + epsT.insert ( std::make_tuple ( std::vector < DefaultSymbolType > { }, to, std::vector < DefaultSymbolType > { } ) ); } } else { - auto & readT = readingTransitions[std::make_tuple ( std::get < 0 > ( transition.first ), std::get < 1 > ( transition.first ).get < alphabet::Symbol > ( ), std::vector < alphabet::Symbol > { } )]; + auto & readT = readingTransitions[std::make_tuple ( std::get < 0 > ( transition.first ), std::get < 1 > ( transition.first ).get < DefaultSymbolType > ( ), std::vector < DefaultSymbolType > { } )]; for ( const auto & to : transition.second ) { - readT.insert ( std::make_pair ( to, std::vector < alphabet::Symbol > { } ) ); + readT.insert ( std::make_pair ( to, std::vector < DefaultSymbolType > { } ) ); } } } for ( const auto & transition : pda.getReturnTransitions ( ) ) { - if ( std::get < 2 > ( transition.first ) == alphabet::BottomOfTheStackSymbol::instance < alphabet::Symbol > ( ) ) continue; + if ( std::get < 2 > ( transition.first ) == alphabet::BottomOfTheStackSymbol::instance < DefaultSymbolType > ( ) ) continue; - if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) { + if ( std::get < 1 > ( transition.first ).is < DefaultEpsilonType > ( ) ) { auto & epsT = epsilonTransitions[std::get < 0 > ( transition.first )]; for ( const auto & to : transition.second ) { - epsT.insert ( std::make_tuple ( std::vector < alphabet::Symbol > { std::get < 2 > ( transition.first ) }, to, std::vector < alphabet::Symbol > { } ) ); + epsT.insert ( std::make_tuple ( std::vector < DefaultSymbolType > { std::get < 2 > ( transition.first ) }, to, std::vector < DefaultSymbolType > { } ) ); } } 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 ) } )]; + auto & readT = readingTransitions[std::make_tuple ( std::get < 0 > ( transition.first ), std::get < 1 > ( transition.first ).get < DefaultSymbolType > ( ), std::vector < DefaultSymbolType > { std::get < 2 > ( transition.first ) } )]; for ( const auto & to : transition.second ) { - readT.insert ( std::make_pair ( to, std::vector < alphabet::Symbol > { } ) ); + readT.insert ( std::make_pair ( to, std::vector < DefaultSymbolType > { } ) ); } } } @@ -222,7 +222,7 @@ automaton::NPDA < > RHPDAToPDA::convert ( const automaton::RealTimeHeightDetermi if ( pda.getInitialStates ( ).size ( ) != 1 ) throw exception::CommonException ( "Cannot convert" ); - const label::Label & initialState = * pda.getInitialStates ( ).begin ( ); + const DefaultStateType & initialState = * pda.getInitialStates ( ).begin ( ); if ( epsilonTransitions[initialState].empty ( ) ) throw exception::CommonException ( "Cannot convert" ); @@ -231,10 +231,10 @@ automaton::NPDA < > RHPDAToPDA::convert ( const automaton::RealTimeHeightDetermi const auto & st = * epsilonTransitions[initialState].begin ( ); - std::vector < alphabet::Symbol > pops ( std::get < 0 > ( st ).begin ( ), std::get < 0 > ( st ).end ( ) ); - std::vector < alphabet::Symbol > pushes ( std::get < 2 > ( st ).rbegin ( ), std::get < 2 > ( st ).rend ( ) ); + std::vector < DefaultSymbolType > pops ( std::get < 0 > ( st ).begin ( ), std::get < 0 > ( st ).end ( ) ); + std::vector < DefaultSymbolType > pushes ( std::get < 2 > ( st ).rbegin ( ), std::get < 2 > ( st ).rend ( ) ); - label::Label toState = std::get < 1 > ( st ); + DefaultStateType toState = std::get < 1 > ( st ); while ( !epsilonTransitions[toState].empty ( ) ) { const auto & epsilonT = * epsilonTransitions[toState].begin ( ); @@ -258,8 +258,8 @@ automaton::NPDA < > RHPDAToPDA::convert ( const automaton::RealTimeHeightDetermi for ( const auto & transition : readingTransitions ) for ( const auto & to : transition.second ) { - pops = std::vector < alphabet::Symbol > ( std::get < 2 > ( transition.first ).begin ( ), std::get < 2 > ( transition.first ).end ( ) ); - pushes = std::vector < alphabet::Symbol > ( to.second.rbegin ( ), to.second.rend ( ) ); + pops = std::vector < DefaultSymbolType > ( std::get < 2 > ( transition.first ).begin ( ), std::get < 2 > ( transition.first ).end ( ) ); + pushes = std::vector < DefaultSymbolType > ( to.second.rbegin ( ), to.second.rend ( ) ); constructTransitions ( transition.first, epsilonTransitions, to.first, std::move ( pops ), std::move ( pushes ), res ); } @@ -275,10 +275,11 @@ automaton::Automaton RHPDAToPDA::convert ( const Automaton & automaton ) { return dispatch ( automaton.getData ( ) ); } -} +} /* namespace automaton */ namespace alib { auto DPDAFromRealTimeHeightDeterministicNPDA = castApi::CastRegister < automaton::DPDA < >, automaton::RealTimeHeightDeterministicDPDA < > > ( automaton::RHPDAToPDA::convert ); auto NPDAFromRealTimeHeightDeterministicNPDA = castApi::CastRegister < automaton::NPDA < >, automaton::RealTimeHeightDeterministicNPDA < > > ( automaton::RHPDAToPDA::convert ); -} + +} /* namespace alib */ diff --git a/alib2algo/src/automaton/transform/RHPDAToPDA.h b/alib2algo/src/automaton/transform/RHPDAToPDA.h index ce33b5c62e8021c47d44c32383157b8e7c7b13e9..957992b724cfd0d149ade0df88a6f3edf12649bf 100644 --- a/alib2algo/src/automaton/transform/RHPDAToPDA.h +++ b/alib2algo/src/automaton/transform/RHPDAToPDA.h @@ -31,6 +31,6 @@ public: static automaton::Automaton convert( const automaton::Automaton & automaton ); }; -} +} /* namespace automaton */ #endif /* RHPDA_TO_PDA_H_ */