Libecoli 0.11.1
Extensible COmmand LIne library
Loading...
Searching...
No Matches
Once node

A node that prevents its child from being parsed more than once. More...

Functions

struct ec_nodeec_node_once (const char *id, struct ec_node *child)
int ec_node_once_set_child (struct ec_node *node, struct ec_node *child)

Detailed Description

A node that prevents its child from being parsed more than once.

Configuration Schema

schema once {
node child {
description "The child node.";
}
}

Function Documentation

◆ ec_node_once()

struct ec_node * ec_node_once ( const char * id,
struct ec_node * child )

This node behaves like its child, but prevents it from being parsed more than once.

Example:

many(
or(
once(str("foo")),
str("bar")))

Matches: [], ["foo", "bar"], ["bar", "bar"], ["foo", "bar", "bar"], ... But not: ["foo", "foo"], ["foo", "bar", "foo"], ...

On error, the child is not freed.

Examples
readline/main.c.

◆ ec_node_once_set_child()

int ec_node_once_set_child ( struct ec_node * node,
struct ec_node * child )

Set the child of a once node. On error, the child is freed.