Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
|
#include <RegularEquationSolver.h>
Public Member Functions | |
virtual | ~RegularEquationSolver () noexcept=default |
void | addVariableSymbol (const VariableSymbolType &symbol) |
void | removeVariableSymbol (const VariableSymbolType &symbol) |
void | setVariableSymbols (const ext::set< VariableSymbolType > &newSymbols) |
void | addEquation (const VariableSymbolType &from, const VariableSymbolType &to, const regexp::UnboundedRegExpElement< TerminalSymbolType > &eq) |
void | addEquation (const VariableSymbolType &from, const regexp::UnboundedRegExpElement< TerminalSymbolType > &eq) |
regexp::UnboundedRegExp< TerminalSymbolType > | solve (const VariableSymbolType &solveFor) |
Protected Member Functions | |
virtual regexp::UnboundedRegExp< TerminalSymbolType > | eliminate ()=0 |
void | sortSymbolsByDepth (const VariableSymbolType &solveFor) |
Protected Attributes | |
ext::deque< VariableSymbolType > | nonterminalSymbolsByDepth |
ext::map< std::pair< VariableSymbolType, VariableSymbolType >, regexp::UnboundedRegExpAlternation< TerminalSymbolType > > | equationTransition |
ext::map< VariableSymbolType, regexp::UnboundedRegExpAlternation< TerminalSymbolType > > | equationFinal |
ext::set< VariableSymbolType > | nonterminalSymbols |
Base class for regular equations solvers.
|
virtualdefaultnoexcept |
void equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::addEquation | ( | const VariableSymbolType & | from, |
const regexp::UnboundedRegExpElement< TerminalSymbolType > & | eq | ||
) |
Adds equation in form: FROM = eq
from | |
eq |
void equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::addEquation | ( | const VariableSymbolType & | from, |
const VariableSymbolType & | to, | ||
const regexp::UnboundedRegExpElement< TerminalSymbolType > & | eq | ||
) |
Adds equation in form FROM = eq TO
from | symbol |
to | symbol |
eq | equation |
void equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::addVariableSymbol | ( | const VariableSymbolType & | symbol | ) |
Adds nonterminal symbol into system.
symbol | given symbol |
|
protectedpure virtual |
actual equations elimination
void equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::removeVariableSymbol | ( | const VariableSymbolType & | symbol | ) |
Removes nonterminal symbol from equation system.
symbol | given symbol |
CommonException | when symbol is in use |
void equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::setVariableSymbols | ( | const ext::set< VariableSymbolType > & | newSymbols | ) |
Sets nonterminal symbols of the equation system.
symbol | Symbols to set |
CommonException |
regexp::UnboundedRegExp< TerminalSymbolType > equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::solve | ( | const VariableSymbolType & | solveFor | ) |
Solve expression system
solveFor | will solve equation system for given symbol |
|
protected |
Runs BFS to determine depth of symbols in equation system and stores it in nonterminalSymbolsByDepth;
|
protected |
Stores equation not going to particular nonterminal, eg A = 01*
|
protected |
Stores transitions from nonterminal to nonterminal, eg A = 2A + 2B + 1C
|
protected |
Set of symbols
|
protected |