|
Libecoli 0.11.1
Extensible COmmand LIne library
|
A node for parsing and evaluating expressions with operators. More...
Data Structures | |
| struct | ec_node_expr_eval_ops |
Typedefs | |
| typedef int(* | ec_node_expr_eval_var_t) (void **result, void *userctx, const struct ec_pnode *var) |
| typedef int(* | ec_node_expr_eval_pre_op_t) (void **result, void *userctx, void *operand, const struct ec_pnode *operator) |
| typedef int(* | ec_node_expr_eval_post_op_t) (void **result, void *userctx, void *operand, const struct ec_pnode *operator) |
| typedef int(* | ec_node_expr_eval_bin_op_t) (void **result, void *userctx, void *operand1, const struct ec_pnode *operator, void *operand2) |
| typedef int(* | ec_node_expr_eval_parenthesis_t) (void **result, void *userctx, const struct ec_pnode *open_paren, const struct ec_pnode *close_paren, void *value) |
| typedef void(* | ec_node_expr_eval_free_t) (void *result, void *userctx) |
Functions | |
| struct ec_node * | ec_node_expr (const char *id) |
| int | ec_node_expr_set_val_node (struct ec_node *gen_node, struct ec_node *val_node) |
| int | ec_node_expr_add_bin_op (struct ec_node *gen_node, struct ec_node *op) |
| int | ec_node_expr_add_pre_op (struct ec_node *gen_node, struct ec_node *op) |
| int | ec_node_expr_add_post_op (struct ec_node *gen_node, struct ec_node *op) |
| int | ec_node_expr_add_parenthesis (struct ec_node *gen_node, struct ec_node *open, struct ec_node *close) |
| int | ec_node_expr_eval (void **result, const struct ec_node *node, struct ec_pnode *parse, const struct ec_node_expr_eval_ops *ops, void *userctx) |
A node for parsing and evaluating expressions with operators.
Configuration Schema
No configuration schema.
| typedef int(* ec_node_expr_eval_var_t) (void **result, void *userctx, const struct ec_pnode *var) |
Callback function type for evaluating a variable
| result | On success, this pointer must be set by the user to point to a user structure describing the evaluated result. |
| userctx | A user-defined context passed to all callback functions, which can be used to maintain a state or store global information. |
| var | The parse result referencing the variable. |
Definition at line 32 of file node_expr.h.
| typedef int(* ec_node_expr_eval_pre_op_t) (void **result, void *userctx, void *operand, const struct ec_pnode *operator) |
Callback function type for evaluating a prefix-operator
| result | On success, this pointer must be set by the user to point to a user structure describing the evaluated result. |
| userctx | A user-defined context passed to all callback functions, which can be used to maintain a state or store global information. |
| operand | The evaluated expression on which the operation should be applied. |
| operator | The parse result referencing the operator. |
Definition at line 51 of file node_expr.h.
| typedef int(* ec_node_expr_eval_post_op_t) (void **result, void *userctx, void *operand, const struct ec_pnode *operator) |
Callback function type for evaluating a postfix-operator.
Same as ec_node_expr_eval_pre_op_t but for postfix operators.
Definition at line 63 of file node_expr.h.
| typedef int(* ec_node_expr_eval_bin_op_t) (void **result, void *userctx, void *operand1, const struct ec_pnode *operator,void *operand2) |
Callback function type for evaluating a binary operator.
| result | On success, this pointer must be set by the user to point to a user structure describing the evaluated result. |
| userctx | A user-defined context passed to all callback functions. |
| operand1 | The evaluated left operand. |
| operator | The parse result referencing the operator. |
| operand2 | The evaluated right operand. |
Definition at line 88 of file node_expr.h.
| typedef int(* ec_node_expr_eval_parenthesis_t) (void **result, void *userctx, const struct ec_pnode *open_paren, const struct ec_pnode *close_paren, void *value) |
Callback function type for evaluating a parenthesized expression.
| result | On success, this pointer must be set by the user to point to a user structure describing the evaluated result. |
| userctx | A user-defined context passed to all callback functions. |
| open_paren | The parse result referencing the opening parenthesis. |
| close_paren | The parse result referencing the closing parenthesis. |
| value | The evaluated expression inside the parentheses. |
Definition at line 114 of file node_expr.h.
| typedef void(* ec_node_expr_eval_free_t) (void *result, void *userctx) |
Callback function type for freeing an evaluated result.
| result | The result to free. |
| userctx | A user-defined context passed to all callback functions. |
Definition at line 130 of file node_expr.h.
| struct ec_node * ec_node_expr | ( | const char * | id | ) |
Create an expression node.
| id | The node identifier. |
Set the value (terminal) node for an expression.
| gen_node | The expression node. |
| val_node | The node matching values. It is consumed and will be freed when the parent is freed, or immediately on error. |
Add a binary operator to an expression node.
| gen_node | The expression node. |
| op | The operator node. It is consumed and will be freed when the parent is freed, or immediately on error. |
Add a prefix operator to an expression node.
| gen_node | The expression node. |
| op | The operator node. It is consumed and will be freed when the parent is freed, or immediately on error. |
Add a postfix operator to an expression node.
| gen_node | The expression node. |
| op | The operator node. It is consumed and will be freed when the parent is freed, or immediately on error. |
| int ec_node_expr_add_parenthesis | ( | struct ec_node * | gen_node, |
| struct ec_node * | open, | ||
| struct ec_node * | close ) |
Add parentheses to an expression node.
| gen_node | The expression node. |
| open | The opening parenthesis node. It is consumed and will be freed when the parent is freed, or immediately on error. |
| close | The closing parenthesis node. It is consumed and will be freed when the parent is freed, or immediately on error. |
| int ec_node_expr_eval | ( | void ** | result, |
| const struct ec_node * | node, | ||
| struct ec_pnode * | parse, | ||
| const struct ec_node_expr_eval_ops * | ops, | ||
| void * | userctx ) |
Evaluate a parsed expression.
| result | On success, this pointer will be set to the evaluated result. |
| node | The expression node. |
| parse | The parse tree to evaluate. |
| ops | The evaluation callbacks. |
| userctx | A user-defined context passed to all callbacks. |