Fix assertion for proper Huffman merge pattern: 0 == 1 modulo 1.
[pspp] / src / expr.def
1 /* One operand, one result. */
2 #define UNARY_OPERATOR(NAME) DEFINE_OPERATOR (NAME, 0, OP_NO_FLAGS, 0)
3
4 /* Two operands, one result. */
5 #define BINARY_OPERATOR(NAME) DEFINE_OPERATOR (NAME, -1, OP_NO_FLAGS, 0)
6
7 /* Three operands, one result. */
8 #define TERNARY_OPERATOR(NAME) DEFINE_OPERATOR (NAME, -2, OP_NO_FLAGS, 0)
9
10 /* Variable operands, one result. */
11 #define NARY_OPERATOR(NAME, FLAGS, ARGS) \
12         DEFINE_OPERATOR (NAME, 0, OP_VAR_ARGS | OP_ABSORB_MISS | (FLAGS), ARGS)
13
14 /* No operands, one result. */
15 #define TERMINAL(NAME, ARGS) DEFINE_OPERATOR (NAME, +1, OP_NO_FLAGS, ARGS)
16
17 /* Basic operators. */
18 BINARY_OPERATOR (ADD)
19 BINARY_OPERATOR (SUB)
20 DEFINE_OPERATOR (MUL, -1, OP_ABSORB_MISS, 0)
21 DEFINE_OPERATOR (DIV, -1, OP_ABSORB_MISS, 0)
22 DEFINE_OPERATOR (MOD, -1, OP_ABSORB_MISS, 0)
23 DEFINE_OPERATOR (POW, -1, OP_ABSORB_MISS, 0)
24 DEFINE_OPERATOR (AND, -1, OP_ABSORB_MISS, 0)
25 DEFINE_OPERATOR (OR, -1, OP_ABSORB_MISS, 0)
26 UNARY_OPERATOR (NOT)
27
28 /* Numeric relational operators. */
29 BINARY_OPERATOR (EQ)
30 BINARY_OPERATOR (GE)
31 BINARY_OPERATOR (GT)
32 BINARY_OPERATOR (LE)
33 BINARY_OPERATOR (LT)
34 BINARY_OPERATOR (NE)
35
36 /* String relational operators. */
37 BINARY_OPERATOR (EQ_STRING)
38 BINARY_OPERATOR (GE_STRING)
39 BINARY_OPERATOR (GT_STRING)
40 BINARY_OPERATOR (LE_STRING)
41 BINARY_OPERATOR (LT_STRING)
42 BINARY_OPERATOR (NE_STRING)
43
44 /* Unary functions. */
45 UNARY_OPERATOR (NEG)
46 UNARY_OPERATOR (ABS)
47 UNARY_OPERATOR (ARCOS)
48 UNARY_OPERATOR (ARSIN)
49 UNARY_OPERATOR (ARTAN)
50 UNARY_OPERATOR (COS)
51 UNARY_OPERATOR (EXP)
52 UNARY_OPERATOR (LG10)
53 UNARY_OPERATOR (LN)
54 UNARY_OPERATOR (MOD10)
55 UNARY_OPERATOR (RND)
56 UNARY_OPERATOR (SIN)
57 UNARY_OPERATOR (SQRT)
58 UNARY_OPERATOR (TAN)
59 UNARY_OPERATOR (TRUNC)
60
61 /* N-ary numeric functions. */
62 NARY_OPERATOR (ANY, 0, 1)
63 NARY_OPERATOR (ANY_STRING, 0, 1)
64 NARY_OPERATOR (CFVAR, OP_MIN_ARGS, 2)
65 NARY_OPERATOR (MAX, OP_MIN_ARGS, 2)
66 NARY_OPERATOR (MAX_STRING, 0, 1)
67 NARY_OPERATOR (MEAN, OP_MIN_ARGS, 2)
68 NARY_OPERATOR (MIN, OP_MIN_ARGS, 2)
69 NARY_OPERATOR (MIN_STRING, 0, 1)
70 NARY_OPERATOR (NMISS, 0, 1)
71 NARY_OPERATOR (NVALID, 0, 1)
72 NARY_OPERATOR (RANGE, 0, 1)
73 NARY_OPERATOR (RANGE_STRING, 0, 1)
74 NARY_OPERATOR (SD, OP_MIN_ARGS, 2)
75 NARY_OPERATOR (SUM, OP_MIN_ARGS, 2)
76 NARY_OPERATOR (VARIANCE, OP_MIN_ARGS, 2)
77
78 /* Time construction & extraction functions. */
79 TERNARY_OPERATOR (TIME_HMS)
80 UNARY_OPERATOR (CTIME_DAYS)
81 UNARY_OPERATOR (CTIME_HOURS)
82 UNARY_OPERATOR (CTIME_MINUTES)
83 UNARY_OPERATOR (CTIME_SECONDS)
84 UNARY_OPERATOR (TIME_DAYS)
85
86 /* Date construction functions. */
87 TERNARY_OPERATOR (DATE_DMY)
88 TERNARY_OPERATOR (DATE_MDY)
89 BINARY_OPERATOR (DATE_MOYR)
90 BINARY_OPERATOR (DATE_QYR)
91 BINARY_OPERATOR (DATE_WKYR)
92 BINARY_OPERATOR (DATE_YRDAY)
93 TERNARY_OPERATOR (YRMODA)
94
95 /* Date extraction functions. */
96 UNARY_OPERATOR (XDATE_DATE)
97 UNARY_OPERATOR (XDATE_HOUR)
98 UNARY_OPERATOR (XDATE_JDAY)
99 UNARY_OPERATOR (XDATE_MDAY)
100 UNARY_OPERATOR (XDATE_MINUTE)
101 UNARY_OPERATOR (XDATE_MONTH)
102 UNARY_OPERATOR (XDATE_QUARTER)
103 UNARY_OPERATOR (XDATE_SECOND)
104 UNARY_OPERATOR (XDATE_TDAY)
105 UNARY_OPERATOR (XDATE_TIME)
106 UNARY_OPERATOR (XDATE_WEEK)
107 UNARY_OPERATOR (XDATE_WKDAY)
108 UNARY_OPERATOR (XDATE_YEAR)
109
110 /* String functions. */
111 NARY_OPERATOR (CONCAT, 0, 0)
112 BINARY_OPERATOR (INDEX_2)
113 TERNARY_OPERATOR (INDEX_3)
114 BINARY_OPERATOR (RINDEX_2)
115 TERNARY_OPERATOR (RINDEX_3)
116 UNARY_OPERATOR (LENGTH)
117 UNARY_OPERATOR (LOWER)
118 UNARY_OPERATOR (UPPER)
119 DEFINE_OPERATOR (LPAD, -2, OP_ABSORB_MISS, 0)
120 DEFINE_OPERATOR (RPAD, -2, OP_ABSORB_MISS, 0)
121 UNARY_OPERATOR (LTRIM)
122 UNARY_OPERATOR (RTRIM)
123 DEFINE_OPERATOR (NUMBER, -1, OP_FMT_SPEC, 3)
124 DEFINE_OPERATOR (STRING, 0, OP_FMT_SPEC | OP_ABSORB_MISS, 3)
125 DEFINE_OPERATOR (SUBSTR_2, -1, OP_ABSORB_MISS, 0)
126 DEFINE_OPERATOR (SUBSTR_3, -2, OP_ABSORB_MISS, 0)
127
128 /* Artificial. */
129 UNARY_OPERATOR (SQUARE)
130 UNARY_OPERATOR (NUM_TO_BOOL)
131
132 /* Weirdness. */
133 UNARY_OPERATOR (NORMAL)
134 UNARY_OPERATOR (UNIFORM)
135 DEFINE_OPERATOR (SYSMIS, 0, OP_ABSORB_MISS, 0)
136 DEFINE_OPERATOR (VEC_ELEM_NUM, 0, OP_MIN_ARGS, 1)
137 DEFINE_OPERATOR (VEC_ELEM_STR, 0, OP_MIN_ARGS, 1)
138
139 /* Terminals. */
140 TERMINAL (NUM_CON, 0)
141 TERMINAL (STR_CON, 0)
142 TERMINAL (NUM_VAR, 0)
143 TERMINAL (STR_VAR, 0)
144 TERMINAL (NUM_LAG, 1)
145 TERMINAL (STR_LAG, 1)
146 TERMINAL (NUM_SYS, 1)
147 TERMINAL (NUM_VAL, 1)
148 TERMINAL (STR_MIS, 1)
149 TERMINAL (CASENUM, 0)
150
151 #undef DEFINE_OPERATOR