-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#878: Fixed jvmoption and parameters containing a space (#473)
related to exasol/script-languages-release#878
- Loading branch information
Showing
12 changed files
with
206 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
exaudfclient/base/javacontainer/script_options/parser_ctpg_jvm_options_parser.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#include "base/javacontainer/script_options/parser_ctpg_jvm_options_parser.h" | ||
#include "base/script_options_parser/ctpg/ctpg.hpp" | ||
#include <sstream> | ||
|
||
using namespace exaudf_ctpg; | ||
using namespace exaudf_ctpg::ftors; | ||
|
||
namespace SWIGVMContainers { | ||
|
||
namespace JavaScriptOptions { | ||
|
||
namespace JvmOptionsCTPG { | ||
|
||
|
||
const auto to_options(std::string&& e) | ||
{ | ||
tJvmOptions options{e}; | ||
return options; | ||
} | ||
|
||
auto&& add_option(std::string&& e, tJvmOptions&& ob) | ||
{ | ||
ob.push_back(std::move(e)); | ||
return std::move(ob); | ||
} | ||
|
||
auto convert_escape_sequence(std::string_view escape_seq) | ||
{ | ||
if (escape_seq == R"_(\ )_") { | ||
return std::string_view(" "); | ||
} else if (escape_seq == R"_(\t)_") { | ||
return std::string_view("\t"); | ||
} else if (escape_seq == R"_(\f)_") { | ||
return std::string_view("\f"); | ||
} else if (escape_seq == R"_(\v)_") { | ||
return std::string_view("\v"); | ||
} else if (escape_seq == R"_(\\)_") { | ||
return std::string_view("\\"); | ||
} else { | ||
throw std::invalid_argument(std::string("Internal parser error: Unexpected escape sequence " + std::string(escape_seq))); | ||
} | ||
} | ||
|
||
|
||
constexpr char not_separator_pattern[] = R"_([^ \x09\x0c\x0b])_"; | ||
constexpr char whitespaces_pattern[] = R"_([ \x09\x0c\x0b]+)_"; | ||
constexpr char escape_pattern[] = R"_(\\\\|\\t|\\ |\\f|\\v)_"; | ||
|
||
constexpr regex_term<not_separator_pattern> not_separator("not_separator"); | ||
constexpr regex_term<whitespaces_pattern> whitespaces("whitespace"); | ||
constexpr regex_term<escape_pattern> escape_seq("escape_seq"); | ||
|
||
constexpr nterm<tJvmOptions> text("text"); | ||
constexpr nterm<std::string> option_element("option_element"); | ||
|
||
|
||
constexpr parser jvm_option_parser( | ||
text, | ||
terms(escape_seq, not_separator, whitespaces), | ||
nterms(text, option_element), | ||
rules( | ||
text() | ||
>= [] () {return tJvmOptions();}, | ||
text(option_element) | ||
>= [](auto&& e) { return to_options(std::move(e)); }, | ||
text(text, whitespaces) | ||
>= [](auto&& ob, skip) { return std::move(ob); }, | ||
text(text, whitespaces, option_element) | ||
>= [](auto&& ob, skip, auto&& e) { return add_option(std::move(e), std::move(ob)); }, | ||
option_element(not_separator) | ||
>= [](auto ns) { return std::string(ns); }, | ||
option_element(option_element, not_separator) | ||
>= [](auto &&ob, auto c) { return std::move(ob.append(c)); }, | ||
option_element(option_element, escape_seq) | ||
>= [](auto &&ob, auto es) { return std::move(ob.append(convert_escape_sequence(es))); } | ||
) | ||
); | ||
|
||
|
||
void parseJvmOptions(const std::string & jvmOptions, tJvmOptions& result) { | ||
std::stringstream error_buffer; | ||
auto && res = jvm_option_parser.parse( | ||
parse_options{}.set_skip_whitespace(false), | ||
buffers::string_buffer(jvmOptions.c_str()), | ||
error_buffer); | ||
if (res.has_value()) { | ||
result.insert(result.end(), res.value().begin(), res.value().end()); | ||
} | ||
else { | ||
throw std::invalid_argument(error_buffer.str()); | ||
} | ||
} | ||
|
||
} //namespace JvmOptionsCTPG | ||
|
||
} //namespace JavaScriptOptions | ||
|
||
} //namespace SWIGVMContainers |
26 changes: 26 additions & 0 deletions
26
exaudfclient/base/javacontainer/script_options/parser_ctpg_jvm_options_parser.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef SCRIPTOPTIONLINEPARSERCTPGJVMOPTIONSPARSER_H | ||
#define SCRIPTOPTIONLINEPARSERCTPGJVMOPTIONSPARSER_H 1 | ||
|
||
#include <vector> | ||
#include <string> | ||
|
||
|
||
namespace SWIGVMContainers { | ||
|
||
namespace JavaScriptOptions { | ||
|
||
namespace JvmOptionsCTPG { | ||
|
||
typedef std::vector<std::string> tJvmOptions; | ||
|
||
void parseJvmOptions(const std::string & jvmOptions, tJvmOptions& result); | ||
|
||
|
||
|
||
} //namespace CTPG | ||
|
||
} //namespace JavaScriptOptions | ||
|
||
} //namespace SWIGVMContainers | ||
|
||
#endif //SCRIPTOPTIONLINEPARSERCTPGSCRIPTIMPORTER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters