Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
AutomatonIterationEpsilonTransition.h
Go to the documentation of this file.
1
6/*
7 * This file is part of Algorithms library toolkit.
8 * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
9
10 * Algorithms library toolkit is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14
15 * Algorithms library toolkit is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19
20 * You should have received a copy of the GNU General Public License
21 * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#pragma once
25
27
28namespace automaton {
29
30namespace transform {
31
38public:
45 template < class T >
47};
48
49template < class T >
51 using SymbolType = typename T::SymbolType;
52 using StateType = typename T::StateType;
53
55
56 for(const auto&q : automaton.getFinalStates())
57 res.addTransition(q, automaton.getInitialState());
58
59 StateType newInitialState = common::createUnique(automaton.getInitialState(), automaton.getStates());
60 res.addState(newInitialState);
61 res.setInitialState(newInitialState);
62 res.addFinalState(newInitialState);
63
64 res.addTransition(newInitialState, automaton.getInitialState());
65 return res;
66}
67
68} /* namespace transform */
69
70} /* namespace automaton */
71
Epsilon nondeterministic finite automaton. Accepts regular languages.
Definition: EpsilonNFA.h:74
Definition: AutomatonIterationEpsilonTransition.h:37
static automaton::EpsilonNFA< typename T::SymbolType, typename T::StateType > iteration(const T &automaton)
Definition: AutomatonIterationEpsilonTransition.h:50
typename T::StateType StateType
Definition: ToGrammarLeftRG.h:64
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
q
Definition: SingleInitialStateEpsilonTransition.h:85
typename T::StateType StateType
Definition: Compaction.h:76
return res
Definition: AutomataConcatenation.h:102
Automaton::StateType newInitialState
Definition: AutomatonIteration.h:56
Definition: ToGrammar.h:31
T createUnique(T object, const Alphabets &... alphabets)
Definition: createUnique.hpp:46
ContainerType< ResType > transform(const ContainerType< InType, Ts ... > &in, Callback transform)
In container tranformation of all elements according to the tranform.
Definition: algorithm.hpp:150