Loading...
Searching...
No Matches
Once node
Grammar nodes

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

Collaboration diagram for Once node:

## Functions

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.
int | ec_node_once_set_child (struct ec_node *node, struct ec_node *child)
| Set the child of a once node.

## 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.