diff --git a/aql2/makefile b/aql2/makefile new file mode 100644 index 0000000000000000000000000000000000000000..bd9fb6f7bcf2fc7fa9d20ce5fc983aa693391c1b --- /dev/null +++ b/aql2/makefile @@ -0,0 +1,3 @@ +-include makefile.conf +-include ../build.conf +-include ../makefile-binary diff --git a/aql2/makefile.conf b/aql2/makefile.conf new file mode 100644 index 0000000000000000000000000000000000000000..4556c5f00da4df610b4a4f9f0215e8579c70abe2 --- /dev/null +++ b/aql2/makefile.conf @@ -0,0 +1,4 @@ +EXECUTABLE:=aql2 +LINK_PATHS=../alib2cli/ ../alib2elgo/ ../alib2algo/ ../alib2raw/ ../alib2str/ ../alib2data/ ../alib2common/ ../alib2std/ +LINK_LIBRARIES=alib2cli alib2elgo alib2algo alib2raw alib2str alib2data alib2common alib2std xml2 +INCLUDE_PATHS=\$$(SOURCES_BASE_DIR)/../../alib2cli/src/ \$$(SOURCES_BASE_DIR)/../../alib2data/src/ \$$(SOURCES_BASE_DIR)/../../alib2common/src/ \$$(SOURCES_BASE_DIR)/../../alib2std/src/ /usr/include/libxml2/ diff --git a/aql2/src/aql.cpp b/aql2/src/aql.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0fb8cb0a980935f6e92bfbe62c39f1dca2324e08 --- /dev/null +++ b/aql2/src/aql.cpp @@ -0,0 +1,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; + } +} diff --git a/makefile b/makefile index acc72b415edb28e856f3f4ce18cb37f06b49173a..664250e5d3f344881ee21f77c75ca2e9c802e3fd 100644 --- a/makefile +++ b/makefile @@ -61,6 +61,7 @@ SUBDIRS_BINS = aecho2 \ atrim2 \ tniceprint \ aintrospection2 \ + aql2 \ define NEW_LINE