#include "parser.h"
+/* global variables */
+
+double answer = 0;
+
/* compare codes */
int codecmp (char *ref, char *str)
{ "help", Help, 0, 4, 5}
};
-#define NB_CONSTANTS 2
+#define NB_CONSTANTS 3
keyword_t constants[NB_CONSTANTS] = {
- { "e", E, 0, 1, 5},
- { "pi", Pi, 0, 2, 5}
+ { "ans", Ans, 0, 3, 5},
+ { "e", E, 0, 1, 5},
+ { "pi", Pi, 0, 2, 5}
};
/* subparser function */
if (codecmp (constant->keyword, str) == 0) {
VERBOSE (DEBUG, fprintf (stdout, "start processing constant\n"));
if (root == NULL) {
- VERBOSE (INFO, fprintf (stdout, "Func: %d\n", constant->func));
+ VERBOSE (INFO, fprintf (stdout, "Const: %d\n", constant->func));
new = newelement (constant->func, constant->nbops, constant->prio);
if (new == NULL) {
return ERROR_OP;
case Exp: func = "Exponantial"; break;
case Quit: func = "Quit"; break;
case Help: func = "Help"; break;
+ case Ans: func = "Ans"; break;
case Pi: func = "Pi"; break;
case E: func = "E"; break;
}
break;
case Quit:
case Help:
+ case Ans:
case Pi:
case E:
break;
case Exp: return exp (op0);
case Quit: quit (); break;
case Help: help (); break;
+ case Ans: return answer;
case Pi: return M_PI;
case E: return M_E;
}