abCalc/expr/abCExpr.h

52 lines
1009 B
C
Raw Normal View History

2013-07-24 13:45:33 +00:00
/*
abCExpr.h
2013-07-24 13:45:33 +00:00
By: Jeremy Rand
*/
#ifndef ABCEXPR_H
#define ABCEXPR_H
2013-07-24 13:45:33 +00:00
typedef enum abCalcExprType {
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
#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 13:45:33 +00:00
typedef struct abCalcExpr {
abCalcExprType type;
union {
abCalcRealType real;
abCalcIntType integer;
} u;
} abCalcExpr;
typedef struct abCalcExprCallbacks {
abCalcExpr * (*parseExpr)(abCalcExpr *expr, char *buffer);
char * (*formatExpr)(abCalcExpr *expr, char *buffer);
2013-07-24 13:45:33 +00:00
} abCalcExprCallbacks;
void abCalcExprInit(void);
void abCalcRegisterExprType(abCalcExprType type, abCalcExprCallbacks *callbacks);
abCalcExpr *abCalcParseExpr(abCalcExpr *expr, char *buffer);
char *abCalcFormatExpr(abCalcExpr *expr, char *buffer);
#endif