Skip to content
Snippets Groups Projects
Commit ed864e2b authored by Jan Trávníček's avatar Jan Trávníček
Browse files

forward call to the same implementation elsewhere

parent 88881f01
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
*/
 
#include "ExactPatternMatchingAutomaton.h"
#include "ExactSubtreeMatchingAutomaton.h"
#include "SubtreeJumpTable.h"
 
#include <exception/AlibException.h>
......@@ -29,27 +30,7 @@ automaton::Automaton ExactPatternMatchingAutomaton::construct ( const tree::Rank
}
 
automaton::InputDrivenNPDA ExactPatternMatchingAutomaton::construct ( const tree::PrefixRankedTree & pattern ) {
automaton::InputDrivenNPDA res ( automaton::State ( 0 ), alphabet::symbolFrom ( 'S' ) );
for ( const alphabet::RankedSymbol & symbol : pattern.getAlphabet ( ) ) {
res.addInputSymbol ( alphabet::Symbol { symbol } );
res.setPushdownStoreOperation ( alphabet::Symbol { symbol }, std::vector < alphabet::Symbol > { 1, alphabet::symbolFrom ( 'S' ) }, std::vector < alphabet::Symbol > { symbol.getRank ( ).getData ( ), alphabet::symbolFrom ( 'S' ) } );
}
for ( const alphabet::RankedSymbol & symbol : pattern.getAlphabet ( ) ) {
res.addTransition ( automaton::State ( 0 ), alphabet::Symbol { symbol }, automaton::State ( 0 ) );
}
int i = 1;
for ( const alphabet::RankedSymbol & symbol : pattern.getContent ( ) ) {
res.addState ( automaton::State ( i ) );
res.addTransition ( automaton::State ( i - 1 ), alphabet::Symbol { symbol }, automaton::State ( i ) );
i++;
}
res.addFinalState ( automaton::State ( i - 1 ) );
return res;
return ExactSubtreeMatchingAutomaton::construct ( pattern );
}
 
auto ExactPatternMatchingAutomatonPrefixRankedTree = ExactPatternMatchingAutomaton::RegistratorWrapper < automaton::InputDrivenNPDA, tree::PrefixRankedTree > ( ExactPatternMatchingAutomaton::getInstance ( ), ExactPatternMatchingAutomaton::construct );
......@@ -130,28 +111,8 @@ automaton::NPDA ExactPatternMatchingAutomaton::construct ( const tree::PrefixRan
 
auto ExactPatternMatchingAutomatonPrefixRankedPattern = ExactPatternMatchingAutomaton::RegistratorWrapper < automaton::NPDA, tree::PrefixRankedPattern > ( ExactPatternMatchingAutomaton::getInstance ( ), ExactPatternMatchingAutomaton::construct );
 
automaton::State constructRecursiveTree ( const tree::RankedNode & node, automaton::NFTA & res, int & nextState ) {
std::vector < automaton::State > states;
states.reserve ( node.getSymbol ( ).getRank ( ).getData ( ) );
for ( const auto & child : node.getChildren ( ) )
states.push_back ( constructRecursiveTree ( * child, res, nextState ) );
automaton::State state ( nextState++ );
res.addState ( state );
res.addTransition ( node.getSymbol ( ), states, state );
return state;
}
automaton::NFTA ExactPatternMatchingAutomaton::construct ( const tree::RankedTree & pattern ) {
const std::set < alphabet::RankedSymbol > & alphabet = pattern.getAlphabet ( );
automaton::NFTA res;
res.setInputSymbols ( alphabet );
int nextState = 0;
res.addFinalState ( constructRecursiveTree ( pattern.getRoot ( ), res, nextState ) );
return res;
return ExactSubtreeMatchingAutomaton::construct ( pattern );
}
 
auto ExactPatternMatchingAutomatonRankedTree = ExactPatternMatchingAutomaton::RegistratorWrapper < automaton::NFTA, tree::RankedTree > ( ExactPatternMatchingAutomaton::getInstance ( ), ExactPatternMatchingAutomaton::construct );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment