Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
Public Member Functions | Protected Member Functions | Protected Attributes
equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType > Class Template Referenceabstract

#include <RegularEquationSolver.h>

Inheritance diagram for equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >:
[legend]

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
 

Detailed Description

template<class TerminalSymbolType, class VariableSymbolType>
class equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >

Base class for regular equations solvers.

Constructor & Destructor Documentation

◆ ~RegularEquationSolver()

template<class TerminalSymbolType , class VariableSymbolType >
virtual equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::~RegularEquationSolver ( )
virtualdefaultnoexcept

Member Function Documentation

◆ addEquation() [1/2]

template<class TerminalSymbolType , class VariableSymbolType >
void equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::addEquation ( const VariableSymbolType &  from,
const regexp::UnboundedRegExpElement< TerminalSymbolType > &  eq 
)

Adds equation in form: FROM = eq

Parameters
from
eq
Here is the call graph for this function:

◆ addEquation() [2/2]

template<class TerminalSymbolType , class VariableSymbolType >
void equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::addEquation ( const VariableSymbolType &  from,
const VariableSymbolType &  to,
const regexp::UnboundedRegExpElement< TerminalSymbolType > &  eq 
)

Adds equation in form FROM = eq TO

Parameters
fromsymbol
tosymbol
eqequation
Here is the call graph for this function:

◆ addVariableSymbol()

template<class TerminalSymbolType , class VariableSymbolType >
void equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::addVariableSymbol ( const VariableSymbolType &  symbol)

Adds nonterminal symbol into system.

Parameters
symbolgiven symbol
Here is the call graph for this function:
Here is the caller graph for this function:

◆ eliminate()

template<class TerminalSymbolType , class VariableSymbolType >
virtual regexp::UnboundedRegExp< TerminalSymbolType > equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::eliminate ( )
protectedpure virtual

actual equations elimination

Returns
pointer to solutions RegExp tree root
Here is the caller graph for this function:

◆ removeVariableSymbol()

template<class TerminalSymbolType , class VariableSymbolType >
void equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::removeVariableSymbol ( const VariableSymbolType &  symbol)

Removes nonterminal symbol from equation system.

Parameters
symbolgiven symbol
Exceptions
CommonExceptionwhen symbol is in use
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setVariableSymbols()

template<class TerminalSymbolType , class VariableSymbolType >
void equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::setVariableSymbols ( const ext::set< VariableSymbolType > &  newSymbols)

Sets nonterminal symbols of the equation system.

Parameters
symbolSymbols to set
Exceptions
CommonException
Here is the call graph for this function:

◆ solve()

template<class TerminalSymbolType , class VariableSymbolType >
regexp::UnboundedRegExp< TerminalSymbolType > equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::solve ( const VariableSymbolType &  solveFor)

Solve expression system

Parameters
solveForwill solve equation system for given symbol
Returns
regexp
Here is the call graph for this function:

◆ sortSymbolsByDepth()

template<class TerminalSymbolType , class VariableSymbolType >
void equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::sortSymbolsByDepth ( const VariableSymbolType &  solveFor)
protected

Runs BFS to determine depth of symbols in equation system and stores it in nonterminalSymbolsByDepth;

See also
nonterminalSymbolsByDepth
Here is the caller graph for this function:

Field Documentation

◆ equationFinal

template<class TerminalSymbolType , class VariableSymbolType >
ext::map< VariableSymbolType, regexp::UnboundedRegExpAlternation < TerminalSymbolType > > equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::equationFinal
protected

Stores equation not going to particular nonterminal, eg A = 01*

◆ equationTransition

template<class TerminalSymbolType , class VariableSymbolType >
ext::map< std::pair < VariableSymbolType, VariableSymbolType >, regexp::UnboundedRegExpAlternation < TerminalSymbolType > > equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::equationTransition
protected

Stores transitions from nonterminal to nonterminal, eg A = 2A + 2B + 1C

◆ nonterminalSymbols

template<class TerminalSymbolType , class VariableSymbolType >
ext::set< VariableSymbolType > equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::nonterminalSymbols
protected

Set of symbols

◆ nonterminalSymbolsByDepth

template<class TerminalSymbolType , class VariableSymbolType >
ext::deque< VariableSymbolType > equations::RegularEquationSolver< TerminalSymbolType, VariableSymbolType >::nonterminalSymbolsByDepth
protected
See also
symbolsByDepth

The documentation for this class was generated from the following file: