Skip to content

Commit ce20195

Browse files
committed
Fixed windows build
1 parent 0a7c710 commit ce20195

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

cucumber_cpp/library/cucumber_expression/test/TestExpressionParser.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "cucumber_cpp/library/cucumber_expression/Ast.hpp"
2-
#include "cucumber_cpp/library/cucumber_expression/Errors.hpp"
32
#include "cucumber_cpp/library/cucumber_expression/ExpressionParser.hpp"
43
#include "yaml-cpp/node/node.h"
54
#include "yaml-cpp/node/parse.h"

cucumber_cpp/library/cucumber_expression/test/TestExpressionTokenizer.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "cucumber_cpp/library/cucumber_expression/Ast.hpp"
2-
#include "cucumber_cpp/library/cucumber_expression/Errors.hpp"
32
#include "cucumber_cpp/library/cucumber_expression/ExpressionTokenizer.hpp"
43
#include "yaml-cpp/node/node.h"
54
#include "yaml-cpp/node/parse.h"
@@ -9,9 +8,7 @@
98
#include <filesystem>
109
#include <format>
1110
#include <gtest/gtest.h>
12-
#include <iostream>
1311
#include <map>
14-
#include <ostream>
1512
#include <string>
1613
#include <string_view>
1714
#include <utility>

cucumber_cpp/library/tag_expression/Parser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace cucumber_cpp::library::tag_expression
2121
void EnsureExpectedTokenType(TokenType tokenType, TokenType expected, std::string_view lastPart)
2222
{
2323
if (tokenType != expected)
24-
throw Error(std::format(R"(Syntax error. Expected {} after {})", tokenTypeMap.at(expected), lastPart));
24+
throw Error(std::format(R"(Syntax error. Expected {} after {})", TokenTypeMap().at(expected), lastPart));
2525
}
2626

2727
void RequireArgCount(const Token& token, std::deque<std::unique_ptr<Expression>>& expressions, std::size_t number)
@@ -116,10 +116,10 @@ namespace cucumber_cpp::library::tag_expression
116116

117117
const Token* SelectToken(std::string_view expression)
118118
{
119-
if (!tokenMap.contains(expression))
119+
if (!TokenMap().contains(expression))
120120
return nullptr;
121121

122-
return &tokenMap.at(expression);
122+
return &TokenMap().at(expression);
123123
}
124124
}
125125

cucumber_cpp/library/tag_expression/Token.hpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,19 @@ namespace cucumber_cpp::library::tag_expression
1616
right
1717
};
1818

19-
inline const std::map<Associative, std::string_view> associativeMap{
20-
{ Associative::left, "left" },
21-
{ Associative::right, "right" },
22-
};
23-
2419
enum struct TokenType
2520
{
2621
operand,
2722
operator_
2823
};
2924

30-
inline const std::map<TokenType, std::string_view> tokenTypeMap{
31-
{ TokenType::operand, "operand" },
32-
{ TokenType::operator_, "operator" },
25+
inline const std::map<TokenType, std::string_view>& TokenTypeMap()
26+
{
27+
static std::map<TokenType, std::string_view> map{
28+
{ TokenType::operand, "operand" },
29+
{ TokenType::operator_, "operator" },
30+
};
31+
return map;
3332
};
3433

3534
struct Token
@@ -60,12 +59,16 @@ namespace cucumber_cpp::library::tag_expression
6059
inline const Token OPEN_PARENTHESIS{ "(", -2, std::nullopt };
6160
inline const Token CLOSE_PARENTHESIS{ ")", -1, std::nullopt };
6261

63-
inline const std::map<std::string_view, const Token&> tokenMap{
64-
{ OR.keyword, OR },
65-
{ AND.keyword, AND },
66-
{ NOT.keyword, NOT },
67-
{ OPEN_PARENTHESIS.keyword, OPEN_PARENTHESIS },
68-
{ CLOSE_PARENTHESIS.keyword, CLOSE_PARENTHESIS }
62+
inline const std::map<std::string_view, const Token&>& TokenMap()
63+
{
64+
static std::map<std::string_view, const Token&> map{
65+
{ OR.keyword, OR },
66+
{ AND.keyword, AND },
67+
{ NOT.keyword, NOT },
68+
{ OPEN_PARENTHESIS.keyword, OPEN_PARENTHESIS },
69+
{ CLOSE_PARENTHESIS.keyword, CLOSE_PARENTHESIS }
70+
};
71+
return map;
6972
};
7073
}
7174

0 commit comments

Comments
 (0)