cctools
Functions
jx_eval.h File Reference

Implements evaluation of JX expressions. More...

#include "jx.h"

Go to the source code of this file.

Functions

struct jxjx_eval (struct jx *j, struct jx *context)
 Evaluate an expression. More...
 
struct jxjx_eval_with_defines (struct jx *j, struct jx *context)
 Evaluate an expression with embedded definitions. More...
 
void jx_eval_enable_external (int enable)
 Enable external functions. More...
 

Detailed Description

Implements evaluation of JX expressions.

Function Documentation

struct jx* jx_eval ( struct jx j,
struct jx context 
)

Evaluate an expression.

Traverses the expression, evaluates all operators and evalutes unbound symbols by looking for matches in the context object.

Parameters
jThe expression to evaluate.
contextAn object in which values will be found.
Returns
A newly created result expression, which must be deleted with jx_delete. If the expression is invalid in some way, an object of type JX_NULL is returned.
struct jx* jx_eval_with_defines ( struct jx j,
struct jx context 
)

Evaluate an expression with embedded definitions.

Same as jx_eval, except first looks for a "defines" clause and combines that with the context. Allows an expression to have its own bound values, for convenience.

Parameters
jThe expression to evaluate, which may contain a "defines" clause.
contextAn object in which values will be found.
Returns
A newly created result expression, which must be deleted with jx_delete. If the expression is invalid in some way, an object of type JX_NULL is returned.
void jx_eval_enable_external ( int  enable)

Enable external functions.

A small number of JX functions make use of "external" context, For safety, these functions are not enabled unless the user first calls jx_eval_enable_external(1).

Parameters
enableIf non-zero, enable external functions, otherwise disable.