clear feature
[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, Tan, Acos, Asin, Atan,
16 Log, Exp,
17 Abs, Ceil, Floor,
18 Store, Recall, Inc, Dec, Disp, Mem, Clear,
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
28typedef 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
38typedef 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
51void delelement (element_t *root);
52
53element_t *parser (char *str, char **next, int prio);
54
55void print_element (element_t *root, int level);
56
57double evaluate_element (element_t *root, char mask);
58
59/* completion functions */
60
61char **generate_completion_list ();
62
63void free_completion_list (char **list);
64
65/* print function */
66
67void set_format (char *prompt, int precision);
68
69void free_format ();
70
71double print (double value);
72
73#endif /* __PARSER_H__ */
74
75/* vim: set ts=4 sw=4 et: */