efficient priority solution
[calc.git] / parser.h
index 46500073105fd206140e36f2c53979a0309f69d5..767fcf08bdc848c6005157f22368744e5b9e7ea7 100644 (file)
--- a/parser.h
+++ b/parser.h
@@ -4,7 +4,7 @@
 /* function type */
 
 typedef enum {
-    Val = 0,
+    Val = 0, Set,
     Add, Sub,
     Mul, Div, Pow,
     Sqr,
@@ -19,21 +19,25 @@ typedef struct _keyword_t {
     func_t func;
     int nbops;
     int offset;
+    int prio;
 } keyword_t;
 
 /* calculus element type */
 
-#define MAX_OPERANDS 2
+#define MAX_OPERANDS 10
 typedef struct _element_t {
     func_t func;
     int nbops;
     struct _element_t *ops[MAX_OPERANDS];
     float value;
+    int prio;
 } element_t;
 
+#define ERROR_OP ((element_t *)(-1))
+
 /* parser function */
 
-element_t *parser (char *str);
+element_t *parser (char *str, char **next, int prio);
 
 void print_element (element_t *root, int level);