MCPcopy Create free account
hub / github.com/catboost/catboost / ParseFunction

Method ParseFunction

contrib/libs/flatbuffers/src/idl_parser.cpp:2023–2064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2021}
2022
2023CheckedError Parser::ParseFunction(const std::string *name, Value &e) {
2024 ParseDepthGuard depth_guard(this);
2025 ECHECK(depth_guard.Check());
2026
2027 // Copy name, attribute will be changed on NEXT().
2028 const auto functionname = attribute_;
2029 if (!IsFloat(e.type.base_type)) {
2030 return Error(functionname + ": type of argument mismatch, expecting: " +
2031 TypeName(BASE_TYPE_DOUBLE) +
2032 ", found: " + TypeName(e.type.base_type) +
2033 ", name: " + (name ? *name : "") + ", value: " + e.constant);
2034 }
2035 NEXT();
2036 EXPECT('(');
2037 ECHECK(ParseSingleValue(name, e, false));
2038 EXPECT(')');
2039 // calculate with double precision
2040 double x, y = 0.0;
2041 ECHECK(atot(e.constant.c_str(), *this, &x));
2042 // clang-format off
2043 auto func_match = false;
2044 #define FLATBUFFERS_FN_DOUBLE(name, op) \
2045 if (!func_match && functionname == name) { y = op; func_match = true; }
2046 FLATBUFFERS_FN_DOUBLE("deg", x / kPi * 180);
2047 FLATBUFFERS_FN_DOUBLE("rad", x * kPi / 180);
2048 FLATBUFFERS_FN_DOUBLE("sin", sin(x));
2049 FLATBUFFERS_FN_DOUBLE("cos", cos(x));
2050 FLATBUFFERS_FN_DOUBLE("tan", tan(x));
2051 FLATBUFFERS_FN_DOUBLE("asin", asin(x));
2052 FLATBUFFERS_FN_DOUBLE("acos", acos(x));
2053 FLATBUFFERS_FN_DOUBLE("atan", atan(x));
2054 // TODO(wvo): add more useful conversion functions here.
2055 #undef FLATBUFFERS_FN_DOUBLE
2056 // clang-format on
2057 if (true != func_match) {
2058 return Error(std::string("Unknown conversion function: ") + functionname +
2059 ", field name: " + (name ? *name : "") +
2060 ", value: " + e.constant);
2061 }
2062 e.constant = NumToString(y);
2063 return NoError();
2064}
2065
2066CheckedError Parser::TryTypedValue(const std::string *name, int dtoken,
2067 bool check, Value &e, BaseType req,

Callers

nothing calls this directly

Calls 15

atotFunction · 0.85
NumToStringFunction · 0.85
NoErrorFunction · 0.85
ErrorFunction · 0.70
IsFloatFunction · 0.50
TypeNameFunction · 0.50
sinFunction · 0.50
cosFunction · 0.50
tanFunction · 0.50
asinFunction · 0.50
acosFunction · 0.50
atanFunction · 0.50

Tested by

no test coverage detected