summaryrefslogtreecommitdiff
path: root/expr.h
diff options
context:
space:
mode:
Diffstat (limited to 'expr.h')
-rw-r--r--expr.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/expr.h b/expr.h
new file mode 100644
index 0000000..0d7422d
--- /dev/null
+++ b/expr.h
@@ -0,0 +1,61 @@
+typedef struct sheet sheet;
+
+typedef struct expr expr;
+typedef struct value value; /* for recursive case */
+typedef struct postfix postfix;
+
+typedef enum exprType {
+ VALUE,
+ POSTFIX,
+ NESTED,
+} exprType;
+
+typedef enum valueType {
+ NUM,
+ LOC,
+} valueType;
+
+typedef struct loc {
+ int x, y;
+} loc;
+
+typedef struct expr {
+ char *expr;
+ exprType t;
+ union {
+ expr *nested;
+ struct {
+ value *value;
+ postfix *postfix;
+ };
+ };
+} expr;
+
+typedef struct postfix {
+ char op;
+ expr *expr;
+} postfix;
+
+typedef struct value {
+ valueType t;
+ union {
+ int num;
+ loc *loc;
+ };
+} value;
+
+extern char *in;
+extern char *Pin;
+
+char isop(char c);
+void consumeleading(char c);
+expr *parseExpr();
+loc *parseLoc();
+postfix *parsePostfix();
+value *parseValue();
+expr *parseExpr();
+double evalValue(value *v, sheet *s);
+double evalPostfix(value *v, postfix *p, sheet *s);
+double evalExpr(expr *e, sheet *s);
+expr *makeNumber(int n);
+void freeExpr(expr *e);