Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* aql.cpp
*
* Created on: 26. 3. 2014
* Author: Jan Travnicek
*/
#include <measure>
#include <tclap/CmdLine.h>
#include <global/GlobalData.h>
#include <lexer/Lexer.h>
#include <parser/Parser.h>
int main ( int argc, char * argv[] ) {
//TODO interfacing to stdin / unnamed pipes and stdout
try {
common::GlobalData::argc = argc;
common::GlobalData::argv = argv;
TCLAP::CmdLine cmd ( "Algorithms query language binary", ' ', "0.01" );
TCLAP::ValueArg < std::string > query ( "q", "query", "Query index", true, "", "query");
cmd.add ( query );
TCLAP::SwitchArg measure ( "m", "measure", "Measure times", false );
cmd.add ( measure );
TCLAP::SwitchArg verbose ( "v", "verbose", "Be verbose", false );
cmd.add ( verbose );
cmd.parse ( argc, argv );
if(verbose.isSet())
common::GlobalData::verbose = true;
if(measure.isSet())
common::GlobalData::measure = true;
measurements::start ( "Overal", measurements::Type::OVERALL );
cli::Parser parser ( cli::Lexer ( query.getValue ( ) ) );
parser.execute ( )->translateAndEval ( nullptr );
measurements::end ( );
if ( measure.getValue ( ) )
std::cmeasure << measurements::results ( ) << std::endl;
return 0;
} catch ( const exception::CommonException & exception ) {
alib::XmlDataFactory::toStdout ( exception );
return 1;
} catch ( const TCLAP::ArgException & exception ) {
std::cout << exception.error ( ) << std::endl;
return 2;
} catch ( const std::exception & exception ) {
std::cerr << "Exception caught: " << exception.what ( ) << std::endl;
return 3;
} catch ( ... ) {
std::cerr << "Unknown exception caught." << std::endl;
return 127;
}
}