From a83bbecb6d5e2d574f55ec8843dc01a07587940a Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Wed, 5 Jul 2017 22:11:59 +0200 Subject: [PATCH] aql binary --- aql2/makefile | 3 +++ aql2/makefile.conf | 4 +++ aql2/src/aql.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++ makefile | 1 + 4 files changed, 74 insertions(+) create mode 100644 aql2/makefile create mode 100644 aql2/makefile.conf create mode 100644 aql2/src/aql.cpp diff --git a/aql2/makefile b/aql2/makefile new file mode 100644 index 0000000000..bd9fb6f7bc --- /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 0000000000..4556c5f00d --- /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 0000000000..0fb8cb0a98 --- /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 acc72b415e..664250e5d3 100644 --- a/makefile +++ b/makefile @@ -61,6 +61,7 @@ SUBDIRS_BINS = aecho2 \ atrim2 \ tniceprint \ aintrospection2 \ + aql2 \ define NEW_LINE -- GitLab