add some coverage tests
[calc.git] / parser.h
... / ...
CommitLineData
1#ifndef __PARSER_H__
2#define __PARSER_H__
3
4/* global variables */
5
6extern double answer;
7
8/* function type */
9
10typedef enum {
11 Val = 0, Sig,
12 Add, Sub,
13 Mul, Div, Mod,
14 Pow, Sqr,
15 Cos, Sin, Atan,
16 Log, Exp,
17 Store, Recall, Inc, Dec, Disp,
18 Quit, Help,
19 Ans, E, Pi,
20 Equal, Diff, Ge, Le, Gt, Lt,
21 And, Or, Not,
22 Cond, While, Prog
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;
32 float prio;
33} keyword_t;
34
35/* calculus element type */
36
37typedef struct _element_t {
38 func_t func;
39 int nbops;
40 struct _element_t **ops;
41 double value;
42 int prio;
43} element_t;
44
45#define ERROR_OP ((element_t *)(-1))
46
47/* parser function */
48
49void delelement (element_t *root);
50
51element_t *parser (char *str, char **next, int prio);
52
53void print_element (element_t *root, int level);
54
55double evaluate_element (element_t *root, char mask);
56
57#endif /* __PARSER_H__ */
58
59/* vim: set ts=4 sw=4 et: */