api documentation for ec_parse
[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 /**
6  * @defgroup nodes Nodes
7  * @{
8  */
9
10 #ifndef ECOLI_NODE_ONCE_
11 #define ECOLI_NODE_ONCE_
12
13 #include <ecoli_node.h>
14
15 /* This node behaves like its child, but prevent from parsing it several
16  * times.
17  *
18  * Example:
19  *   many(
20  *     or(
21  *       once(str("foo")),
22  *       str("bar")))
23  *
24  *   Matches: [], ["foo", "bar"], ["bar", "bar"], ["foo", "bar", "bar"], ...
25  *   But not: ["foo", "foo"], ["foo", "bar", "foo"], ...
26  */
27
28 /* on error, child is *not* freed */
29 struct ec_node *ec_node_once(const char *id, struct ec_node *child);
30
31 /* on error, child is freed */
32 int ec_node_once_set_child(struct ec_node *node, struct ec_node *child);
33
34 #endif
35
36 /** @} */