help correction
[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 Ln, Log, Exp,
17 Erfc, Erf,
18 Abs, Ceil, Floor,
19 Store, Recall, Inc, Dec, Disp, Mem, Clear,
20 Quit, Help,
21 Ans, E, Pi,
22 Equal, Diff, Ge, Le, Gt, Lt,
23 And, Or, Not,
24 Cond, While, Code, Print,
25 Prog, Call, List, Edit, Del
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 int hidden;
47 char *string;
48} element_t;
49
50#define ERROR_OP ((element_t *)(-1))
51
52/* workspace type */
53
54typedef struct _workspace_t {
55 int id;
56 double answer;
57 double *storage;
58 int storage_size;
59 element_t *root;
60 char *string;
61} workspace_t;
62
63/* parser function */
64
65void delelement (element_t *root);
66
67element_t *parser (char *str, char **next, int prio);
68
69void print_element (element_t *root, int level);
70
71double evaluate_element (element_t *root, char mask);
72
73/* completion functions */
74
75char **generate_completion_list ();
76
77void free_completion_list (char **list);
78
79/* print function */
80
81void set_format (char *prompt, int precision);
82
83void free_format ();
84
85double print (double value);
86
87#endif /* __PARSER_H__ */
88
89/* vim: set ts=4 sw=4 et: */