11 keyword_t operators
[NB_OPERATORS
] = {
12 { "+\t", Add
, 2, 1, 1},
13 { "-\t", Sub
, 2, 1, 1},
18 { "==", Equal
, 2, 2, -1},
19 { "!=", Diff
, 2, 2, -1},
20 { ">=", Ge
, 2, 2, -1},
21 { "<=", Le
, 2, 2, -1},
24 { "&", And
, 2, 1, -2},
28 keyword_t functions
[NB_FUNCTIONS
] = {
29 { "sqrt", Sqr
, 1, 4, 5},
30 { "pow", Pow
, 2, 3, 5},
31 { "cos", Cos
, 1, 3, 5},
32 { "sin", Sin
, 1, 3, 5},
33 { "tan", Tan
, 1, 3, 5},
34 { "acos", Acos
, 1, 4, 5},
35 { "asin", Asin
, 1, 4, 5},
36 { "atan", Atan
, 1, 4, 5},
38 { "log", Log
, 1, 3, 5},
39 { "exp", Exp
, 1, 3, 5},
40 { "erfc", Erfc
, 1, 4, 5},
41 { "erf", Erf
, 1, 3, 5},
42 { "abs", Abs
, 1, 3, 5},
43 { "floor", Floor
, 1, 5, 5},
44 { "ceil", Ceil
, 1, 4, 5},
45 { "sto", Store
, 2, 3, 5},
46 { "rcl", Recall
, 1, 3, 5},
47 { "inc", Inc
, 1, 3, 5},
48 { "dec", Dec
, 1, 3, 5},
49 { "disp", Disp
, 0, 4, 9},
50 { "mem", Memory
, 1, 3, 5},
51 { "clr", Clear
, 0, 3, 9},
52 { "quit", Quit
, 0, 4, 9},
53 { "help", Help
, 0, 4, 9},
54 { "hist", History
, 0, 4, 9},
56 { "cond", Cond
, 3, 4, 5},
57 { "while", While
, 2, 5, 5},
58 { "print", Print
, 1, 5, 5},
59 { "prog", Prog
, 2, 4, 9},
60 { "arg", Arg
, 1, 3, 5},
61 { "call", Call
, MAX_ARGS
, 4, 5},
62 { "ls", List
, 0, 2, 9},
63 { "edit", Edit
, 1, 4, 9},
64 { "del", Del
, 1, 3, 9},
65 { "get", Get
, 1, 3, 5},
66 { "len", Length
, 0, 3, 5},
67 { "pop", Pop
, 0, 3, 5},
68 { "push", Push
, 1, 4, 5},
69 { "put", Put
, 2, 3, 5},
70 { "set", Set
, MAX_ARGS
, 3, 5},
71 { "show", Show
, 0, 4, 5},
72 { "max", Max
, 2, 3, 5},
73 { "mean", Mean
, 2, 4, 5},
74 { "med", Median
, 0, 3, 5},
75 { "min", Min
, 2, 3, 5},
76 { "ord", Order
, 0, 3, 5},
77 { "prod", Prod
, 0, 4, 5},
78 { "sum", Sum
, 0, 3, 5},
79 { "var", Variance
, 2, 3, 5},
80 { "format", Precision
, 1, 6, 9},
81 { "base", Base
, 2, 4, 9},
82 { "deg", Deg
, 0, 3, 9},
83 { "grad", Grad
, 0, 4, 9},
84 { "rad", Rad
, 0, 3, 9}
87 keyword_t constants
[NB_CONSTANTS
] = {
88 { "ans", Ans
, 0, 3, 5},
93 char *symbols
[NB_SYMBOLS
] = {
97 /* allocate new element */
99 element_t
*newelement (func_t function
, int nbops
, int prio
)
101 element_t
*new = (element_t
*) callocordie (1, sizeof (element_t
));
103 new->ops
= (element_t
**) callocordie (nbops
, sizeof (element_t
*));
105 new->func
= function
;
112 /* desallocate element */
114 void delelement (element_t
*root
)
116 if ((root
!= NULL
) && (root
!= ERROR_OP
)) {
118 for (i
= 0; i
< root
->nbops
; i
++) {
119 delelement (root
->ops
[i
]);
128 /* duplicate element */
130 element_t
*dupelement (element_t
*root
)
132 element_t
*tmp
= NULL
;
135 if ((root
== NULL
) || (root
== ERROR_OP
)) {
138 tmp
= newelement (root
->func
, root
->nbops
, root
->prio
);
139 tmp
->value
= root
->value
;
140 for (i
= 0; i
< root
->nbops
; i
++) {
141 tmp
->ops
[i
] = dupelement (root
->ops
[i
]);
146 /* vim: set ts=4 sw=4 et: */