166 return NSAPI_EXPRESSION_MUL; |
166 return NSAPI_EXPRESSION_MUL; |
167 } else if(!cx_strcmp(token, cx_str("/"))) { |
167 } else if(!cx_strcmp(token, cx_str("/"))) { |
168 return NSAPI_EXPRESSION_DIV; |
168 return NSAPI_EXPRESSION_DIV; |
169 } else if(!cx_strcmp(token, cx_str("%"))) { |
169 } else if(!cx_strcmp(token, cx_str("%"))) { |
170 return NSAPI_EXPRESSION_MOD; |
170 return NSAPI_EXPRESSION_MOD; |
171 } else if(!cx_strcmp(token, cx_str("not"))) { |
171 } else if(!cx_strcmp(token, cx_str("."))) { |
|
172 return NSAPI_EXPRESSION_STRCAT; |
|
173 } else if(!cx_strcmp(token, cx_str("not")) || !cx_strcmp(token, cx_str("!"))) { |
172 return NSAPI_EXPRESSION_NOT; |
174 return NSAPI_EXPRESSION_NOT; |
173 } else if(!cx_strcmp(token, cx_str("and"))) { |
175 } else if(!cx_strcmp(token, cx_str("and")) || !cx_strcmp(token, cx_str("&&"))) { |
174 return NSAPI_EXPRESSION_AND; |
176 return NSAPI_EXPRESSION_AND; |
175 } else if(!cx_strcmp(token, cx_str("or"))) { |
177 } else if(!cx_strcmp(token, cx_str("or")) || !cx_strcmp(token, cx_str("||"))) { |
176 return NSAPI_EXPRESSION_OR; |
178 return NSAPI_EXPRESSION_OR; |
177 } else if(!cx_strcmp(token, cx_str("xor"))) { |
179 } else if(!cx_strcmp(token, cx_str("xor")) || !cx_strcmp(token, cx_str("^"))) { |
178 return NSAPI_EXPRESSION_XOR; |
180 return NSAPI_EXPRESSION_XOR; |
179 } else if(!cx_strcmp(token, cx_str("=="))) { |
181 } else if(!cx_strcmp(token, cx_str("=="))) { |
180 return NSAPI_EXPRESSION_EQ; |
182 return NSAPI_EXPRESSION_EQ; |
181 } else if(!cx_strcmp(token, cx_str("!="))) { |
183 } else if(!cx_strcmp(token, cx_str("!="))) { |
182 return NSAPI_EXPRESSION_NEQ; |
184 return NSAPI_EXPRESSION_NEQ; |
186 return NSAPI_EXPRESSION_LT; |
188 return NSAPI_EXPRESSION_LT; |
187 } else if(!cx_strcmp(token, cx_str(">="))) { |
189 } else if(!cx_strcmp(token, cx_str(">="))) { |
188 return NSAPI_EXPRESSION_GE; |
190 return NSAPI_EXPRESSION_GE; |
189 } else if(!cx_strcmp(token, cx_str("<="))) { |
191 } else if(!cx_strcmp(token, cx_str("<="))) { |
190 return NSAPI_EXPRESSION_LE; |
192 return NSAPI_EXPRESSION_LE; |
|
193 } else if(!cx_strcmp(token, cx_str("="))) { |
|
194 return NSAPI_EXPRESSION_WILDCARD_MATCH; |
|
195 } else if(!cx_strcmp(token, cx_str("=~"))) { |
|
196 return NSAPI_EXPRESSION_REGEX_MATCH; |
|
197 } else if(!cx_strcmp(token, cx_str("!~"))) { |
|
198 return NSAPI_EXPRESSION_REGEX_MISMATCH; |
|
199 } else if(!cx_strcmp(token, cx_str("defined"))) { |
|
200 return NSAPI_EXPRESSION_VALUE_DEFINED; |
|
201 } else if(!cx_strcmp(token, cx_str("-d"))) { |
|
202 return NSAPI_EXPRESSION_DIR_EXISTS; |
|
203 } else if(!cx_strcmp(token, cx_str("-e"))) { |
|
204 return NSAPI_EXPRESSION_FILE_DIR_EXISTS; |
|
205 } else if(!cx_strcmp(token, cx_str("-f"))) { |
|
206 return NSAPI_EXPRESSION_FILE_EXISTS; |
|
207 } else if(!cx_strcmp(token, cx_str("-l"))) { |
|
208 return NSAPI_EXPRESSION_SYMLINK_EXISTS; |
|
209 } else if(!cx_strcmp(token, cx_str("-r"))) { |
|
210 return NSAPI_EXPRESSION_FILE_READABLE; |
|
211 } else if(!cx_strcmp(token, cx_str("-s"))) { |
|
212 return NSAPI_EXPRESSION_FILE_SIZE; |
191 } |
213 } |
192 return NSAPI_EXPRESSION_NOOP; |
214 return NSAPI_EXPRESSION_NOOP; |
193 } |
215 } |
194 |
216 |
195 static int token_is_int(cxstring token) { |
217 static int token_is_int(cxstring token) { |
278 } |
300 } |
279 |
301 |
280 exp->type = NSAPI_EXPRESSION_UNARY; |
302 exp->type = NSAPI_EXPRESSION_UNARY; |
281 exp->left = expr_parser_pop(parser); |
303 exp->left = expr_parser_pop(parser); |
282 exp->right = NULL; |
304 exp->right = NULL; |
|
305 } else if(exp->operator == NSAPI_EXPRESSION_CALL) { |
|
306 // identifiers are added as call, but if they land here, it is |
|
307 // actually just an identifier |
|
308 exp->operator = NSAPI_EXPRESSION_NOOP; |
|
309 exp->left = NULL; |
|
310 exp->right = NULL; |
|
311 exp->type = NSAPI_EXPRESSION_IDENTIFIER; |
|
312 exp->value.identifier = op->identifier; |
283 } else { |
313 } else { |
284 // binary operator |
314 // binary operator |
285 exp->type = NSAPI_EXPRESSION_BINARY; |
315 exp->type = NSAPI_EXPRESSION_BINARY; |
286 exp->right = expr_parser_pop(parser); |
316 exp->right = expr_parser_pop(parser); |
287 exp->left = expr_parser_pop(parser); |
317 exp->left = expr_parser_pop(parser); |
288 } |
318 } |
289 |
319 |
290 if(!exp->left && !exp->right) { |
320 if(!exp->left && !exp->right && exp->operator != NSAPI_EXPRESSION_NOOP) { |
291 return 1; // error |
321 return 1; // error |
292 } |
322 } |
293 |
323 |
294 cxListAdd(parser->ex_stack, &exp); |
324 cxListAdd(parser->ex_stack, &exp); |
295 |
325 |