2013-07-24 13:45:33 +00:00
|
|
|
/*
|
2013-07-25 14:42:02 +00:00
|
|
|
abCExpr.h
|
2013-07-24 13:45:33 +00:00
|
|
|
By: Jeremy Rand
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-07-25 14:42:02 +00:00
|
|
|
#ifndef ABCEXPR_H
|
|
|
|
#define ABCEXPR_H
|
2013-07-24 15:56:02 +00:00
|
|
|
|
|
|
|
|
2013-07-24 13:45:33 +00:00
|
|
|
typedef enum abCalcExprType {
|
2013-07-24 14:30:44 +00:00
|
|
|
abCalcExprTypeMin = 0,
|
|
|
|
abCalcExprTypeReal = 0,
|
|
|
|
abCalcExprTypeInt,
|
|
|
|
|
|
|
|
abCalcExprTypeMax
|
2013-07-24 13:45:33 +00:00
|
|
|
} abCalcExprType;
|
|
|
|
|
|
|
|
|
|
|
|
typedef double abCalcRealType;
|
2013-07-24 15:06:38 +00:00
|
|
|
typedef unsigned long abCalcIntType;
|
2013-07-24 13:45:33 +00:00
|
|
|
|
|
|
|
|
2013-07-24 15:56:02 +00:00
|
|
|
#define AB_CALC_EXPR_MAX_INT_WIDTH ((sizeof(abCalcIntType) * 8))
|
|
|
|
|
2013-07-25 01:02:07 +00:00
|
|
|
#define AB_CALC_EXPR_STRING_MAX (AB_CALC_EXPR_MAX_INT_WIDTH + 8)
|
2013-07-24 15:56:02 +00:00
|
|
|
|
|
|
|
|
2013-07-24 13:45:33 +00:00
|
|
|
typedef struct abCalcExpr {
|
|
|
|
abCalcExprType type;
|
|
|
|
union {
|
|
|
|
abCalcRealType real;
|
|
|
|
abCalcIntType integer;
|
|
|
|
} u;
|
|
|
|
} abCalcExpr;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct abCalcExprCallbacks {
|
2013-07-24 14:30:44 +00:00
|
|
|
abCalcExpr * (*parseExpr)(abCalcExpr *expr, char *buffer);
|
|
|
|
char * (*formatExpr)(abCalcExpr *expr, char *buffer);
|
2013-07-24 13:45:33 +00:00
|
|
|
} abCalcExprCallbacks;
|
2013-07-24 14:30:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
void abCalcExprInit(void);
|
|
|
|
void abCalcRegisterExprType(abCalcExprType type, abCalcExprCallbacks *callbacks);
|
|
|
|
|
|
|
|
abCalcExpr *abCalcParseExpr(abCalcExpr *expr, char *buffer);
|
|
|
|
char *abCalcFormatExpr(abCalcExpr *expr, char *buffer);
|
2013-07-24 15:56:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|