#include <util.h>
Go to the source code of this file.
Data Structures | |
struct | element_t |
The type element_t is used to return a stack element. More... | |
Defines | |
#define | PRS_OK 0 |
Return code OK. | |
#define | PRS_ERROR_PAR 1 |
Incorrect parameter passed to the function (e.g. NULL when a pointer is expected). | |
#define | PRS_ERROR_MEMORY 2 |
Unable to allocate an object. | |
#define | PRS_ERROR_VARIABLE 3 |
Variable not initialized. | |
#define | PRS_ERROR_ARG 4 |
Not enough arguments. | |
#define | PRS_ERROR_STACK 5 |
Level out of stack. | |
#define | PRS_ERROR_SLOT_VAR 6 |
No more empty slot for variable. | |
#define | PRS_ERROR_SLOT_FUNC 7 |
No more empty slot for function. | |
#define | PRS_ERROR_NOT_IMPLEMENTED 99 |
The type of the RPL object under processing is currently not supported by HPStack. | |
#define | xNEG 0x39976 |
x -> -x | |
#define | xABS 0x39a07 |
x -> |x| | |
#define | xPLUS 0x39b58 |
x, y -> x + y | |
#define | xMINUS 0x39cfc |
x, y -> x - y | |
#define | xMULTIPLY 0x39de8 |
x, y -> x * y | |
#define | xDIVIDE 0x39f49 |
x, y -> x / y | |
#define | xPOW 0x3a097 |
x, y -> x^y | |
#define | xROOT 0x3a200 |
x, y -> x^(1/y) | |
#define | xSIGN 0x3a3ee |
x -> (x < 0) ? -1 : 1) | |
#define | xSQRT 0x3a442 |
x -> x^(1/2) | |
#define | xSQ 0x3a4ef |
x -> x^2 | |
#define | xSIN 0x3a57c |
x -> sin(x) | |
#define | xCOS 0x3a5d0 |
x -> cos(x) | |
#define | xTAN 0x3a624 |
x -> tan(x) | |
#define | xSINH 0x3a678 |
x -> sinh(x) | |
#define | xCOSH 0x3a6c2 |
x -> cosh(x) | |
#define | xTANH 0x3a70c |
x -> tanh(x) | |
#define | xASIN 0x3a756 |
x -> arcsin(x) | |
#define | xACOS 0x3a7dc |
x -> arccos(x) | |
#define | xATAN 0x3a844 |
x -> arctan(x) | |
#define | xASINH 0x3a88e |
x -> arcsinh(x) | |
#define | xACOSH 0x3a8d8 |
x -> arccosh(x) | |
#define | xATANH 0x3a94f |
x -> arctanh(x) | |
#define | xEXP 0x3a9b7 |
x -> exp(x) | |
#define | xLN 0x3aa01 |
x -> Ln(x) | |
#define | xLOG 0x3aa73 |
x -> Log(x) | |
#define | xALOG 0x3aae5 |
x -> 10^x | |
#define | xFACT 0x3abaf |
x -> x! (Not yet implemented) | |
#define | xIP 0x3ac3d |
x -> int(x) | |
#define | xFP 0x3ac87 |
x -> fract(x) | |
#define | xFLOOR 0x3acd1 |
x -> floor(x) (Not yet implemented) | |
#define | xCEIL 0x3ad1b |
x -> ceil(x) (Not yet implemented) | |
#define | xMOD 0x3afcb |
x, y -> x % y (Not yet implemented) | |
#define | xRAND 0x3b3e6 |
-> random (Not yet implemented) | |
#define | xAND 0x3ca07 |
x, y -> x AND y (Not yet implemented) | |
#define | xOR 0x3ca8d |
x, y -> x OR y (Not yet implemented) | |
#define | xNOT 0x3cb13 |
x -> NOT x (Not yet implemented) | |
#define | xEQ 0x3cbf6 |
x, y -> x XOR y (Not yet implemented)x, y -> x == y | |
#define | xDIFF 0x3cd21 |
x, y -> x != y | |
#define | xLT 0x3ce42 |
x, y -> x < y | |
#define | xGT 0x3cee1 |
x, y -> x > y | |
#define | xLE 0x3cf80 |
x, y -> x <= y | |
#define | xGE 0x3d01f |
x, y -> x >= y | |
#define | xDER 0x3d258 |
f(x) -> df(x)/dx (Not yet implemented)) | |
#define | xINTEGRAL 0x3d47e |
f(x) -> integ(f(x)) | |
#define | xSUM 0x3d503 |
'x', i1, in, f(x) -> sum(x = i1..in, f(x)) | |
#define | C_TypeVal 1 |
#define | C_TypeFunc 2 |
#define | C_TypeIdent 3 |
#define | C_TypeSymb 4 |
Typedefs | |
typedef entry | entry_t |
The type entry_t is used to store an algebraic expression converted into C structure. | |
typedef function | function_t |
typedef stackeval | stackeval_t |
Functions | |
char * | prs_error (int error) |
Returns a string associated with an error code. | |
void | prs_alg_set_angle (int angmode) |
Sets the angular mode for computations. | |
int | prs_alg_create (entry_t **stack, int size) |
Creates a new expression. | |
int | prs_alg_add_val (entry_t *stack, int level, double value) |
Adds a 'double' value to the expression stack. | |
int | prs_alg_add_ident (entry_t *stack, int level, char *ident) |
Adds a variable to the expression stack. | |
int | prs_alg_add_func (entry_t *stack, int level, int code) |
Adds a function to the expression stack. | |
int | prs_alg_add_symb (entry_t *stack, int level, entry_t *expr) |
Adds a symbolic expression to the expression stack. | |
int | prs_alg_eval (entry_t *stack, double *value) |
Evaluates an expression. | |
int | prs_alg_set_var (char *var, double value) |
Sets the value of a variable. | |
int | prs_alg_get_size (entry_t *stack, int *size) |
Gets the size of the expression stack. | |
int | prs_alg_set_size (entry_t *stack, int size) |
Sets the size of the expression stack. | |
int | prs_alg_first_var (entry_t *stack, char **name) |
Gets the first variable used by an expression. | |
int | prs_alg_next_var (entry_t *stack, char **name) |
Gets the next variable used by an expression. | |
int | prs_alg_get_element (entry_t *stack, int level, element_t *element) |
Gets the element stored at a given level of the C stack. | |
function_t * | prs_alg_func_create (int code, int nbarg, void *newfunc) |
Adds a new function to the list of functions recognized by the parser. | |
int | prs_alg_func_reg (function_t *newfunc, function_t **oldfunc) |
Adds a new function to the list of functions recognized by the parser. |
Definition in file hpparser.h.
int prs_alg_add_func | ( | entry_t * | stack, | |
int | level, | |||
int | code | |||
) |
Adds a function to the expression stack.
This function adds a function at the indicated level of the expression stack
stack | Pointer to the C stack | |
level | Level at which put the function, if 0 : the function is put on top of stack | |
code | RPL code (address) of the function |
int prs_alg_add_ident | ( | entry_t * | stack, | |
int | level, | |||
char * | ident | |||
) |
Adds a variable to the expression stack.
This function adds a variable at the indicated level of the expression stack
stack | Pointer to the C stack | |
level | Level at which put the ident, if 0 : the ident is put on top of stack | |
ident | Variable name |
Adds a symbolic expression to the expression stack.
This function adds a function at the indicated level of the expression stack
stack | Pointer to the C stack | |
level | Level at which put the expression, if 0 : the expression is put on top of stack | |
code | RPL code (address) of the function |
int prs_alg_add_val | ( | entry_t * | stack, | |
int | level, | |||
double | value | |||
) |
Adds a 'double' value to the expression stack.
This function adds a numerical value at the indicated level of the expression stack
stack | Pointer to the C stack | |
level | Level at which put the value, if 0 : the value is put on top of stack | |
value | Value to add |
int prs_alg_create | ( | entry_t ** | stack, | |
int | size | |||
) |
Creates a new expression.
This function creates a C stack for storing an expression.
stack | Pointer to the C stack | |
size | Maximum number of terms in the expression (could be arbitrarily large) |
int prs_alg_eval | ( | entry_t * | stack, | |
double * | value | |||
) |
Evaluates an expression.
This function evaluates the expression stored as a stack
stack | Pointer to the C stack | |
value | Result of the evaluation |
int prs_alg_first_var | ( | entry_t * | stack, | |
char ** | name | |||
) |
Gets the first variable used by an expression.
This function gets the first variable used by an expression. If the 'stack' parameter is set to NULL, the list of all the variables is considered.
stack | Pointer to the C stack | |
name | Name of the variable |
function_t* prs_alg_func_create | ( | int | code, | |
int | nbarg, | |||
void * | newfunc | |||
) |
Adds a new function to the list of functions recognized by the parser.
This function adds a new function identified by the 'code' to the list of the parser. If a function with the same 'code' already exists, it is returned in 'oldfunc'.
code | Code of the function (e.g. xSIN) | |
nbarg | Number of arguments of the function | |
newfunc | Pointer to the function procedure | |
oldfunc | Pointer to a structure for storing old definition (if any). Ignored if set to NULL. |
int prs_alg_func_reg | ( | function_t * | newfunc, | |
function_t ** | oldfunc | |||
) |
Adds a new function to the list of functions recognized by the parser.
This function adds a new function identified by the 'code' to the list of the parser. If a function with the same 'code' already exists, it is returned in 'oldfunc'.
code | Code of the function (e.g. xSIN) | |
nbarg | Number of arguments of the function | |
newfunc | Pointer to the function procedure | |
oldfunc | Pointer to a structure for storing old definition (if any). Ignored if set to NULL. |
Gets the element stored at a given level of the C stack.
This function gets the element stored at the 'level' of the C stack.
name | Name of the variable | |
level | Level of the C stack | |
element | Element to return (must be allocated by the caller, except name string if the element is an ident |
int prs_alg_get_size | ( | entry_t * | stack, | |
int * | size | |||
) |
Gets the size of the expression stack.
This function gets the size of the expression stack
stack | Pointer to the C stack | |
size | Stack size |
int prs_alg_next_var | ( | entry_t * | stack, | |
char ** | name | |||
) |
Gets the next variable used by an expression.
This function gets the next variable used by an expression. prs_alg_first_var must have been called before, for the same expressions. If the 'stack' parameter is set to NULL, the list of all the variables is considered.
stack | Pointer to the C stack | |
name | Name of the variable |
void prs_alg_set_angle | ( | int | angmode | ) |
Sets the angular mode for computations.
This function sets the angular mode (Deg/Rad/Grad) that must be used during computations. NB : By default, Rad is set
angmod | The angular mode : either C_AngDeg, C_AngRad or C_AngGrad |
int prs_alg_set_size | ( | entry_t * | stack, | |
int | size | |||
) |
Sets the size of the expression stack.
This function sets the size of the expression stack
stack | Pointer to the C stack | |
size | Stack size |
int prs_alg_set_var | ( | char * | var, | |
double | value | |||
) |
Sets the value of a variable.
This function sets the value of a variable in the expressiON
var | Variable name | |
value | Variable value |
char* prs_error | ( | int | error | ) |
Returns a string associated with an error code.
This function returns a string describing the error associated with the error code passed as parameter.
error | The error code |