help correction
[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,
9e52bbc5 15 Cos, Sin, Tan, Acos, Asin, Atan,
2a986c8f 16 Ln, Log, Exp,
72b7d4bc 17 Erfc, Erf,
9e52bbc5 18 Abs, Ceil, Floor,
143f91ae 19 Store, Recall, Inc, Dec, Disp, Mem, Clear,
471da7c9 20 Quit, Help,
7fe742c9 21 Ans, E, Pi,
ca3e2a2f 22 Equal, Diff, Ge, Le, Gt, Lt,
94b4e517 23 And, Or, Not,
05aabb97 24 Cond, While, Code, Print,
c7cbb833 25 Prog, Call, List, Edit, Del
bc97a989
LM
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;
ca3e2a2f 35 float prio;
bc97a989
LM
36} keyword_t;
37
38/* calculus element type */
39
bc97a989
LM
40typedef struct _element_t {
41 func_t func;
42 int nbops;
0c95a3d3 43 struct _element_t **ops;
fd88e359 44 double value;
11cda8d7 45 int prio;
2d0cd54c 46 int hidden;
779282bb 47 char *string;
bc97a989
LM
48} element_t;
49
0b489a77
LM
50#define ERROR_OP ((element_t *)(-1))
51
c7cbb833
LM
52/* workspace type */
53
54typedef struct _workspace_t {
55 int id;
56 double answer;
57 double *storage;
05aabb97 58 int storage_size;
c7cbb833 59 element_t *root;
2e34899a 60 char *string;
c7cbb833
LM
61} workspace_t;
62
bc97a989
LM
63/* parser function */
64
031d7bba
LM
65void delelement (element_t *root);
66
ef37d966 67element_t *parser (char *str, char **next, int prio);
bc97a989
LM
68
69void print_element (element_t *root, int level);
70
3b4b0bbe 71double evaluate_element (element_t *root, char mask);
f2927108 72
b9c1c40d
LM
73/* completion functions */
74
75char **generate_completion_list ();
76
77void free_completion_list (char **list);
78
2a5ec9d1
LM
79/* print function */
80
81void set_format (char *prompt, int precision);
82
83void free_format ();
84
85double print (double value);
86
bc97a989
LM
87#endif /* __PARSER_H__ */
88
89/* vim: set ts=4 sw=4 et: */