X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=parser.h;h=80fbd984ca68fe213910df0496f3a7d112908f74;hb=686c4bc2a512a57b6c672792b6b44e2d61458dfb;hp=46500073105fd206140e36f2c53979a0309f69d5;hpb=bc97a98979c3378e4f0e962b9c2667fc27239a4d;p=calc.git diff --git a/parser.h b/parser.h index 4650007..80fbd98 100644 --- a/parser.h +++ b/parser.h @@ -1,15 +1,24 @@ #ifndef __PARSER_H__ #define __PARSER_H__ +/* global variables */ + +extern double answer; + /* function type */ typedef enum { - Val = 0, + Val = 0, Sig, Add, Sub, - Mul, Div, Pow, - Sqr, - Cos, Sin, Atn, - Log, Exp + Mul, Div, Mod, + Pow, Sqr, + Cos, Sin, Atan, + Log, Exp, + Store, Recall, Disp, + Quit, Help, + Ans, E, Pi, + Equal, Diff, Ge, Le, Gt, Lt, + And, Or, Not } func_t; /* keyword type */ @@ -19,24 +28,32 @@ typedef struct _keyword_t { func_t func; int nbops; int offset; + float 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; + double value; + int prio; } element_t; +#define ERROR_OP ((element_t *)(-1)) + /* parser function */ -element_t *parser (char *str); +void delelement (element_t *root); + +element_t *parser (char *str, char **next, int prio); void print_element (element_t *root, int level); +double evaluate_element (element_t *root, char mask); + #endif /* __PARSER_H__ */ /* vim: set ts=4 sw=4 et: */