This function attempts to match "expr" against the grammar rule of the same name, and if it succeeds evaluates the parse tree according to the rules used to evaluate parameters.
I have a protytype if you'd like to try it.
This seems too invasive just before the release. I suggest instead to change the default value of IO::out_dir to be something else but $parfile. Since the value $parfile never actually worked, no one is relying on this default.
I agree, and changed the default back. Leaving the ticket open, to get it into the dev-version eventually.
Steve: can you try your prototype and see if it works (with the default being $parfile)? If it does: please post the patch here.
extern "C" void CCTK_EvaluateExpr(const char expr,int *type);
It might be good to add the word "Parameter" somwhere in the function name. For the trigger thorn (ticket ) we also wanted to expose a flesh function to evaluate expressions containing both parameters and grid scalars as variables. The later one might be all fancy and allow the user to choose which variables to expand (parameters, grid scalars, both, none) and even let the caller pass in an extra list of name-value pairs for private variables that one wants to use.
Should the routine CCTK_EvaluateExpr be public or flesh internal (ie CCTK or CCTKi)?
I assume this function would call malloc to store the return value, and expect the caller to free it?
I assume this function is (or will be) also used by the scheduler to evaluate WHILE and IF expressions?
This function seems quite useful; it should be public.
Steven R. Brandt
Adding parameter to the name did occur to me after posting this :) , and yes it does require the user to call free().
I'm not sure that the scheduler needs this, as it can take equations and directly from the CCL file and insert them into C code. I have included CCTK_EvaluateParamExpr available on the Piraha branch.
If you are interested, I have been working on the Piraha interface a bit in general.
In the Piraha branch (https://svn.cactuscode.org/flesh/branches/piraha_schedule) there's a file called Piraha.html which shows, side by side, how to use Piraha in C++, C, and Java. Basically, if you know regex's, it shouldn't be too hard to concoct grammars and parse them.