condition feature
[calc.git] / parser.h
CommitLineData
bc97a989
LM
1#ifndef __PARSER_H__
2#define __PARSER_H__
3
5075f6ea
LM
4/* global variables */
5
6extern double answer;
7
bc97a989
LM
8/* function type */
9
10typedef enum {
89cf0955 11 Val = 0, Sig,
bc97a989 12 Add, Sub,
c47a9298
LM
13 Mul, Div, Mod,
14 Pow, Sqr,
471da7c9 15 Cos, Sin, Atan,
3b4b0bbe 16 Log, Exp,
6ba1dd0f 17 Store, Recall, Disp,
471da7c9 18 Quit, Help,
7fe742c9 19 Ans, E, Pi,
ca3e2a2f 20 Equal, Diff, Ge, Le, Gt, Lt,
94b4e517
LM
21 And, Or, Not,
22 Cond
bc97a989
LM
23} func_t;
24
25/* keyword type */
26
27typedef struct _keyword_t {
28 char *keyword;
29 func_t func;
30 int nbops;
31 int offset;
ca3e2a2f 32 float prio;
bc97a989
LM
33} keyword_t;
34
35/* calculus element type */
36
0b489a77 37#define MAX_OPERANDS 10
bc97a989
LM
38typedef struct _element_t {
39 func_t func;
40 int nbops;
41 struct _element_t *ops[MAX_OPERANDS];
fd88e359 42 double value;
11cda8d7 43 int prio;
bc97a989
LM
44} element_t;
45
0b489a77
LM
46#define ERROR_OP ((element_t *)(-1))
47
bc97a989
LM
48/* parser function */
49
031d7bba
LM
50void delelement (element_t *root);
51
ef37d966 52element_t *parser (char *str, char **next, int prio);
bc97a989
LM
53
54void print_element (element_t *root, int level);
55
3b4b0bbe 56double evaluate_element (element_t *root, char mask);
f2927108 57
bc97a989
LM
58#endif /* __PARSER_H__ */
59
60/* vim: set ts=4 sw=4 et: */