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.c
diff --git
a/parser.c
b/parser.c
index 38b7c2692fad24c3a4c9422caa92d3214ad70c3c..395e2aea1e90642757ab4cf6fb2d891058d479a1 100644
(file)
--- a/
parser.c
+++ b/
parser.c
@@
-21,6
+21,8
@@
double *storage = NULL;
char *format = NULL;
char *minform = NULL;
char *format = NULL;
char *minform = NULL;
+workspace_t *programs = NULL;
+
/* compare codes */
int codecmp (char *ref, char *str)
/* compare codes */
int codecmp (char *ref, char *str)
@@
-122,7
+124,7
@@
keyword_t operators[NB_OPERATORS] = {
{ "|", Or, 2, 1, -2}
};
{ "|", Or, 2, 1, -2}
};
-#define NB_FUNCTIONS
26
+#define NB_FUNCTIONS
31
keyword_t functions[NB_FUNCTIONS] = {
{ "sqrt", Sqr, 1, 4, 5},
{ "pow", Pow, 2, 3, 5},
keyword_t functions[NB_FUNCTIONS] = {
{ "sqrt", Sqr, 1, 4, 5},
{ "pow", Pow, 2, 3, 5},
@@
-149,7
+151,12
@@
keyword_t functions[NB_FUNCTIONS] = {
{ "!", Not, 1, 1, 6},
{ "cond", Cond, 3, 4, 5},
{ "while", While, 2, 5, 5},
{ "!", Not, 1, 1, 6},
{ "cond", Cond, 3, 4, 5},
{ "while", While, 2, 5, 5},
- { "print", Print, 1, 5, 5}
+ { "print", Print, 1, 5, 5},
+ { "prog", Prog, 3, 4, 9},
+ { "call", Call, 10, 4, 5},
+ { "ls", List, 0, 2, 9},
+ { "edit", Edit, 1, 4, 9},
+ { "del", Del, 1, 3, 9}
};
#define NB_CONSTANTS 3
};
#define NB_CONSTANTS 3
@@
-527,6
+534,11
@@
void print_element (element_t *root, int level)
case While: func = "While"; break;
case Prog: func = "Program"; break;
case Print: func = "Print"; break;
case While: func = "While"; break;
case Prog: func = "Program"; break;
case Print: func = "Print"; break;
+ case Prog: func = "Program"; break;
+ case Call: func = "Call"; break;
+ case List: func = "List"; break;
+ case Edit: func = "Edit"; break;
+ case Del: func = "Del"; break;
}
fprintf (stdout, "Function: %s\n", func);
}
fprintf (stdout, "Function: %s\n", func);
@@
-719,6
+731,25
@@
void quit (void)
exit (0);
}
exit (0);
}
+/* program function */
+
+void prog (int id, int nbmems, element_t *root)
+{ }
+
+double call (int id, int nbobs, element_t **ops)
+{
+ return 0;
+}
+
+void list ()
+{ }
+
+void edit (int id)
+{ }
+
+void del (int id)
+{ }
+
/* help message */
void help (void)
/* help message */
void help (void)
@@
-801,6
+832,7
@@
double evaluate_element (element_t *root, char mask)
case Lt:
case And:
case Or:
case Lt:
case And:
case Or:
+ case Prog:
if (root->ops[1]) {
op1 = evaluate_element (root->ops[1], nextmask);
} else if (root->func != Store) {
if (root->ops[1]) {
op1 = evaluate_element (root->ops[1], nextmask);
} else if (root->func != Store) {
@@
-826,6
+858,10
@@
double evaluate_element (element_t *root, char mask)
case Not:
case Mem:
case Cond:
case Not:
case Mem:
case Cond:
+ case Call:
+ case List:
+ case Edit:
+ case Del:
if (root->ops[0]) {
op0 = evaluate_element (root->ops[0], 0);
} else {
if (root->ops[0]) {
op0 = evaluate_element (root->ops[0], 0);
} else {
@@
-906,6
+942,11
@@
double evaluate_element (element_t *root, char mask)
case While: return while_do (root->ops[0], root->ops[1]);
case Prog: return program_do (root->ops, root->nbops);
case Print: return print (op0);
case While: return while_do (root->ops[0], root->ops[1]);
case Prog: return program_do (root->ops, root->nbops);
case Print: return print (op0);
+ case Prog: prog ((int)op0, (int)op1, root->ops[2]); break;
+ case Call: return call ((int)op0, root->nbops + 1, root->ops + 1);
+ case List: list (); break;
+ case Edit: edit ((int)op0); break;
+ case Del: del (int (op0)); break;
}
return 0;
}
return 0;