X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=parser.h;h=80fbd984ca68fe213910df0496f3a7d112908f74;hb=686c4bc2a512a57b6c672792b6b44e2d61458dfb;hp=7d486a330c764bc3aecd2bbe32e01eb79a85b5bf;hpb=0b489a77ab06263674d1f4376c3bf6c2ead42cd6;p=calc.git diff --git a/parser.h b/parser.h index 7d486a3..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, Set, + 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,6 +28,7 @@ typedef struct _keyword_t { func_t func; int nbops; int offset; + float prio; } keyword_t; /* calculus element type */ @@ -28,17 +38,22 @@ 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, char **next); +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: */