-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
node.h
82 lines (61 loc) · 1.44 KB
/
node.h
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Copyright 2014-2017 Katherine Flavel
*
* See LICENCE for the full copyright terms.
*/
#ifndef KGT_RRD_NODE_H
#define KGT_RRD_NODE_H
enum rrd_features {
FEATURE_RRD_CI_LITERAL = 1 << 0
};
struct node {
enum {
NODE_CI_LITERAL,
NODE_CS_LITERAL,
NODE_RULE,
NODE_PROSE,
NODE_ALT,
NODE_ALT_SKIPPABLE,
NODE_SEQ,
NODE_LOOP
} type;
int invisible;
union {
struct txt literal; /* TODO: point to ast_literal instead */
const char *name; /* TODO: point to ast_rule instead */
const char *prose;
struct list *alt;
struct list *seq;
struct {
struct node *forward;
struct node *backward;
unsigned int min;
unsigned int max;
} loop;
} u;
};
void
node_free(struct node *);
struct node *
node_create_ci_literal(int invisible, const struct txt *literal);
struct node *
node_create_cs_literal(int invisible, const struct txt *literal);
struct node *
node_create_name(int invisible, const char *name);
struct node *
node_create_prose(int invisible, const char *name);
struct node *
node_create_alt(int invisible, struct list *alt);
struct node *
node_create_alt_skippable(int invisible, struct list *alt);
struct node *
node_create_seq(int invisible, struct list *seq);
struct node *
node_create_loop(int invisible, struct node *forward, struct node *backward);
void
node_make_seq(int invisible, struct node **n);
int
node_compare(const struct node *a, const struct node *b);
void
loop_flip(struct node *n);
#endif