|
|
1.1 ! root 1: ! 2: /* ! 3: exprDefs.h ! 4: ! 5: Private defs used by Expression and the parsing modules. ! 6: */ ! 7: ! 8: #import "Expression.h" ! 9: ! 10: /* a type of function term we know how to parse */ ! 11: typedef struct _Function { ! 12: char *name; ! 13: int minArgs; ! 14: int maxArgs; ! 15: EXPTermEvalFunc *evalFunc; ! 16: } Function; ! 17: ! 18: typedef enum { /* various types of terms we know about */ ! 19: constantTerm = 1, ! 20: varTerm = 2, ! 21: vectorTerm = 4, ! 22: binOpTerm = 8, ! 23: funcTerm = 16 ! 24: } TermTag; ! 25: ! 26: /* a term of an expression. ! 27: Note that even if a constant is an integer, we store it as a float. This ! 28: ensures that divide by zero results in NaN ("not a number", a special ! 29: floating point value) instead of a coredump due to an arithmetic exception. ! 30: */ ! 31: typedef struct _EXPTerm { ! 32: TermTag tag; /* type of term */ ! 33: union { ! 34: struct { ! 35: BOOL isInt; /* is this an integer? */ ! 36: float val; /* the constant value */ ! 37: } constant; ! 38: struct { ! 39: char *name; /* name of var */ ! 40: float val; /* value of var */ ! 41: } var; ! 42: struct { ! 43: BOOL hasRange; /* do we calc the vector or the range? */ ! 44: BOOL changed; /* do we need to recalc? */ ! 45: short dimension; /* dimension within which we vary */ ! 46: char *name; /* name of var */ ! 47: int resolution; /* last resolution we calc'ed at */ ! 48: float min; /* range of values */ ! 49: float max; ! 50: float *vals; /* list of values */ ! 51: } vector; ! 52: struct { ! 53: char op; /* char representing op (e.g. '+', '-',...) */ ! 54: } binOp; ! 55: struct { ! 56: Function *type; /* info for this type of function */ ! 57: } func; ! 58: } data; ! 59: int numSubterms; /* number of subTerms from parse */ ! 60: struct _EXPTerm *subterms[1]; /* the subTerms */ ! 61: } Term; ! 62: ! 63: ! 64: typedef struct _TermList { /* a list of terms */ ! 65: int num; ! 66: Term *terms[1]; ! 67: } TermList; ! 68: ! 69: ! 70: /* declaration of functions shared between the parsing modules */ ! 71: ! 72: extern Term *_EXPAllocTerm(NXZone *zone, TermTag tag, int numSubterms, ...); ! 73: extern void _EXPFreeTerm(void *info, Term *data); ! 74: extern BOOL _EXPParseExpression(const char *text, NXHashTable *validTerms, Term **parseTree, NXHashTable *varTerms, NXZone *zone); ! 75: extern void _EXPPrepareToScan(const char *text);
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.