From 3043d25b16a68b92a16ea9903bfd5e6d09e5b575 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Thu, 14 Nov 2019 07:43:58 +0100 Subject: [PATCH] fixup load and unload statements --- alib2cli/src/lexer/Lexer.h | 3 +-- alib2cli/src/parser/Parser.cpp | 10 ++++++++-- alib2cli/test-src/cli/CliTest.cpp | 1 + .../test-src/testing/TimeoutAqlTest.cpp | 2 ++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/alib2cli/src/lexer/Lexer.h b/alib2cli/src/lexer/Lexer.h index 7706d34329..60733d5e38 100644 --- a/alib2cli/src/lexer/Lexer.h +++ b/alib2cli/src/lexer/Lexer.h @@ -9,8 +9,7 @@ #include <exception/CommonException.h> -#include "CharSequence.h" -#include <readline/StringLineInterface.h> +#include <lexer/CharSequence.h> namespace cli { diff --git a/alib2cli/src/parser/Parser.cpp b/alib2cli/src/parser/Parser.cpp index 94a1c5c456..f7e56a925b 100644 --- a/alib2cli/src/parser/Parser.cpp +++ b/alib2cli/src/parser/Parser.cpp @@ -410,13 +410,19 @@ std::unique_ptr < Command > Parser::command ( ) { return std::make_unique < SetCommand > ( std::move ( param ), std::move ( value ) ); } else if ( check_nonreserved_kw ( "load" ) ) { match_nonreserved_kw ( "load" ); + + setHint ( Lexer::Hint::FILE ); std::string libraryName = getTokenValue ( ); - match ( cli::Lexer::TokenType::INTEGER, cli::Lexer::TokenType::IDENTIFIER, cli::Lexer::TokenType::STRING ); + match ( cli::Lexer::TokenType::FILE, cli::Lexer::TokenType::STRING ); + return std::make_unique < LoadCommand > ( std::move ( libraryName ) ); } else if ( check_nonreserved_kw ( "unload" ) ) { match_nonreserved_kw ( "unload" ); + + setHint ( Lexer::Hint::FILE ); std::string libraryName = getTokenValue ( ); - match ( cli::Lexer::TokenType::INTEGER, cli::Lexer::TokenType::IDENTIFIER, cli::Lexer::TokenType::STRING ); + match ( cli::Lexer::TokenType::FILE, cli::Lexer::TokenType::STRING ); + return std::make_unique < UnloadCommand > ( std::move ( libraryName ) ); } else if ( check ( cli::Lexer::TokenType::EOT ) ) { return std::make_unique < EOTCommand > ( ); diff --git a/alib2cli/test-src/cli/CliTest.cpp b/alib2cli/test-src/cli/CliTest.cpp index 2b7f4441cd..1754bd2c4e 100644 --- a/alib2cli/test-src/cli/CliTest.cpp +++ b/alib2cli/test-src/cli/CliTest.cpp @@ -8,6 +8,7 @@ #include <sys/stat.h> #include <registry/AlgorithmRegistry.hpp> #include <registration/AlgoRegistration.hpp> +#include <readline/StringLineInterface.h> void testLine ( std::string line, cli::Environment & environment ) { cli::Parser ( cli::Lexer ( cli::CharSequence ( cli::StringLineInterface ( line ) ) ) ).parse ( )->run ( environment ); diff --git a/alib2integrationtest/test-src/testing/TimeoutAqlTest.cpp b/alib2integrationtest/test-src/testing/TimeoutAqlTest.cpp index 35ee0666e3..ed0bc38907 100644 --- a/alib2integrationtest/test-src/testing/TimeoutAqlTest.cpp +++ b/alib2integrationtest/test-src/testing/TimeoutAqlTest.cpp @@ -12,6 +12,8 @@ #include <alib/exception> #include <alib/random> +#include <readline/StringLineInterface.h> + #define PIPE_RD 0 #define PIPE_WR 1 -- GitLab