yambar/particles/map.h
Leonardo Gibrowski Faé 4a41d4296a
Implement '&&' and '||' operators on map
'-' is a valid character for tags.

Commit 03e1c7d (module/network: Add link stats, 2022-04-30) introduced
two new tags for the network module: `ul-speed` and `dl-speed`. These
use the `-` character, that was previously never used in any tag.

We had two options: either change those tags to use `_` instead, or just
accept `-`s as a valid character. Going forward, I can see many people
deciding to name their tags with `-` instead of `_`, so I believe it is
better to just accept it once and for all.

Note that `-` cannot be used as the first character of a tag (e.g.
`-tag1`) since the `-` has a special meaning in `.yml` files. I don't
believe this will happen often, however, and should be easy to both
detect and correct if it does.
2022-12-10 22:53:30 -03:00

37 lines
690 B
C

#pragma once
enum map_op {
MAP_OP_EQ,
MAP_OP_NE,
MAP_OP_LE,
MAP_OP_LT,
MAP_OP_GE,
MAP_OP_GT,
MAP_OP_SELF,
MAP_OP_NOT,
MAP_OP_AND,
MAP_OP_OR,
};
struct map_condition {
union {
char *tag;
struct map_condition *cond1;
};
enum map_op op;
union {
char *value;
struct map_condition *cond2;
};
};
void free_map_condition(struct map_condition *c);
typedef struct yy_buffer_state* YY_BUFFER_STATE;
YY_BUFFER_STATE yy_scan_string(const char *str);
int yyparse();
void yy_delete_buffer(YY_BUFFER_STATE buffer);
extern struct map_condition *MAP_CONDITION_PARSE_RESULT;
extern char *MAP_PARSER_ERROR_MSG;