|
Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
|
Right linear grammar in Chomsky hierarchy or type 3 in Chomsky hierarchy. Generates regular languages. More...
#include <RightLG.h>
Public Member Functions | |
| RightLG (NonterminalSymbolType initialSymbol) | |
| Creates a new instance of Right linear grammar with a concrete initial symbol. More... | |
| RightLG (ext::set< NonterminalSymbolType > nonterminalAlphabet, ext::set< TerminalSymbolType > terminalAlphabet, NonterminalSymbolType initialSymbol) | |
| Creates a new instance of Right linear grammar with a concrete nonterminal, terminal alphabet and initial symbol. More... | |
| bool | addRule (NonterminalSymbolType leftHandSide, ext::variant< ext::vector< TerminalSymbolType >, ext::pair< ext::vector< TerminalSymbolType >, NonterminalSymbolType > > rightHandSide) |
| Add a new rule of a grammar. More... | |
| void | addRules (NonterminalSymbolType leftHandSide, ext::set< ext::variant< ext::vector< TerminalSymbolType >, ext::pair< ext::vector< TerminalSymbolType >, NonterminalSymbolType > > > rightHandSide) |
| Add new rules of a grammar. More... | |
| const ext::map< NonterminalSymbolType, ext::set< ext::variant< ext::vector< TerminalSymbolType >, ext::pair< ext::vector< TerminalSymbolType >, NonterminalSymbolType > > > > & | getRules () const & |
| ext::map< NonterminalSymbolType, ext::set< ext::variant< ext::vector< TerminalSymbolType >, ext::pair< ext::vector< TerminalSymbolType >, NonterminalSymbolType > > > > && | getRules () && |
| bool | removeRule (const NonterminalSymbolType &leftHandSide, const ext::variant< ext::vector< TerminalSymbolType >, ext::pair< ext::vector< TerminalSymbolType >, NonterminalSymbolType > > &rightHandSide) |
| bool | removeRule (const NonterminalSymbolType &leftHandSide, const ext::vector< TerminalSymbolType > &rightHandSide) |
| bool | removeRule (const NonterminalSymbolType &leftHandSide, const ext::pair< ext::vector< TerminalSymbolType >, 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) |
| auto | operator<=> (const RightLG &other) const |
| bool | operator== (const RightLG &other) const |
Public Member Functions inherited from core::Components< RightLG< DefaultSymbolType, DefaultSymbolType >, ext::set< DefaultSymbolType >, component::Set, TerminalAlphabet, ext::set< DefaultSymbolType >, component::Set, NonterminalAlphabet, DefaultSymbolType, component::Value, InitialSymbol > | |
| void | accessComponent () |
Friends | |
| ext::ostream & | operator<< (ext::ostream &out, const RightLG &instance) |
Additional Inherited Members | |
Static Public Member Functions inherited from core::Components< RightLG< DefaultSymbolType, DefaultSymbolType >, ext::set< DefaultSymbolType >, component::Set, TerminalAlphabet, ext::set< DefaultSymbolType >, component::Set, NonterminalAlphabet, DefaultSymbolType, component::Value, InitialSymbol > | |
| static void | registerComponent () |
| static void | unregisterComponent () |
Right linear grammar in Chomsky hierarchy or type 3 in Chomsky hierarchy. Generates regular languages.
Definition is similar to all common definitions of 'relaxed' regular 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 -> aB or A -> a, where A, B \in N and a \in T*, S (InitialSymbol) = initial nonterminal symbol,
| NonterminalSymbolType | used for the terminal alphabet, the nonterminal alphabet, and the initial symbol of the grammar. |
|
explicit |
Creates a new instance of Right linear grammar with a concrete initial symbol.
| initialSymbol | the initial symbol of the grammar |
|
explicit |
Creates a new instance of Right linear grammar with a concrete nonterminal, terminal alphabet and initial symbol.
| nonTerminalSymbols | the initial nonterminal alphabet |
| terminalSymbols | the initial terminal alphabet |
| initialSymbol | the initial symbol of the grammar |
|
inline |
Adder of nonterminal symbol.
| symbol | the new symbol to be added to nonterminal alphabet |
| bool grammar::RightLG< TerminalSymbolType, NonterminalSymbolType >::addRule | ( | NonterminalSymbolType | leftHandSide, |
| ext::variant< ext::vector< TerminalSymbolType >, ext::pair< ext::vector< TerminalSymbolType >, NonterminalSymbolType > > | rightHandSide | ||
| ) |
Add a new rule of a grammar.
The rule is in a form of A -> aB or A -> a, where A, B \in N and a \in T*.
| leftHandSide | the left hand side of the rule |
| rightHandSide | the right hand side of the rule |
| void grammar::RightLG< TerminalSymbolType, NonterminalSymbolType >::addRules | ( | NonterminalSymbolType | leftHandSide, |
| ext::set< ext::variant< ext::vector< TerminalSymbolType >, ext::pair< ext::vector< TerminalSymbolType >, NonterminalSymbolType > > > | rightHandSide | ||
| ) |
Add new rules of a grammar.
The rules are in form of A -> aB | bC | ... | a | b | ..., where A, B, C ... \in N and a, b ... \in T*.
| leftHandSide | the left hand side of the rule |
| rightHandSide | a set of right hand sides of the rule |
|
inline |
Adder of terminal symbol.
| symbol | the new symbol tuo be added to nonterminal alphabet |
|
inline |
Getter of initial symbol.
|
inline |
Getter of initial symbol.
|
inline |
Getter of nonterminal alphabet.
|
inline |
Getter of nonterminal alphabet.
| ext::map< NonterminalSymbolType, ext::set< ext::variant< ext::vector< TerminalSymbolType >, ext::pair< ext::vector< TerminalSymbolType >, NonterminalSymbolType > > > > && grammar::RightLG< TerminalSymbolType, NonterminalSymbolType >::getRules | ( | ) | && |
Get rules of the grammar.
| const ext::map< NonterminalSymbolType, ext::set< ext::variant< ext::vector< TerminalSymbolType >, ext::pair< ext::vector< TerminalSymbolType >, NonterminalSymbolType > > > > & grammar::RightLG< TerminalSymbolType, NonterminalSymbolType >::getRules | ( | ) | const & |
Get rules of the grammar.
|
inline |
Getter of terminal alphabet.
|
inline |
Getter of terminal alphabet.
|
inline |
The three way comparison implementation
| other | the other instance |
other.
|
inline |
The equality comparison implementation.
| other | the other object to compare with. |
| bool grammar::RightLG< TerminalSymbolType, NonterminalSymbolType >::removeRule | ( | const NonterminalSymbolType & | leftHandSide, |
| const ext::pair< ext::vector< TerminalSymbolType >, NonterminalSymbolType > & | rightHandSide | ||
| ) |
Remove a rule of a grammar in form of A -> aB, where A, B \in N and a \in T*.
| leftHandSide | the left hand side of the rule |
| rightHandSide | the right hand side of the rule |
| bool grammar::RightLG< TerminalSymbolType, NonterminalSymbolType >::removeRule | ( | const NonterminalSymbolType & | leftHandSide, |
| const ext::variant< ext::vector< TerminalSymbolType >, ext::pair< ext::vector< TerminalSymbolType >, NonterminalSymbolType > > & | rightHandSide | ||
| ) |
Remove a rule of a grammar in form of A -> aB or A -> a, where A, B \in N and a \in T*.
| leftHandSide | the left hand side of the rule |
| rightHandSide | the right hand side of the rule |
| bool grammar::RightLG< TerminalSymbolType, NonterminalSymbolType >::removeRule | ( | const NonterminalSymbolType & | leftHandSide, |
| const ext::vector< TerminalSymbolType > & | rightHandSide | ||
| ) |
Remove a rule of a grammar in form of A -> a, where A \in N and a \in T*.
| leftHandSide | the left hand side of the rule |
| rightHandSide | the right hand side of the rule |
|
inline |
Setter of initial symbol.
| symbol | new initial symbol of the grammar |
|
inline |
Setter of nonterminal alphabet.
| symbols | completely new nonterminal alphabet |
|
inline |
Setter of terminal alphabet.
| symbol | completely new nontemrinal alphabet |
|
friend |
Print this object as raw representation to ostream.
| out | ostream where to print |
| instance | object to print |