add arg feature
[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,
1e292005 25 Prog, Arg, Call, List, Edit, Del,
a9a3da22 26 Get, Length, Pop, Push, Put, Set, Show
bc97a989
LM
27} func_t;
28
29/* keyword type */
30
31typedef struct _keyword_t {
32 char *keyword;
33 func_t func;
34 int nbops;
35 int offset;
ca3e2a2f 36 float prio;
bc97a989
LM
37} keyword_t;
38
39/* calculus element type */
40
bc97a989
LM
41typedef struct _element_t {
42 func_t func;
43 int nbops;
0c95a3d3 44 struct _element_t **ops;
fd88e359 45 double value;
11cda8d7 46 int prio;
2d0cd54c 47 int hidden;
779282bb 48 char *string;
bc97a989
LM
49} element_t;
50
0b489a77
LM
51#define ERROR_OP ((element_t *)(-1))
52
c7cbb833
LM
53/* workspace type */
54
55typedef struct _workspace_t {
56 int id;
57 double answer;
58 double *storage;
05aabb97 59 int storage_size;
1e292005
LM
60 double *argument;
61 int argument_size;
c7cbb833 62 element_t *root;
a9a3da22
LM
63 double *stack;
64 int stack_size;
2e34899a 65 char *string;
c7cbb833
LM
66} workspace_t;
67
bc97a989
LM
68/* parser function */
69
031d7bba
LM
70void delelement (element_t *root);
71
ef37d966 72element_t *parser (char *str, char **next, int prio);
bc97a989
LM
73
74void print_element (element_t *root, int level);
75
3b4b0bbe 76double evaluate_element (element_t *root, char mask);
f2927108 77
b9c1c40d
LM
78/* completion functions */
79
80char **generate_completion_list ();
81
82void free_completion_list (char **list);
83
2a5ec9d1
LM
84/* print function */
85
86void set_format (char *prompt, int precision);
87
88void free_format ();
89
90double print (double value);
91
bc97a989
LM
92#endif /* __PARSER_H__ */
93
94/* vim: set ts=4 sw=4 et: */