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

A node that matches any subset of its children in any order. More...

Collaboration diagram for Subset node:

## Macros

#define | EC_NODE_SUBSET(args...)
| Create a subset node from a list of child nodes.

## Functions

struct ec_node * | ec_node_subset (const char *id)
| Create an empty subset node.
struct ec_node * | ec_node_subset_min (const char *id, unsigned int min)
| Create an empty subset node with a minimum number of children that must match.
int | ec_node_subset_add (struct ec_node *node, struct ec_node *child)
| Add a child to a subset node.
int | ec_node_subset_set_min (struct ec_node *node, unsigned int min)
| Set the minimum number of children that must match.
unsigned int | ec_node_subset_get_min (const struct ec_node *node)
| Get the minimum number of children that must match.

## Detailed Description

A node that matches any subset of its children in any order.

Configuration Schema

No configuration schema.

## Macro Definition Documentation

## EC_NODE_SUBSET

#define EC_NODE_SUBSET | ( |  | args... | ) |

Value:
__ec_node_subset(args, EC_VA_END)
EC_VA_END
#define EC_VA_END
Mark the end of the arguments list in some functions.
Definition utils.h:26

Create a subset node from a list of child nodes.

A subset node matches any permutation of a subset of its children. All child nodes passed as arguments are consumed and will be freed when the subset node is freed, or immediately on error.

Example:

EC_NODE_SUBSET("mysubset", child1, child2, child3)
EC_NODE_SUBSET
#define EC_NODE_SUBSET(args...)
Create a subset node from a list of child nodes.
Definition node_subset.h:30

Definition at line 30 of file node_subset.h.

## Function Documentation

## ec_node_subset()

struct ec_node * ec_node_subset | ( | const char * | id | ) |

Create an empty subset node.

Use ec_node_subset_add() to add children.

Parameters

  id | The node identifier.

Returns
  The node, or NULL on error (errno is set).

## ec_node_subset_min()

struct ec_node * ec_node_subset_min | ( | const char * | id,
|  | unsigned int | min )

Create an empty subset node with a minimum number of children that must match.

Use ec_node_subset_add() to add children.

Parameters

  id | The node identifier.
  min | The minimum number of children that must match.

Returns
  The node, or NULL on error (errno is set).

## ec_node_subset_add()

int ec_node_subset_add | ( | struct ec_node * | node,
|  | struct ec_node * | child )

Add a child to a subset node.

Parameters

  node | The subset node.
  child | The child node to add. It is consumed and will be freed when the parent is freed, or immediately on error.

Returns
  0 on success, -1 on error (errno is set).

## ec_node_subset_set_min()

int ec_node_subset_set_min | ( | struct ec_node * | node,
|  | unsigned int | min )

Set the minimum number of children that must match.

By default, a subset node accepts zero matching children. Use this function to require a minimum number of children to match for the parse to succeed.

Parameters

  node | The subset node.
  min | The minimum number of children that must match.

Returns
  0 on success, -1 on error (errno is set).

## ec_node_subset_get_min()

unsigned int ec_node_subset_get_min | ( | const struct ec_node * | node | ) |

Get the minimum number of children that must match.

Parameters

  node | The subset node.

Returns
  The minimum number, or 0 if the node is not a subset.