Commit c70317d5 authored by Ing. Jan Trávníček's avatar Ing. Jan Trávníček

fixes and simplifications in ExactPatternMatch

parent 9103f85b
......@@ -73,10 +73,8 @@ private:
template < class SymbolType >
static void matchInternal ( unsigned & index, ext::set < unsigned > & occ, const ext::tree < SymbolType > & subject, const ext::tree < SymbolType > & pattern, const SymbolType & subtreeVariable );
template < class SymbolType >
static void matchInternal ( unsigned & index, ext::set < unsigned > & occ, const ext::tree < common::ranked_symbol < SymbolType > > & subject, const ext::tree < common::ranked_symbol < SymbolType > > & pattern, const common::ranked_symbol < SymbolType > & subtreeVariable );
template < class SymbolType >
static void matchInternal ( unsigned & index, ext::set < unsigned > & occ, const ext::tree < common::ranked_symbol < SymbolType > > & subject, const ext::tree < common::ranked_symbol < SymbolType > > & pattern, const common::ranked_symbol < SymbolType > & subtreeVariable, const ext::set < common::ranked_symbol < SymbolType > > & nonlinearVariables, const ext::tree < common::ranked_symbol < unsigned > > & repeats );
template < class SymbolType, class RepeatsType >
static void matchInternal ( unsigned & index, ext::set < unsigned > & occ, const ext::tree < SymbolType > & subject, const ext::tree < SymbolType > & pattern, const SymbolType & subtreeVariable, const ext::set < SymbolType > & nonlinearVariables, const ext::tree < RepeatsType > & repeats );
template < class SymbolType >
static bool matchUnorderedHelper ( const ext::tree < common::ranked_symbol < SymbolType > > & subject, const ext::tree < common::ranked_symbol < SymbolType > > & pattern, const common::ranked_symbol < SymbolType > & subtreeVariable );
......@@ -95,7 +93,7 @@ bool ExactPatternMatch::matchHelper ( const ext::tree < SymbolType > & subject,
auto patternIter = pattern.getChildren ( ).begin ( );
auto subjectIter = subject.getChildren ( ).begin ( );
while ( patternIter != pattern.getChildren ( ).end ( ) || subjectIter != subject.getChildren ( ).end ( ) ) {
while ( patternIter != pattern.getChildren ( ).end ( ) && subjectIter != subject.getChildren ( ).end ( ) ) {
if ( matchHelper ( * subjectIter, * patternIter, subtreeVariable ) )
++ patternIter;
......@@ -151,25 +149,15 @@ void ExactPatternMatch::matchInternal ( unsigned & index, ext::set < unsigned >
matchInternal ( index, occ, child, pattern, subtreeVariable );
}
template < class SymbolType >
void ExactPatternMatch::matchInternal ( unsigned & index, ext::set < unsigned > & occ, const ext::tree < common::ranked_symbol < SymbolType > > & subject, const ext::tree < common::ranked_symbol < SymbolType > > & pattern, const common::ranked_symbol < SymbolType > & subtreeVariable ) {
if ( matchHelper ( subject, pattern, subtreeVariable ) ) occ.insert ( index );
index++;
for ( const ext::tree < common::ranked_symbol < SymbolType > > & child : subject.getChildren ( ) )
matchInternal ( index, occ, child, pattern, subtreeVariable );
}
template < class SymbolType >
void ExactPatternMatch::matchInternal ( unsigned & index, ext::set < unsigned > & occ, const ext::tree < common::ranked_symbol < SymbolType > > & subject, const ext::tree < common::ranked_symbol < SymbolType > > & pattern, const common::ranked_symbol < SymbolType > & subtreeVariable, const ext::set < common::ranked_symbol < SymbolType > > & nonlinearVariables, const ext::tree < common::ranked_symbol < unsigned > > & repeats ) {
ext::map < common::ranked_symbol < SymbolType >, unsigned > variablesSetting;
template < class SymbolType, class RepeatsType >
void ExactPatternMatch::matchInternal ( unsigned & index, ext::set < unsigned > & occ, const ext::tree < SymbolType > & subject, const ext::tree < SymbolType > & pattern, const SymbolType & subtreeVariable, const ext::set < SymbolType > & nonlinearVariables, const ext::tree < RepeatsType > & repeats ) {
ext::map < SymbolType, unsigned > variablesSetting;
if ( matchHelper ( subject, pattern, subtreeVariable, nonlinearVariables, repeats, variablesSetting ) ) occ.insert ( index );
index++;
for ( const ext::tuple < const ext::tree < common::ranked_symbol < SymbolType > > &, const ext::tree < common::ranked_symbol < unsigned > > & > & childs : ext::make_tuple_foreach ( subject.getChildren ( ), repeats.getChildren ( ) ) )
for ( const ext::tuple < const ext::tree < SymbolType > &, const ext::tree < RepeatsType > & > & childs : ext::make_tuple_foreach ( subject.getChildren ( ), repeats.getChildren ( ) ) )
matchInternal ( index, occ, std::get < 0 > ( childs ), pattern, subtreeVariable, nonlinearVariables, std::get < 1 > ( childs ) );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment