eed45f679d14585706f9e5eca3200143c16ac533
[calc.git] / parser.h
1 #ifndef __PARSER_H__
2 #define __PARSER_H__
3
4 /* global variables */
5
6 extern double answer;
7
8 /* function type */
9
10 typedef enum {
11 Val = 0, Sig,
12 Add, Sub,
13 Mul, Div, Mod,
14 Pow, Sqr,
15 Cos, Sin, Tan, Acos, Asin, Atan,
16 Log, Exp,
17 Abs, Ceil, Floor,
18 Store, Recall, Inc, Dec, Disp,
19 Quit, Help,
20 Ans, E, Pi,
21 Equal, Diff, Ge, Le, Gt, Lt,
22 And, Or, Not,
23 Cond, While, Prog, Print
24 } func_t;
25
26 /* keyword type */
27
28 typedef struct _keyword_t {
29 char *keyword;
30 func_t func;
31 int nbops;
32 int offset;
33 float prio;
34 } keyword_t;
35
36 /* calculus element type */
37
38 typedef struct _element_t {
39 func_t func;
40 int nbops;
41 struct _element_t **ops;
42 double value;
43 int prio;
44 int hidden;
45 } element_t;
46
47 #define ERROR_OP ((element_t *)(-1))
48
49 /* parser function */
50
51 void delelement (element_t *root);
52
53 element_t *parser (char *str, char **next, int prio);
54
55 void print_element (element_t *root, int level);
56
57 double evaluate_element (element_t *root, char mask);
58
59 /* completion functions */
60
61 char **generate_completion_list ();
62
63 void free_completion_list (char **list);
64
65 /* print function */
66
67 void set_format (char *prompt, int precision);
68
69 void free_format ();
70
71 double print (double value);
72
73 #endif /* __PARSER_H__ */
74
75 /* vim: set ts=4 sw=4 et: */