X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=parser.h;h=95ee0e594176d6ef31e02e238a2ca00fb6c83ae6;hb=532af887a1892cf5a75d86c487d257609f84dd18;hp=90dba49323fe032e7cfd7ce184d2d174a964bbdc;hpb=031d7bba7849b5b5ec7d1110f830175cc3b65b44;p=calc.git diff --git a/parser.h b/parser.h index 90dba49..95ee0e5 100644 --- a/parser.h +++ b/parser.h @@ -1,6 +1,10 @@ #ifndef __PARSER_H__ #define __PARSER_H__ +/* global variables */ + +extern double answer; + /* function type */ typedef enum { @@ -8,9 +12,17 @@ typedef enum { Add, Sub, Mul, Div, Mod, Pow, Sqr, - Cos, Sin, Atn, - Log, Exp, - Qui, Hel + Cos, Sin, Tan, Acos, Asin, Atan, + Ln, Log, Exp, + Erfc, Erf, + Abs, Ceil, Floor, + Store, Recall, Inc, Dec, Disp, Mem, Clear, + Quit, Help, + Ans, E, Pi, + Equal, Diff, Ge, Le, Gt, Lt, + And, Or, Not, + Cond, While, Code, Print, + Prog, Call, List, Edit, Del } func_t; /* keyword type */ @@ -20,22 +32,34 @@ typedef struct _keyword_t { func_t func; int nbops; int offset; - int prio; + float prio; } keyword_t; /* calculus element type */ -#define MAX_OPERANDS 10 typedef struct _element_t { func_t func; int nbops; - struct _element_t *ops[MAX_OPERANDS]; - float value; + struct _element_t **ops; + double value; int prio; + int hidden; + char *string; } element_t; #define ERROR_OP ((element_t *)(-1)) +/* workspace type */ + +typedef struct _workspace_t { + int id; + double answer; + double *storage; + int storage_size; + element_t *root; + char *string; +} workspace_t; + /* parser function */ void delelement (element_t *root); @@ -46,6 +70,20 @@ void print_element (element_t *root, int level); double evaluate_element (element_t *root, char mask); +/* completion functions */ + +char **generate_completion_list (); + +void free_completion_list (char **list); + +/* print function */ + +void set_format (char *prompt, int precision); + +void free_format (); + +double print (double value); + #endif /* __PARSER_H__ */ /* vim: set ts=4 sw=4 et: */