partial implementation of edit
[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, Code, Print,
24 Prog, Call, List, Edit, Del
25} func_t;
26
27/* keyword type */
28
29typedef struct _keyword_t {
30 char *keyword;
31 func_t func;
32 int nbops;
33 int offset;
34 float prio;
35} keyword_t;
36
37/* calculus element type */
38
39typedef struct _element_t {
40 func_t func;
41 int nbops;
42 struct _element_t **ops;
43 double value;
44 int prio;
45 int hidden;
46} element_t;
47
48#define ERROR_OP ((element_t *)(-1))
49
50/* workspace type */
51
52typedef struct _workspace_t {
53 int id;
54 double answer;
55 double *storage;
56 int storage_size;
57 element_t *root;
58 char *string;
59} workspace_t;
60
61/* parser function */
62
63void delelement (element_t *root);
64
65element_t *parser (char *str, char **next, int prio);
66
67void print_element (element_t *root, int level);
68
69double evaluate_element (element_t *root, char mask);
70
71void save_string (int id, char *string);
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: */