Soft'N'Design Software
/
projects
/
calc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
very partial program functions
[calc.git]
/
parser.h
diff --git
a/parser.h
b/parser.h
index 26022e5e585a469c67b824484a86912be28bf5f4..4907c67699a74dc69f5655065e5165df7ae8b072 100644
(file)
--- a/
parser.h
+++ b/
parser.h
@@
-1,6
+1,10
@@
#ifndef __PARSER_H__
#define __PARSER_H__
#ifndef __PARSER_H__
#define __PARSER_H__
+/* global variables */
+
+extern double answer;
+
/* function type */
typedef enum {
/* function type */
typedef enum {
@@
-8,9
+12,16
@@
typedef enum {
Add, Sub,
Mul, Div, Mod,
Pow, Sqr,
Add, Sub,
Mul, Div, Mod,
Pow, Sqr,
- Cos, Sin,
At
n,
+ Cos, Sin,
Tan, Acos, Asin, Ata
n,
Log, Exp,
Log, Exp,
- Qui, Hel
+ Abs, Ceil, Floor,
+ Store, Recall, Inc, Dec, Disp, Mem, Clear,
+ Quit, Help,
+ Ans, E, Pi,
+ Equal, Diff, Ge, Le, Gt, Lt,
+ And, Or, Not,
+ Cond, While, Prog, Print,
+ Prog, Call, List, Edit, Del
} func_t;
/* keyword type */
} func_t;
/* keyword type */
@@
-20,30
+31,55
@@
typedef struct _keyword_t {
func_t func;
int nbops;
int offset;
func_t func;
int nbops;
int offset;
-
in
t prio;
+
floa
t prio;
} keyword_t;
/* calculus element type */
} keyword_t;
/* calculus element type */
-#define MAX_OPERANDS 10
typedef struct _element_t {
func_t func;
int nbops;
typedef struct _element_t {
func_t func;
int nbops;
- struct _element_t *
ops[MAX_OPERANDS]
;
-
float
value;
+ struct _element_t *
*ops
;
+
double
value;
int prio;
int prio;
+ int hidden;
} element_t;
#define ERROR_OP ((element_t *)(-1))
} element_t;
#define ERROR_OP ((element_t *)(-1))
+/* workspace type */
+
+typedef struct _workspace_t {
+ int id;
+ double answer;
+ double *storage;
+ element_t *root;
+} workspace_t;
+
/* parser function */
/* parser function */
+void delelement (element_t *root);
+
element_t *parser (char *str, char **next, int prio);
void print_element (element_t *root, int level);
double evaluate_element (element_t *root, char mask);
element_t *parser (char *str, char **next, int prio);
void print_element (element_t *root, int level);
double evaluate_element (element_t *root, char mask);
+/* completion functions */
+
+char **generate_completion_list ();
+
+void free_completion_list (char **list);
+
+/* print function */
+
+void set_format (char *prompt, int precision);
+
+void free_format ();
+
+double print (double value);
+
#endif /* __PARSER_H__ */
/* vim: set ts=4 sw=4 et: */
#endif /* __PARSER_H__ */
/* vim: set ts=4 sw=4 et: */