move all code relative to readline into separate file (2)
[calc.git] / parser.c
index 4d9b01a23b8a81bb438ba989f9e0df76d85a0ceb..44152a96cc4cb1a5f3fd655642b49de0b863d51e 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -46,100 +46,6 @@ int codecmp (char *ref, char *str)
     return 0;
 }
 
-/* functions */
-
-#define MAX_ARGS 100
-
-#define NB_OPERATORS 14
-keyword_t operators[NB_OPERATORS] = {
-    { "+\t", Add, 2, 1, 1},
-    { "-\t", Sub, 2, 1, 1},
-    { "*",   Mul, 2, 1, 2},
-    { "/",   Div, 2, 1, 2},
-    { "%",   Mod, 2, 1, 3},
-    { "^",   Pow, 2, 1, 4},
-    { "==",  Equal, 2, 2, -1},
-    { "!=",  Diff, 2, 2, -1},
-    { ">=",  Ge, 2, 2, -1},
-    { "<=",  Le, 2, 2, -1},
-    { ">",   Gt, 2, 1, -1},
-    { "<",   Lt, 2, 1, -1},
-    { "&",   And, 2, 1, -2},
-    { "|",   Or, 2, 1, -2}
-};
-
-#define NB_FUNCTIONS 56
-keyword_t functions[NB_FUNCTIONS] = {
-    { "sqrt", Sqr, 1, 4, 5},
-    { "pow",  Pow, 2, 3, 5},
-    { "cos",  Cos, 1, 3, 5},
-    { "sin",  Sin, 1, 3, 5},
-    { "tan",  Tan, 1, 3, 5},
-    { "acos", Acos, 1, 4, 5},
-    { "asin", Asin, 1, 4, 5},
-    { "atan", Atan, 1, 4, 5},
-    { "ln",   Ln, 1, 2, 5},
-    { "log",  Log, 1, 3, 5},
-    { "exp",  Exp, 1, 3, 5},
-    { "erfc", Erfc, 1, 4, 5},
-    { "erf",  Erf, 1, 3, 5},
-    { "abs",  Abs, 1, 3, 5},
-    { "floor", Floor, 1, 5, 5},
-    { "ceil", Ceil, 1, 4, 5},
-    { "sto",  Store, 2, 3, 5},
-    { "rcl",  Recall, 1, 3, 5},
-    { "inc",  Inc, 1, 3, 5},
-    { "dec",  Dec, 1, 3, 5},
-    { "disp", Disp, 0, 4, 9},
-    { "mem",  Memory, 1, 3, 5},
-    { "clr",  Clear, 0, 3, 9},
-    { "quit", Quit, 0, 4, 9},
-    { "help", Help, 0, 4, 9},
-    { "hist", History, 0, 4, 9},
-    { "!",    Not, 1, 1, 6},
-    { "cond", Cond, 3, 4, 5},
-    { "while", While, 2, 5, 5},
-    { "print", Print, 1, 5, 5},
-    { "prog", Prog, 2, 4, 9},
-    { "arg",  Arg, 1, 3, 5},
-    { "call", Call, MAX_ARGS, 4, 5},
-    { "ls",   List, 0, 2, 9},
-    { "edit", Edit, 1, 4, 9},
-    { "del",  Del, 1, 3, 9},
-    { "get",  Get, 1, 3, 5},
-    { "len",  Length, 0, 3, 5},
-    { "pop",  Pop, 0, 3, 5},
-    { "push", Push, 1, 4, 5},
-    { "put",  Put, 2, 3, 5},
-    { "set",  Set, MAX_ARGS, 3, 5},
-    { "show", Show, 0, 4, 5},
-    { "max",  Max, 2, 3, 5},
-    { "mean", Mean, 2, 4, 5},
-    { "med",  Median, 0, 3, 5},
-    { "min",  Min, 2, 3, 5},
-    { "ord",  Order, 0, 3, 5},
-    { "prod", Prod, 0, 4, 5},
-    { "sum",  Sum, 0, 3, 5},
-    { "var",  Variance, 2, 3, 5},
-    { "format", Precision, 1, 6, 9},
-    { "base", Base, 2, 4, 9},
-    { "deg", Deg, 0, 3, 9},
-    { "grad", Grad, 0, 4, 9},
-    { "rad", Rad, 0, 3, 9}
-};
-
-#define NB_CONSTANTS 3
-keyword_t constants[NB_CONSTANTS] = {
-    { "ans", Ans, 0, 3, 5},
-    { "e",   E, 0, 1, 5},
-    { "pi",  Pi, 0, 2, 5}
-};
-
-#define NB_SYMBOLS 4
-char *symbols[NB_SYMBOLS] = {
-    "(", ")", "{", "}"
-};
-
 /* subparser function */
 
 element_t *subparser (element_t **proot, char **pstr, func_t func, int nbops, int prio)
@@ -968,59 +874,4 @@ double evaluate_element (element_t *root, char mask)
     return 0;
 }
 
-char **generate_completion_list ()
-{
-    int i, j, l = 0;
-    char **list = (char **) callocordie (NB_OPERATORS + NB_FUNCTIONS + NB_CONSTANTS + NB_SYMBOLS + 1, sizeof (char *));
-
-    for (i = 0; i < NB_OPERATORS; i++) {
-        list[l] = strdup ((operators + i)->keyword);
-        for (j = 0; j < (int)strlen (list[l]); j++) {
-            if (list[i][j] == '\t') {
-                list[i][j] = '\0';
-            }
-        }
-        if (list[l] != NULL) {
-            l++;
-        }
-    }
-
-    for (i = 0; i < NB_FUNCTIONS; i++) {
-        list[l] = strdup ((functions + i)->keyword);
-        if (list[l] != NULL) {
-            l++;
-        }
-    }
-
-    for (i = 0; i < NB_CONSTANTS; i++) {
-        list[l] = strdup ((constants + i)->keyword);
-        if (list[l] != NULL) {
-            l++;
-        }
-    }
-
-    for (i = 0; i < NB_SYMBOLS; i++) {
-        list[l] = strdup (symbols[i]);
-        if (list[l] != NULL) {
-            l++;
-        }
-    }
-
-    return (list);
-}
-
-void free_completion_list (char **list)
-{
-    int i;
-
-    if (list) {
-        for (i = 0; i < NB_OPERATORS + NB_FUNCTIONS + NB_CONSTANTS + NB_SYMBOLS + 1; i++) {
-            if (list[i] != NULL) {
-                free (list[i]);
-            }
-        }
-        free (list);
-    }
-}
-
 /* vim: set ts=4 sw=4 et: */