add ec_node_bypass
[protos/libecoli.git] / include / ecoli_node_once.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2016, Olivier MATZ <zer0@droids-corp.org>
3  */
4
5 #ifndef ECOLI_NODE_ONCE_
6 #define ECOLI_NODE_ONCE_
7
8 #include <ecoli_node.h>
9
10 /* This node behaves like its child, but prevent from parsing it several
11  * times.
12  *
13  * Example:
14  *   many(
15  *     or(
16  *       once(str("foo")),
17  *       str("bar")))
18  *
19  *   Matches: [], ["foo", "bar"], ["bar", "bar"], ["foo", "bar", "bar"], ...
20  *   But not: ["foo", "foo"], ["foo", "bar", "foo"], ...
21  */
22
23 /* on error, child is *not* freed */
24 struct ec_node *ec_node_once(const char *id, struct ec_node *child);
25
26 /* on error, child is freed */
27 int ec_node_once_set_child(struct ec_node *node, struct ec_node *child);
28
29 #endif