Greibach normal form of a context free grammar in Chomsky hierarchy or type 2 in Chomsky hierarchy. Generates context free languages.
More...
|
| GNF (NonterminalSymbolType initialSymbol) |
| Creates a new instance of the grammar with a concrete initial symbol. More...
|
|
| GNF (ext::set< NonterminalSymbolType > nonterminalAlphabet, ext::set< TerminalSymbolType > terminalAlphabet, NonterminalSymbolType initialSymbol) |
| Creates a new instance of the grammar with a concrete nonterminal alphabet, terminal alphabet and initial symbol. More...
|
|
bool | addRule (NonterminalSymbolType leftHandSide, ext::pair< TerminalSymbolType, ext::vector< NonterminalSymbolType > > rightHandSide) |
| Add a new rule of a grammar. More...
|
|
void | addRules (NonterminalSymbolType leftHandSide, ext::set< ext::pair< TerminalSymbolType, ext::vector< NonterminalSymbolType > > > rightHandSide) |
| Add new rules of a grammar. More...
|
|
const ext::map< NonterminalSymbolType, ext::set< ext::pair< TerminalSymbolType, ext::vector< NonterminalSymbolType > > > > & | getRules () const & |
|
ext::map< NonterminalSymbolType, ext::set< ext::pair< TerminalSymbolType, ext::vector< NonterminalSymbolType > > > > && | getRules () && |
|
bool | removeRule (const NonterminalSymbolType &leftHandSide, const ext::pair< TerminalSymbolType, ext::vector< NonterminalSymbolType > > &rightHandSide) |
|
const NonterminalSymbolType & | getInitialSymbol () const & |
|
NonterminalSymbolType && | getInitialSymbol () && |
|
bool | setInitialSymbol (NonterminalSymbolType symbol) |
|
const ext::set< NonterminalSymbolType > & | getNonterminalAlphabet () const & |
|
ext::set< NonterminalSymbolType > && | getNonterminalAlphabet () && |
|
bool | addNonterminalSymbol (NonterminalSymbolType symbol) |
|
void | setNonterminalAlphabet (ext::set< NonterminalSymbolType > symbols) |
|
const ext::set< TerminalSymbolType > & | getTerminalAlphabet () const & |
|
ext::set< TerminalSymbolType > && | getTerminalAlphabet () && |
|
bool | addTerminalSymbol (TerminalSymbolType symbol) |
|
void | setTerminalAlphabet (ext::set< TerminalSymbolType > symbols) |
|
void | setGeneratesEpsilon (bool genEps) |
|
bool | getGeneratesEpsilon () const |
|
auto | operator<=> (const GNF &other) const |
|
bool | operator== (const GNF &other) const |
|
void | accessComponent () |
|
template<class TerminalSymbolType = DefaultSymbolType, class NonterminalSymbolType = DefaultSymbolType>
class grammar::GNF< TerminalSymbolType, NonterminalSymbolType >
Greibach normal form of a context free grammar in Chomsky hierarchy or type 2 in Chomsky hierarchy. Generates context free languages.
Definition is similar to all common definitions of context free grammars. G = (N, T, P, S), N (NonterminalAlphabet) = nonempty finite set of nonterminal symbols, T (TerminalAlphabet) = finite set of terminal symbols - having this empty won't let grammar do much though, P = set of production rules of the form A -> BC or A -> a, where A, B, C \in N and a \in T, S (InitialSymbol) = initial nonterminal symbol,
- Template Parameters
-
TerminalSymbolType | used for the terminal alphabet of the grammar. |
NonterminalSymbolType | used for the nonterminal alphabet, and the initial symbol of the grammar. |
template<class TerminalSymbolType , class NonterminalSymbolType >
void grammar::GNF< TerminalSymbolType, NonterminalSymbolType >::addRules |
( |
NonterminalSymbolType |
leftHandSide, |
|
|
ext::set< ext::pair< TerminalSymbolType, ext::vector< NonterminalSymbolType > > > |
rightHandSide |
|
) |
| |
Add new rules of a grammar.
The rules are in form of A -> aB | bC, where A \in N, a, b in T, and B, C \in N*.
- Parameters
-
leftHandSide | the left hand side of the rule |
rightHandSide | a set of right hand sides of the rule |