mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 11:55:30 +00:00
Fix compiler warning about "old style cast"
This commit is contained in:
parent
5d3d63cf11
commit
5cac962f18
@ -46,8 +46,8 @@ int main(int argc, const char** argv)
|
||||
|
||||
parser["EXPRESSION"] = reduce;
|
||||
parser["TERM"] = reduce;
|
||||
parser["TERM_OPERATOR"] = [](const SemanticValues& sv) { return (char)*sv.c_str(); };
|
||||
parser["FACTOR_OPERATOR"] = [](const SemanticValues& sv) { return (char)*sv.c_str(); };
|
||||
parser["TERM_OPERATOR"] = [](const SemanticValues& sv) { return static_cast<char>(*sv.c_str()); };
|
||||
parser["FACTOR_OPERATOR"] = [](const SemanticValues& sv) { return static_cast<char>(*sv.c_str()); };
|
||||
parser["NUMBER"] = [](const SemanticValues& sv) { return atol(sv.c_str()); };
|
||||
|
||||
auto expr = argv[1];
|
||||
|
@ -49,8 +49,8 @@ int main(int argc, const char** argv)
|
||||
EXPRESSION <= seq(TERM, zom(seq(TERM_OPERATOR, TERM))), reduce;
|
||||
TERM <= seq(FACTOR, zom(seq(FACTOR_OPERATOR, FACTOR))), reduce;
|
||||
FACTOR <= cho(NUMBER, seq(chr('('), EXPRESSION, chr(')')));
|
||||
TERM_OPERATOR <= cls("+-"), [](const SemanticValues& sv) { return (char)*sv.c_str(); };
|
||||
FACTOR_OPERATOR <= cls("*/"), [](const SemanticValues& sv) { return (char)*sv.c_str(); };
|
||||
TERM_OPERATOR <= cls("+-"), [](const SemanticValues& sv) { return static_cast<char>(*sv.c_str()); };
|
||||
FACTOR_OPERATOR <= cls("*/"), [](const SemanticValues& sv) { return static_cast<char>(*sv.c_str()); };
|
||||
NUMBER <= oom(cls("0-9")), [](const SemanticValues& sv) { return atol(sv.c_str()); };
|
||||
|
||||
auto expr = argv[1];
|
||||
|
@ -245,7 +245,7 @@ socket_t create_socket(const char* host, int port, Fn fn)
|
||||
|
||||
// Make 'reuse address' option available
|
||||
int yes = 1;
|
||||
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&yes, sizeof(yes));
|
||||
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char*>(&yes), sizeof(yes));
|
||||
|
||||
// bind or connect
|
||||
if (fn(sock, *rp)) {
|
||||
|
4
peglib.h
4
peglib.h
@ -348,7 +348,7 @@ public:
|
||||
Action& operator=(const Action& rhs) = default;
|
||||
|
||||
operator bool() const {
|
||||
return (bool)fn_;
|
||||
return bool(fn_);
|
||||
}
|
||||
|
||||
any operator()(const SemanticValues& sv, any& dt) const {
|
||||
@ -1518,7 +1518,7 @@ inline void DefinitionReference::accept(Visitor& v) { v.visit(*this); }
|
||||
inline void Whitespace::accept(Visitor& v) { v.visit(*this); }
|
||||
|
||||
inline void AssignIDToDefinition::visit(Holder& ope) {
|
||||
auto p = (void*)ope.outer_;
|
||||
auto p = static_cast<void*>(ope.outer_);
|
||||
if (ids.count(p)) {
|
||||
return;
|
||||
}
|
||||
|
@ -551,8 +551,8 @@ TEST_CASE("Calculator test3", "[general]")
|
||||
// Setup actions
|
||||
parser["EXPRESSION"] = reduce;
|
||||
parser["TERM"] = reduce;
|
||||
parser["TERM_OPERATOR"] = [](const SemanticValues& sv) { return (char)*sv.c_str(); };
|
||||
parser["FACTOR_OPERATOR"] = [](const SemanticValues& sv) { return (char)*sv.c_str(); };
|
||||
parser["TERM_OPERATOR"] = [](const SemanticValues& sv) { return static_cast<char>(*sv.c_str()); };
|
||||
parser["FACTOR_OPERATOR"] = [](const SemanticValues& sv) { return static_cast<char>(*sv.c_str()); };
|
||||
parser["NUMBER"] = [](const SemanticValues& sv) { return stol(sv.str(), nullptr, 10); };
|
||||
|
||||
// Parse
|
||||
|
Loading…
Reference in New Issue
Block a user