37#include "d4_function_parser.tab.hh"
65 std::istringstream iss(expr);
70 parser.set_debug_level(1);
71 parser.set_debug_stream(std::cerr);
74 return parser.parse() == 0;
106 throw InternalErr(__FILE__, __LINE__,
"Must parse() the function expression before calling eval()");
109 for (
auto result : *d_result) {
127 list<D4Dimension *> dim_set;
130 if ((*i)->is_vector_type()) {
131 auto a =
static_cast<Array *
>(*i);
132 for (
auto d = a->dim_begin(), de = a->dim_end(); d != de; ++d) {
136 bool found = (std::find(dim_set.begin(), dim_set.end(), d4_dim) != dim_set.end());
138 dim_set.push_back(a->dimension_D4dim(d));
147 for (
auto dim : dim_set) {
152 list<D4EnumDef *> enum_def_set;
159 for (
auto enum_def : enum_def_set) {
182D4RValue *D4FunctionEvaluator::build_rvalue(
const std::string &
id) {
186 if (top_basetype()) {
187 btp = top_basetype()->
var(
id);
193 return new D4RValue(btp);
197 char *end_ptr =
nullptr;
200 long long ll_val = strtoll(
id.c_str(), &end_ptr, 0);
201 if (*end_ptr ==
'\0' && errno == 0)
202 return new D4RValue(ll_val);
207 unsigned long long ull_val = strtoull(
id.c_str(), &end_ptr, 0);
208 if (*end_ptr ==
'\0' && errno == 0)
209 return new D4RValue(ull_val);
212 double d_val = strtod(
id.c_str(), &end_ptr);
213 if (*end_ptr ==
'\0' && errno == 0)
214 return new D4RValue(d_val);
218 return new D4RValue(
www2id(
id));
226 auto arg_list = make_unique<vector<T>>();
230 arg_list->push_back(val);
232 return arg_list.release();
253 oss << l <<
": " << m << ends;
#define malformed_expr
(400)
A multidimensional array of identical data types.
The basic data type for the DODS DAP types.
virtual BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=nullptr)
Returns a pointer to a member of a constructor class.
void add_var(BaseType *bt, Part part=nil) override
void add_dim(D4Dimension *dim)
void add_enum(D4EnumDef *enum_def)
Holds a DAP4 enumeration.
virtual D4EnumDef * enumeration() const
bool trace_parsing() const
std::vector< t > * init_arg_list(t val)
static void error(const libdap::location &l, const std::string &m)
unsigned long long get_arg_length_hint() const
bool parse(const std::string &expr)
friend class D4FunctionParser
D4RValueList * result() const
BaseType * find_var(const string &name)
D4Dimensions * dims()
Get the dimensions defined for this Group.
D4EnumDefs * enum_defs()
Get the enumerations defined for this Group.
A class for error processing.
A class for software fault reporting.
top level DAP object to house generic methods
string www2id(const string &in, const string &escape, const string &except)
bool is_quoted(const string &s)