sheets

a simple spread sheet software
Log | Files | Refs

expr.h (954B)


      1 typedef struct sheet sheet;
      2 
      3 typedef struct expr expr; 
      4 typedef struct value value;  /* for recursive case */
      5 typedef struct postfix postfix;
      6 
      7 typedef enum exprType {
      8 	VALUE,
      9 	POSTFIX,	
     10 	NESTED,
     11 } exprType;
     12 
     13 typedef enum valueType {
     14 	NUM,
     15 	LOC,
     16 } valueType;
     17 
     18 typedef struct loc {
     19         int x, y;
     20 } loc;
     21 
     22 typedef struct expr {
     23 	char *expr;
     24 	exprType t;
     25 	union {
     26 		expr *nested;
     27 		struct {
     28 			value *value;
     29 			postfix *postfix;
     30 		};
     31 	};
     32 } expr;
     33 
     34 typedef struct postfix {
     35 	char op;
     36 	expr *expr;
     37 } postfix;
     38 
     39 typedef struct value {
     40 	valueType t;
     41 	union {
     42 		int num;
     43 		loc *loc;
     44 	};
     45 } value;
     46 
     47 extern char *in;
     48 extern char *Pin;
     49 
     50 char isop(char c);
     51 void consumeleading(char c);
     52 expr *parseExpr(); 
     53 loc *parseLoc();
     54 postfix *parsePostfix(); 
     55 value *parseValue(); 
     56 expr *parseExpr(); 
     57 double evalValue(value *v, sheet *s);
     58 double evalPostfix(value *v, postfix *p, sheet *s);
     59 double evalExpr(expr *e, sheet *s); 
     60 expr *makeNumber(int n);
     61 void freeExpr(expr *e);