- e = expr_create (ds);
- n = parse_or (lexer, e);
- if (n != NULL && type_check (e, &n, type))
- return finish_expression (expr_optimize (n, e), e);
- else
+ e = finish_expression (expr_optimize (n, e), e);
+ if (pool)
+ pool_add_subpool (pool, e->expr_pool);
+ return e;
+}
+
+/* Parses a boolean expression, otherwise similar to expr_parse(). */
+struct expression *
+expr_parse_bool (struct lexer *lexer, struct pool *pool, struct dataset *ds)
+{
+ struct expression *e = expr_create (ds);
+ union any_node *n = parse_or (lexer, e);
+ if (!n)
+ {
+ expr_free (e);
+ return NULL;
+ }
+
+ atom_type actual_type = expr_node_returns (n);
+ if (actual_type == OP_number)
+ n = expr_allocate_binary (e, OP_NUM_TO_BOOLEAN, n,
+ expr_allocate_string (e, ss_empty ()));
+ else if (actual_type != OP_boolean)