Skip to content

Commit

Permalink
Check astnode dependencies are in their children
Browse files Browse the repository at this point in the history
  • Loading branch information
cleishm committed Oct 8, 2019
1 parent d8586d7 commit 8c76cc5
Show file tree
Hide file tree
Showing 80 changed files with 281 additions and 162 deletions.
7 changes: 4 additions & 3 deletions lib/src/ast_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ cypher_astnode_t *cypher_ast_all(const cypher_astnode_t *identifier,
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_TYPE(expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_TYPE_OPTIONAL(predicate, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_CHILD(children, nchildren, expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD_OPTIONAL(children, nchildren, predicate,
CYPHER_AST_EXPRESSION, NULL);

struct all *node = calloc(1, sizeof(struct all));
if (node == NULL)
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast_all_nodes_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ cypher_astnode_t *cypher_ast_all_nodes_scan(const cypher_astnode_t *identifier,
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_CHILD(children, nchildren, identifier, CYPHER_AST_IDENTIFIER, NULL);

struct all_nodes_scan *node = calloc(1, sizeof(struct all_nodes_scan));
if (node == NULL)
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast_all_rels_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ cypher_astnode_t *cypher_ast_all_rels_scan(const cypher_astnode_t *identifier,
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_CHILD(children, nchildren, identifier, CYPHER_AST_IDENTIFIER, NULL);

struct all_rels_scan *node = calloc(1, sizeof(struct all_rels_scan));
if (node == NULL)
Expand Down
7 changes: 4 additions & 3 deletions lib/src/ast_any.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ cypher_astnode_t *cypher_ast_any(const cypher_astnode_t *identifier,
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_TYPE(expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_TYPE_OPTIONAL(predicate, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_CHILD(children, nchildren, expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD_OPTIONAL(children, nchildren, predicate,
CYPHER_AST_EXPRESSION, NULL);

struct any *node = calloc(1, sizeof(struct any));
if (node == NULL)
Expand Down
3 changes: 2 additions & 1 deletion lib/src/ast_apply_all_operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ cypher_astnode_t *cypher_ast_apply_all_operator(
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(func_name, CYPHER_AST_FUNCTION_NAME, NULL);
REQUIRE_CHILD(children, nchildren, func_name,
CYPHER_AST_FUNCTION_NAME, NULL);

struct apply_all_operator *node =
calloc(1, sizeof(struct apply_all_operator));
Expand Down
6 changes: 4 additions & 2 deletions lib/src/ast_apply_operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ cypher_astnode_t *cypher_ast_apply_operator(const cypher_astnode_t *func_name,
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(func_name, CYPHER_AST_FUNCTION_NAME, NULL);
REQUIRE_TYPE_ALL(args, nargs, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, func_name,
CYPHER_AST_FUNCTION_NAME, NULL);
REQUIRE_CHILD_ALL(children, nchildren, args, nargs,
CYPHER_AST_EXPRESSION, NULL);

struct apply_operator *node = calloc(1, sizeof(struct apply_operator) +
nargs * sizeof(cypher_astnode_t *));
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ast_binary_operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ cypher_astnode_t *cypher_ast_binary_operator(const cypher_operator_t *op,
struct cypher_input_range range)
{
REQUIRE(op != NULL, NULL);
REQUIRE_TYPE(arg1, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_TYPE(arg2, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, arg1, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, arg2, CYPHER_AST_EXPRESSION, NULL);

struct binary_operator *node = calloc(1, sizeof(struct binary_operator));
if (node == NULL)
Expand Down
10 changes: 7 additions & 3 deletions lib/src/ast_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ cypher_astnode_t *cypher_ast_call(const cypher_astnode_t *proc_name,
const cypher_astnode_t *predicate, cypher_astnode_t **children,
unsigned int nchildren, struct cypher_input_range range)
{
REQUIRE_TYPE(proc_name, CYPHER_AST_PROC_NAME, NULL);
REQUIRE_TYPE_ALL(args, nargs, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_TYPE_ALL(projections, nprojections, CYPHER_AST_PROJECTION, NULL);
REQUIRE_CHILD(children, nchildren, proc_name, CYPHER_AST_PROC_NAME, NULL);
REQUIRE_CHILD_ALL(children, nchildren, args, nargs,
CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD_ALL(children, nchildren, projections, nprojections,
CYPHER_AST_PROJECTION, NULL);
REQUIRE_CHILD_OPTIONAL(children, nchildren, predicate,
CYPHER_AST_EXPRESSION, NULL);

struct call_clause *node = calloc(1, sizeof(struct call_clause));
if (node == NULL)
Expand Down
9 changes: 6 additions & 3 deletions lib/src/ast_case.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ cypher_astnode_t *cypher_ast_case(const cypher_astnode_t *expression,
const cypher_astnode_t *deflt, cypher_astnode_t **children,
unsigned int nchildren, struct cypher_input_range range)
{
REQUIRE_TYPE_OPTIONAL(expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_TYPE_ALL(alternatives, nalternatives, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_TYPE_OPTIONAL(deflt, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD_OPTIONAL(children, nchildren, expression,
CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD_ALL(children, nchildren, alternatives, nalternatives,
CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD_OPTIONAL(children, nchildren, deflt,
CYPHER_AST_EXPRESSION, NULL);

struct case_expression *node = calloc(1, sizeof(struct case_expression) +
nalternatives * 2 * sizeof(cypher_astnode_t *));
Expand Down
3 changes: 2 additions & 1 deletion lib/src/ast_collection.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ cypher_astnode_t *cypher_ast_collection(
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE_ALL(elements, nelements, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD_ALL(children, nchildren, elements, nelements,
CYPHER_AST_EXPRESSION, NULL);

struct collection *node = calloc(1, sizeof(struct collection) +
nelements * sizeof(cypher_astnode_t *));
Expand Down
5 changes: 3 additions & 2 deletions lib/src/ast_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ cypher_astnode_t *cypher_ast_command(const cypher_astnode_t *name,
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(name, CYPHER_AST_STRING, NULL);
REQUIRE_TYPE_ALL(args, nargs, CYPHER_AST_STRING, NULL);
REQUIRE_CHILD(children, nchildren, name, CYPHER_AST_STRING, NULL);
REQUIRE_CHILD_ALL(children, nchildren, args, nargs,
CYPHER_AST_STRING, NULL);

struct command *node = calloc(1, sizeof(struct command) +
nargs * sizeof(cypher_astnode_t *));
Expand Down
3 changes: 2 additions & 1 deletion lib/src/ast_comparison.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ cypher_astnode_t *cypher_ast_comparison(unsigned int length,
{
REQUIRE(length > 0, NULL);
REQUIRE(ops != NULL, NULL);
REQUIRE_TYPE_ALL(args, length+1, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD_ALL(children, nchildren, args, length+1,
CYPHER_AST_EXPRESSION, NULL);

struct comparison *node = calloc(1, sizeof(struct comparison) +
(length + 1) * sizeof(cypher_astnode_t *));
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ cypher_astnode_t *cypher_ast_create(bool unique,
const cypher_astnode_t *pattern, cypher_astnode_t **children,
unsigned int nchildren, struct cypher_input_range range)
{
REQUIRE_TYPE(pattern, CYPHER_AST_PATTERN, NULL);
REQUIRE_CHILD(children, nchildren, pattern, CYPHER_AST_PATTERN, NULL);

struct create *node = calloc(1, sizeof(struct create));
if (node == NULL)
Expand Down
6 changes: 3 additions & 3 deletions lib/src/ast_create_node_prop_constraint.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ cypher_astnode_t *cypher_ast_create_node_prop_constraint(
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_TYPE(label, CYPHER_AST_LABEL, NULL);
REQUIRE_TYPE(expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_CHILD(children, nchildren, label, CYPHER_AST_LABEL, NULL);
REQUIRE_CHILD(children, nchildren, expression, CYPHER_AST_EXPRESSION, NULL);

struct constraint *node = calloc(1, sizeof(struct constraint));
if (node == NULL)
Expand Down
5 changes: 3 additions & 2 deletions lib/src/ast_create_node_props_index.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ cypher_astnode_t *cypher_ast_create_node_props_index(
unsigned int nprops, cypher_astnode_t **children,
unsigned int nchildren, struct cypher_input_range range)
{
REQUIRE_TYPE(label, CYPHER_AST_LABEL, NULL);
REQUIRE_CHILD(children, nchildren, label, CYPHER_AST_LABEL, NULL);
REQUIRE(nprops > 0, NULL);
REQUIRE_TYPE_ALL(prop_names, nprops, CYPHER_AST_PROP_NAME, NULL);
REQUIRE_CHILD_ALL(children, nchildren, prop_names, nprops,
CYPHER_AST_PROP_NAME, NULL);

struct create_index *node = calloc(1, sizeof(struct create_index) +
nprops * sizeof(cypher_astnode_t *));
Expand Down
6 changes: 3 additions & 3 deletions lib/src/ast_create_rel_prop_constraint.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ cypher_astnode_t *cypher_ast_create_rel_prop_constraint(
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_TYPE(reltype, CYPHER_AST_RELTYPE, NULL);
REQUIRE_TYPE(expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_CHILD(children, nchildren, reltype, CYPHER_AST_RELTYPE, NULL);
REQUIRE_CHILD(children, nchildren, expression, CYPHER_AST_EXPRESSION, NULL);

struct constraint *node = calloc(1, sizeof(struct constraint));
if (node == NULL)
Expand Down
6 changes: 4 additions & 2 deletions lib/src/ast_cypher_option.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ cypher_astnode_t *cypher_ast_cypher_option(const cypher_astnode_t *version,
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE_OPTIONAL(version, CYPHER_AST_STRING, NULL);
REQUIRE_TYPE_ALL(params, nparams, CYPHER_AST_CYPHER_OPTION_PARAM, NULL);
REQUIRE_CHILD_OPTIONAL(children, nchildren, version,
CYPHER_AST_STRING, NULL);
REQUIRE_CHILD_ALL(children, nchildren, params, nparams,
CYPHER_AST_CYPHER_OPTION_PARAM, NULL);

struct cypher_option *node = calloc(1, sizeof(struct cypher_option) +
nparams * sizeof(cypher_astnode_t *));
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ast_cypher_option_param.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ cypher_astnode_t *cypher_ast_cypher_option_param(const cypher_astnode_t *name,
const cypher_astnode_t *value, cypher_astnode_t **children,
unsigned int nchildren, struct cypher_input_range range)
{
REQUIRE_TYPE(name, CYPHER_AST_STRING, NULL);
REQUIRE_TYPE(value, CYPHER_AST_STRING, NULL);
REQUIRE_CHILD(children, nchildren, name, CYPHER_AST_STRING, NULL);
REQUIRE_CHILD(children, nchildren, value, CYPHER_AST_STRING, NULL);

struct cypher_option_param *node =
calloc(1, sizeof(struct cypher_option_param));
Expand Down
3 changes: 2 additions & 1 deletion lib/src/ast_delete.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ cypher_astnode_t *cypher_ast_delete(bool detach,
struct cypher_input_range range)
{
REQUIRE(nexpressions > 0, NULL);
REQUIRE_TYPE_ALL(expressions, nexpressions, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD_ALL(children, nchildren, expressions, nexpressions,
CYPHER_AST_EXPRESSION, NULL);

struct delete_clause *node = calloc(1, sizeof(struct delete_clause) +
nexpressions * sizeof(cypher_astnode_t *));
Expand Down
6 changes: 3 additions & 3 deletions lib/src/ast_drop_node_prop_constraint.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ cypher_astnode_t *cypher_ast_drop_node_prop_constraint(
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_TYPE(label, CYPHER_AST_LABEL, NULL);
REQUIRE_TYPE(expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_CHILD(children, nchildren, label, CYPHER_AST_LABEL, NULL);
REQUIRE_CHILD(children, nchildren, expression, CYPHER_AST_EXPRESSION, NULL);

struct constraint *node = calloc(1, sizeof(struct constraint));
if (node == NULL)
Expand Down
5 changes: 3 additions & 2 deletions lib/src/ast_drop_node_props_index.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ cypher_astnode_t *cypher_ast_drop_node_props_index(
unsigned int nprops, cypher_astnode_t **children,
unsigned int nchildren, struct cypher_input_range range)
{
REQUIRE_TYPE(label, CYPHER_AST_LABEL, NULL);
REQUIRE_CHILD(children, nchildren, label, CYPHER_AST_LABEL, NULL);
REQUIRE(nprops > 0, NULL);
REQUIRE_TYPE_ALL(prop_names, nprops, CYPHER_AST_PROP_NAME, NULL);
REQUIRE_CHILD_ALL(children, nchildren, prop_names, nprops,
CYPHER_AST_PROP_NAME, NULL);

struct drop_index *node = calloc(1, sizeof(struct drop_index) +
nprops * sizeof(cypher_astnode_t *));
Expand Down
6 changes: 3 additions & 3 deletions lib/src/ast_drop_rel_prop_constraint.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ cypher_astnode_t *cypher_ast_drop_rel_prop_constraint(
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_TYPE(reltype, CYPHER_AST_RELTYPE, NULL);
REQUIRE_TYPE(expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_CHILD(children, nchildren, reltype, CYPHER_AST_RELTYPE, NULL);
REQUIRE_CHILD(children, nchildren, expression, CYPHER_AST_EXPRESSION, NULL);

struct constraint *node = calloc(1, sizeof(struct constraint));
if (node == NULL)
Expand Down
7 changes: 4 additions & 3 deletions lib/src/ast_extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ cypher_astnode_t *cypher_ast_extract(const cypher_astnode_t *identifier,
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_TYPE(expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_TYPE_OPTIONAL(eval, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_CHILD(children, nchildren, expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD_OPTIONAL(children, nchildren, eval,
CYPHER_AST_EXPRESSION, NULL);

struct extract *node = calloc(1, sizeof(struct extract));
if (node == NULL)
Expand Down
7 changes: 4 additions & 3 deletions lib/src/ast_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ cypher_astnode_t *cypher_ast_filter(const cypher_astnode_t *identifier,
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_TYPE(expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_TYPE_OPTIONAL(predicate, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_CHILD(children, nchildren, expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD_OPTIONAL(children, nchildren, predicate,
CYPHER_AST_EXPRESSION, NULL);

struct filter *node = calloc(1, sizeof(struct filter));
if (node == NULL)
Expand Down
7 changes: 4 additions & 3 deletions lib/src/ast_foreach.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ cypher_astnode_t *cypher_ast_foreach(const cypher_astnode_t *identifier,
unsigned int nclauses, cypher_astnode_t **children,
unsigned int nchildren, struct cypher_input_range range)
{
REQUIRE_TYPE(identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_TYPE(expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_CHILD(children, nchildren, expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE(nclauses > 0, NULL);
REQUIRE_TYPE_ALL(clauses, nclauses, CYPHER_AST_QUERY_CLAUSE, NULL);
REQUIRE_CHILD_ALL(children, nchildren, clauses, nclauses,
CYPHER_AST_QUERY_CLAUSE, NULL);

struct foreach_clause *node = calloc(1, sizeof(struct foreach_clause) +
nclauses * sizeof(cypher_astnode_t *));
Expand Down
5 changes: 3 additions & 2 deletions lib/src/ast_labels_operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ cypher_astnode_t *cypher_ast_labels_operator(const cypher_astnode_t *expression,
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE(nlabels > 0, NULL);
REQUIRE_TYPE_ALL(labels, nlabels, CYPHER_AST_LABEL, NULL);
REQUIRE_CHILD_ALL(children, nchildren, labels, nlabels,
CYPHER_AST_LABEL, NULL);

struct labels_operator *node = calloc(1, sizeof(struct labels_operator) +
nlabels * sizeof(cypher_astnode_t *));
Expand Down
10 changes: 6 additions & 4 deletions lib/src/ast_list_comprehension.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ cypher_astnode_t *cypher_ast_list_comprehension(
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_TYPE(expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_TYPE_OPTIONAL(predicate, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_TYPE_OPTIONAL(eval, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_CHILD(children, nchildren, expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD_OPTIONAL(children, nchildren, predicate,
CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD_OPTIONAL(children, nchildren, eval,
CYPHER_AST_EXPRESSION, NULL);

struct list_comprehension *node =
calloc(1, sizeof(struct list_comprehension));
Expand Down
7 changes: 4 additions & 3 deletions lib/src/ast_load_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ cypher_astnode_t *cypher_ast_load_csv(bool with_headers,
const cypher_astnode_t *field_terminator, cypher_astnode_t **children,
unsigned int nchildren, struct cypher_input_range range)
{
REQUIRE_TYPE(url, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_TYPE(identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_TYPE_OPTIONAL(field_terminator, CYPHER_AST_STRING, NULL);
REQUIRE_CHILD(children, nchildren, url, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_CHILD_OPTIONAL(children, nchildren, field_terminator,
CYPHER_AST_STRING, NULL);

struct loadcsv *node = calloc(1, sizeof(struct loadcsv));
if (node == NULL)
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast_map_projection.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cypher_astnode_t *cypher_ast_map_projection(
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, expression, CYPHER_AST_EXPRESSION, NULL);

struct map_projection *node = calloc(1, sizeof(struct map_projection) +
nselectors * sizeof(cypher_astnode_t *));
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast_map_projection_identifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ cypher_astnode_t *cypher_ast_map_projection_identifier(
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(identifier, CYPHER_AST_IDENTIFIER, NULL);
REQUIRE_CHILD(children, nchildren, identifier, CYPHER_AST_IDENTIFIER, NULL);

struct map_projection_identifier *node =
calloc(1, sizeof(struct map_projection_identifier));
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ast_map_projection_literal.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ cypher_astnode_t *cypher_ast_map_projection_literal(
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(prop_name, CYPHER_AST_PROP_NAME, NULL);
REQUIRE_TYPE(expression, CYPHER_AST_EXPRESSION, NULL);
REQUIRE_CHILD(children, nchildren, prop_name, CYPHER_AST_PROP_NAME, NULL);
REQUIRE_CHILD(children, nchildren, expression, CYPHER_AST_EXPRESSION, NULL);

struct map_projection_literal *node =
calloc(1, sizeof(struct map_projection_literal));
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast_map_projection_property.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ cypher_astnode_t *cypher_ast_map_projection_property(
cypher_astnode_t **children, unsigned int nchildren,
struct cypher_input_range range)
{
REQUIRE_TYPE(prop_name, CYPHER_AST_PROP_NAME, NULL);
REQUIRE_CHILD(children, nchildren, prop_name, CYPHER_AST_PROP_NAME, NULL);

struct map_projection_property *node =
calloc(1, sizeof(struct map_projection_property));
Expand Down
Loading

0 comments on commit 8c76cc5

Please sign in to comment.