[go: up one dir, main page]

File: expr.h

package info (click to toggle)
cmus 2.0.4-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,092 kB
  • ctags: 2,405
  • sloc: ansic: 21,341; sh: 959; makefile: 165
file content (58 lines) | stat: -rw-r--r-- 958 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * Copyright 2005 Timo Hirvonen
 */

#ifndef EXPR_H
#define EXPR_H

#include <track_info.h>
#include <list.h>

enum { OP_LT, OP_LE, OP_EQ, OP_GE, OP_GT, OP_NE };
#define NR_OPS (OP_NE + 1)

enum expr_type {
	EXPR_AND,
	EXPR_OR,

	EXPR_NOT,

	EXPR_STR,
	EXPR_INT,
	EXPR_BOOL
};
#define NR_EXPRS (EXPR_BOOL + 1)

struct expr {
	struct expr *left, *right, *parent;
	enum expr_type type;
	char *key;
	union {
		struct {
			struct list_head glob_head;
			enum {
				SOP_EQ = OP_EQ,
				SOP_NE = OP_NE
			} op;
		} estr;
		struct {
			int val;
			enum {
				IOP_LT = OP_LT,
				IOP_LE = OP_LE,
				IOP_EQ = OP_EQ,
				IOP_GE = OP_GE,
				IOP_GT = OP_GT,
				IOP_NE = OP_NE
			} op;
		} eint;
	};
};

struct expr *expr_parse(const char *str);
int expr_check_leaves(struct expr **exprp, const char *(*get_filter)(const char *name));
int expr_eval(struct expr *expr, struct track_info *ti);
void expr_free(struct expr *expr);
const char *expr_error(void);

#endif