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