Lines Matching defs:expr
64 static unsigned int tokenize(const char *expr, struct tst_expr_tok *last)
69 for (j = i = 0; expr[i]; i++) {
70 switch (expr[i]) {
76 token_cnt += new_tok(&last, &expr[j], i - j);
77 token_cnt += new_tok(&last, &expr[i], 1);
82 token_cnt += new_tok(&last, &expr[j], i - j);
86 while (expr[i+1] != '"' && expr[i+1])
89 if (expr[i+1] == '"')
97 token_cnt += new_tok(&last, &expr[j], i - j);
102 void tst_bool_expr_print(FILE *f, struct tst_expr *expr)
107 for (i = expr->rpn; i; i = i->next) {
122 static void tst_bool_expr_err(FILE *f, struct tst_expr *expr, unsigned int cnt)
127 fprintf(f, "%s", expr->buf->tok);
131 if (expr->buf[i].priv)
135 spaces = expr->buf[i].tok - expr->buf[0].tok;
136 err = expr->buf[i].priv;
221 static int shunting_yard(struct tst_expr *expr, unsigned int cnt)
231 for (i = expr->buf; i < &(expr->buf[cnt]); i++) {
309 if (!check_two(expr->buf[cnt-1].op)) {
310 expr->buf[cnt-1].priv = "Unfinished expression";
330 expr->rpn = out[0];
337 struct tst_expr *tst_bool_expr_parse(const char *expr)
340 unsigned int tok_cnt = tokenize(expr, NULL);
349 tokenize(expr, ret->buf);
362 int tst_bool_expr_eval(struct tst_expr *expr,
369 for (i = expr->rpn; i; i = i->next) {
403 void tst_bool_expr_free(struct tst_expr *expr)
405 free(expr);