3131#include " parser/sbg_program.hpp"
3232#include " eval/visitors/program_visitor.hpp"
3333
34- void parseEvalProgramFromFile (std::string fname, bool debug)
34+ struct Impl {
35+ int set_impl_;
36+ int pw_impl_;
37+
38+ Impl (int set_impl, int pw_impl) : set_impl_(set_impl), pw_impl_(pw_impl) {};
39+ };
40+
41+ void parseEvalProgramFromFile (std::string fname, Impl impl, bool debug)
3542{
3643 std::ifstream in (fname.c_str ());
3744 if (in.fail ())
@@ -57,7 +64,26 @@ void parseEvalProgramFromFile(std::string fname, bool debug)
5764 std::cout << " >>>>>> Eval result <<<<<<\n " ;
5865 std::cout << " -------------------------\n\n " ;
5966
60- SBG::Eval::ProgramVisitor program_visit (debug);
67+ std::unique_ptr<SBG::LIB::SetAF> set_fact
68+ = std::make_unique<SBG::LIB::UnordAF>();
69+
70+ switch (impl.set_impl_ ) {
71+ case 2 :
72+ set_fact = std::make_unique<SBG::LIB::OrdDenseAF>();
73+
74+ default :
75+ break ;
76+ }
77+
78+ SBG::LIB::MapAF map_fact (*set_fact);
79+ std::unique_ptr<SBG::LIB::PWMapAF> fact
80+ = std::make_unique<SBG::LIB::UnordPWMapAF>(map_fact);
81+ switch (impl.pw_impl_ ) {
82+ default :
83+ break ;
84+ }
85+
86+ SBG::Eval::ProgramVisitor program_visit (*fact, debug);
6187 SBG::Eval::ProgramIO visit_result = boost::apply_visitor (
6288 program_visit, parser_result
6389 );
@@ -78,6 +104,8 @@ void usage()
78104 std::cout << " Usage evaluator: ./bin/sbg-eval -f filename [options]\n " ;
79105 std::cout << " Parses and evaluates a SBG program.\n\n " ;
80106 std::cout << " -f, --file SBG program file used as input\n " ;
107+ std::cout << " -s, --set_impl Choose set implementation: 0 unordered sets,\n " ;
108+ std::cout << " 1 ordered sets, 2 ordered dense sets.\n " ;
81109 std::cout << " -h, --help Display this information and exit\n " ;
82110 std::cout << " -d, --debug Activate debug info\n " ;
83111 std::cout << " -v, --version Display version information and exit\n\n " ;
@@ -201,27 +229,30 @@ void version()
201229 std::cout << " There is NO WARRANTY, to the extent permitted by law.\n " ;
202230}
203231
204-
205232int main (int argc, char **argv)
206233{
207234 std::string filename;
208- int opt;
235+ int opt, set_impl = 0 , pw_impl = 0 ;
209236 extern char * optarg;
210237 bool debug = false ;
211238
212239 while (true ) {
213240 static struct option long_options[] = {{" file" , required_argument, 0 , ' f' }
241+ , {" set_impl" , required_argument, 0 , ' s' }
214242 , {" help" , no_argument, 0 , ' h' }
215243 , {" debug" , no_argument, 0 , ' d' }
216244 , {" version" , no_argument, 0 , ' v' }
217245 , {0 , 0 , 0 , 0 }};
218- opt = getopt_long (argc, argv, " f:hdv" , long_options, nullptr );
246+ opt = getopt_long (argc, argv, " f:s: hdv" , long_options, nullptr );
219247 if (opt == EOF)
220248 break ;
221249 switch (opt) {
222250 case ' f' :
223251 filename = optarg;
224252 break ;
253+ case ' s' :
254+ set_impl = std::stoi (optarg);
255+ break ;
225256 case ' h' :
226257 usage ();
227258 exit (0 );
@@ -241,7 +272,7 @@ int main(int argc, char**argv)
241272 }
242273
243274 if (!filename.empty ())
244- parseEvalProgramFromFile (filename, debug);
275+ parseEvalProgramFromFile (filename, Impl (set_impl, pw_impl), debug);
245276 else
246277 SBG::Util::ERROR (" A filename should be provided\n " );
247278
0 commit comments