Skip to content

Commit

Permalink
Fixing some compiler warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
gpdaniels committed Mar 7, 2023
1 parent 5d01bf2 commit fb08d3e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 36 deletions.
6 changes: 3 additions & 3 deletions source/parser/generator
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ namespace gtl {
static_cast<void>(self);
static_cast<void>(forest);
for (ssize_t index = static_cast<ssize_t>(string.size()) - 1; index >= 0; --index) {
branch.pending.push_back(generator::terminal_any(string[index]));
branch.pending.push_back(generator::terminal_any(string[static_cast<size_t>(index)]));
}
});
}
Expand Down Expand Up @@ -689,7 +689,7 @@ namespace gtl {
}

// Remove any failed branches.
forest.branches.erase(std::remove_if(forest.branches.begin(), forest.branches.end(), [&forest](parse_branch_type& branch){
forest.branches.erase(std::remove_if(forest.branches.begin(), forest.branches.end(), [](parse_branch_type& branch){
return (!branch.error.empty());
}), forest.branches.end());

Expand Down Expand Up @@ -788,7 +788,7 @@ namespace gtl {
}

// Remove any failed branches.
forest.branches.erase(std::remove_if(forest.branches.begin(), forest.branches.end(), [&forest](parse_branch_type& branch){
forest.branches.erase(std::remove_if(forest.branches.begin(), forest.branches.end(), [](parse_branch_type& branch){
return (!branch.error.empty());
}), forest.branches.end());

Expand Down
66 changes: 33 additions & 33 deletions tests/parser/generator.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST(parser, element, empty) {
TEST(parser, element, barrier) {
constexpr static const size_t grammar_count = 6;

std::string inputs[grammar_count] = {
std::string test_inputs[grammar_count] = {
R"(0)", // 0
R"(1)", // 1 or 2
R"(4)", // 3 or 4
Expand All @@ -59,10 +59,10 @@ TEST(parser, element, barrier) {
parser::parse_forest_type forests[grammar_count];

for (size_t index = 0; index < grammar_count; ++index) {
const std::string& input = inputs[index];
const std::string& test_input = test_inputs[index];
const parser& grammar = grammars[index];
parser::parse_forest_type& forest = forests[index];
for (char character : input) {
for (char character : test_input) {
grammar.parse(character, forest);
}
std::vector<char> tokens;
Expand All @@ -75,7 +75,7 @@ TEST(parser, element, barrier) {
TEST(parser, element, terminal) {
constexpr static const size_t grammar_count = 7;

std::string inputs[grammar_count] = {
std::string test_inputs[grammar_count] = {
R"(0)", // 0
R"(1)", // 1 or 2
R"(4)", // 3 or 4
Expand All @@ -100,10 +100,10 @@ TEST(parser, element, terminal) {
parser::parse_forest_type forests[grammar_count];

for (size_t index = 0; index < grammar_count; ++index) {
const std::string& input = inputs[index];
const std::string& test_input = test_inputs[index];
const parser& grammar = grammars[index];
parser::parse_forest_type& forest = forests[index];
for (char character : input) {
for (char character : test_input) {
grammar.parse(character, forest);
}
std::vector<char> tokens;
Expand All @@ -115,7 +115,7 @@ TEST(parser, element, terminal) {

TEST(parser, element, sequence) {

std::string input = R"(Ab02)";
std::string test_input = R"(Ab02)";

using parser = gtl::generator<char>;

Expand All @@ -132,7 +132,7 @@ TEST(parser, element, sequence) {
);

parser::parse_forest_type forest;
for (char character : input) {
for (char character : test_input) {
grammar.parse(character, forest);
}
std::vector<char> tokens;
Expand All @@ -143,7 +143,7 @@ TEST(parser, element, sequence) {

TEST(parser, element, disjunction) {

std::string input = R"(Ab02)";
std::string test_input = R"(Ab02)";

using parser = gtl::generator<char>;

Expand All @@ -156,7 +156,7 @@ TEST(parser, element, disjunction) {
);

parser::parse_forest_type forest;
for (char character : input) {
for (char character : test_input) {
grammar.parse(character, forest);
}
std::vector<char> tokens;
Expand All @@ -168,7 +168,7 @@ TEST(parser, element, disjunction) {
TEST(parser, element, recurse) {
constexpr static const size_t grammar_count = 3;

std::string input = R"(TTTTTTTT)";
std::string test_input = R"(TTTTTTTT)";

using parser = gtl::generator<char>;

Expand All @@ -183,7 +183,7 @@ TEST(parser, element, recurse) {
for (size_t index = 0; index < grammar_count; ++index) {
const parser& grammar = grammars[index];
parser::parse_forest_type& forest = forests[index];
for (char character : input) {
for (char character : test_input) {
grammar.parse(character, forest);
}
std::vector<char> tokens;
Expand All @@ -194,14 +194,14 @@ TEST(parser, element, recurse) {
}

TEST(parser, element, repeat) {
std::string input = R"(TTTTTTTT)";
std::string test_input = R"(TTTTTTTT)";

using parser = gtl::generator<char>;

parser grammar = parser::repeat(parser::terminal_any('T'), 8);

parser::parse_forest_type forest;
for (char character : input) {
for (char character : test_input) {
grammar.parse(character, forest);
}
std::vector<char> tokens;
Expand All @@ -213,7 +213,7 @@ TEST(parser, element, repeat) {
TEST(parser, element, emit) {
constexpr static const size_t grammar_count = 8;

std::string inputs[grammar_count] = {
std::string test_inputs[grammar_count] = {
R"()", // No requirement.
R"(0)", // Requires a 0.
R"(1)", // Requires a 1 or 2.
Expand Down Expand Up @@ -251,10 +251,10 @@ TEST(parser, element, emit) {
parser::parse_forest_type forests[grammar_count];

for (size_t index = 0; index < grammar_count; ++index) {
const std::string& input = inputs[index];
const std::string& test_input = test_inputs[index];
const parser& grammar = grammars[index];
parser::parse_forest_type& forest = forests[index];
for (char character : input) {
for (char character : test_input) {
grammar.parse(character, forest);
}
std::vector<char> tokens;
Expand All @@ -271,7 +271,7 @@ TEST(parser, element, emit) {
TEST(parser, element, capture) {
constexpr static const size_t grammar_count = 7;

std::string inputs[grammar_count] = {
std::string test_inputs[grammar_count] = {
R"(0)", // Requires a 0.
R"(1)", // Requires a 1 or 2.
R"(4)", // Requires a 3 or 4.
Expand Down Expand Up @@ -306,10 +306,10 @@ TEST(parser, element, capture) {
parser::parse_forest_type forests[grammar_count];

for (size_t index = 0; index < grammar_count; ++index) {
const std::string& input = inputs[index];
const std::string& test_input = test_inputs[index];
const parser& grammar = grammars[index];
parser::parse_forest_type& forest = forests[index];
for (char character : input) {
for (char character : test_input) {
grammar.parse(character, forest);
}
std::vector<char> tokens;
Expand All @@ -324,7 +324,7 @@ TEST(parser, element, capture) {
}

TEST(parser, element, reference) {
std::string input = R"(TTTTTTTT)";
std::string test_input = R"(TTTTTTTT)";

using parser = gtl::generator<char>;

Expand All @@ -334,7 +334,7 @@ TEST(parser, element, reference) {
grammar = parser::terminal_any('T') + (parser::empty() | parser::reference(grammar));

parser::parse_forest_type forest;
for (char character : input) {
for (char character : test_input) {
grammar.parse(character, forest);
}
std::vector<char> tokens;
Expand All @@ -350,7 +350,7 @@ TEST(parser, element, reference) {
// grammar = (parser::empty() | parser::reference(grammar)) + parser::terminal_any('T');
//
// parser::parse_forest_type forest;
// for (char character : input) {
// for (char character : test_input) {
// grammar.parse(character, forest);
// }
// REQUIRE(grammar.finalise(forest, nullptr, nullptr));
Expand All @@ -359,7 +359,7 @@ TEST(parser, element, reference) {
}

TEST(parser, element, custom) {
std::string input = R"(abc)";
std::string test_input = R"(abc)";

using parser = gtl::generator<char>;

Expand All @@ -374,8 +374,8 @@ TEST(parser, element, custom) {
tracer.push_back(input);
}
) +
parser::terminal_any() + // first input char.
parser::terminal_any() + // second input char.
parser::terminal_any() + // first test_input char.
parser::terminal_any() + // second test_input char.
parser(true, false, [&tracer](char input, parser& self, parser::parse_branch_type& branch, parser::parse_forest_type& forest)->void{
static_cast<void>(input);
static_cast<void>(self);
Expand All @@ -384,14 +384,14 @@ TEST(parser, element, custom) {
tracer.push_back(input);
}
) +
parser::terminal_any(); // third input char.
parser::terminal_any(); // third test_input char.

std::vector<char> expected = {
'a', 'c'
};

parser::parse_forest_type forest;
for (char character : input) {
for (char character : test_input) {
grammar.parse(character, forest);
}
std::vector<char> tokens;
Expand All @@ -402,14 +402,14 @@ TEST(parser, element, custom) {
}

TEST(parser, evaluate, ambiguous) {
std::string input = R"(AB)";
std::string test_input = R"(AB)";

using parser = gtl::generator<std::string>;

gtl::generator grammar = ((parser::terminal("A") >> "A") + (parser::terminal("B") >> "B")) | (parser::terminal("AB") >> "AB");
parser grammar = ((parser::terminal("A") >> "A") + (parser::terminal("B") >> "B")) | (parser::terminal("AB") >> "AB");

parser::parse_forest_type forest;
for (char character : input) {
for (char character : test_input) {
grammar.parse(character, forest);
}
std::vector<std::string> tokens;
Expand Down Expand Up @@ -447,14 +447,14 @@ TEST(parser, evaluate, csv) {
parser header = record;
parser csv = header + record + parser::recurse(record | parser::empty());

std::string input = R"(header cell
std::string test_input = R"(header cell
text,000, 123.456 ,"space "" space", "
line
"
)";

parser::parse_forest_type forest;
for (char character : input) {
for (char character : test_input) {
csv.parse(character, forest);
}
std::vector<std::pair<token_type, std::vector<char>>> tokens;
Expand Down
6 changes: 6 additions & 0 deletions tests/vision/api.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ extern "C" struct gtl_vision_system {
#endif
#endif

GTL_API_STATIC_ASSERT(sizeof(char) == 1, "For ABI compatibility the sizeof(char) must be 1 byte.")
GTL_API_STATIC_ASSERT(sizeof(short int) == 2, "For ABI compatibility the sizeof(short int) must be 2 bytes.")
GTL_API_STATIC_ASSERT(sizeof(int) == 4, "For ABI compatibility the sizeof(int) must be 4 bytes.")
GTL_API_STATIC_ASSERT(sizeof(long long int) == 8, "For ABI compatibility the sizeof(long long int) must be 8 bytes.")
GTL_API_STATIC_ASSERT(sizeof(float) == 4, "For ABI compatibility the sizeof(float) must be 4 bytes.")

extern "C" GTL_API_VISIBILITY gtl_vision_return_enum GTL_API_CALL gtl_vision_create(gtl_vision_system** system) {
if (!system) {
return gtl_vision_return_failure_invalid_system;
Expand Down

0 comments on commit fb08d3e

Please sign in to comment.