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...
 

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.