Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
GrammarIteration.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
28
30
31namespace grammar::transform {
32
40public:
48 template < class TerminalSymbolType, class NonterminalSymbolType >
50};
51
52template < class TerminalSymbolType, class NonterminalSymbolType >
54 NonterminalSymbolType S = common::createUnique ( label::InitialStateLabel::instance < NonterminalSymbolType > ( ), grammar.getNonterminalAlphabet ( ) );
56
57 res.addNonterminalSymbol ( S );
58 res.setInitialSymbol ( S );
59 res.addRule ( S, { } );
60 res.addRule ( S, { grammar.getInitialSymbol ( ), S } );
61
62 return res;
63}
64
65} /* namespace grammar::transform */
66
Context free grammar in Chomsky hierarchy or type 2 in Chomsky hierarchy. Generates context free lang...
Definition: CFG.h:67
Definition: GrammarIteration.h:39
static grammar::CFG< TerminalSymbolType, NonterminalSymbolType > iteration(const grammar::CFG< TerminalSymbolType, NonterminalSymbolType > &grammar)
Definition: GrammarIteration.h:53
return grammar
Definition: ToGrammarLeftRG.h:99
return res
Definition: MinimizeByPartitioning.h:145
T createUnique(T object, const Alphabets &... alphabets)
Definition: createUnique.hpp:46
Definition: GrammarAlternation.h:33
Definition: ToAutomaton.h:24