Returns a securer::securer_tool() that evaluates mathematical
expressions safely via AST validation.
Details
The calculator tool evaluates mathematical expressions in a restricted environment. Only the following functions and operators are allowed:
Arithmetic:
+,-,*,/,^,%%,%/%Math:
sqrt,abs,log,log2,log10,exp,ceiling,floor,round,truncTrigonometry:
sin,cos,tan,asin,acos,atanAggregation:
sum,mean,max,min,lengthUtilities:
c,pi
Expressions are first parsed and validated via an AST walk that rejects
any function call or symbol not on the allowlist. Evaluation then occurs
in a minimal environment containing only the allowed functions, with
emptyenv() as its parent to prevent access to other R functionality.
See also
Other tool factories:
data_profile_tool(),
fetch_url_tool(),
plot_tool(),
query_sql_tool(),
r_help_tool(),
read_file_tool(),
write_file_tool()