<commit_before>#include "parse.h"


parse_decl_t* parse_decl(
	const sparse_t* src, const char* ptr,
	unsigned* len)
{
	parse_decl_t* decl
		= (parse_decl_t*)malloc(
			sizeof(parse_decl_t));
	if (!decl) return NULL;

	unsigned i;
	decl->lhs = parse_lhs(src, ptr, &i);
	if (!decl->lhs)
	{
		free(decl);
		return NULL;
	}

	decl->len = NULL;
	if (ptr[i] == '*')
	{
		unsigned l;
		decl->len = parse_expr(
			src, &ptr[i + 1], &l);
		if (decl->len) i += (l + 1);
	}

	decl->init_expr  = NULL;
	decl->init_clist = NULL;
	if (ptr[i] == '=')
	{
		unsigned l;
		decl->init_expr = parse_expr(
			src, &ptr[i + 1], &l);
		if (decl->init_expr) i += (l + 1);
	}
	else if (ptr[i] == '/')
	{
		unsigned l;
		decl->init_clist = parse_clist(
			src, &ptr[i + 1], &l);
		if (decl->init_clist) i += (l + 1);
	}

	if (len) *len = i;
	return decl;
}

void parse_decl_delete(
	parse_decl_t* decl)
{
	if (!decl)
		return;

	parse_expr_delete(decl->init_expr);
	parse_clist_delete(decl->init_clist);
<commit_msg>Fix bug in clist declaration initializers<commit_after>#include "parse.h"


parse_decl_t* parse_decl(
	const sparse_t* src, const char* ptr,
	unsigned* len)
{
	parse_decl_t* decl
		= (parse_decl_t*)malloc(
			sizeof(parse_decl_t));
	if (!decl) return NULL;

	unsigned i;
	decl->lhs = parse_lhs(src, ptr, &i);
	if (!decl->lhs)
	{
		free(decl);
		return NULL;
	}

	decl->len = NULL;
	if (ptr[i] == '*')
	{
		unsigned l;
		decl->len = parse_expr(
			src, &ptr[i + 1], &l);
		if (decl->len) i += (l + 1);
	}

	decl->init_expr  = NULL;
	decl->init_clist = NULL;
	if (ptr[i] == '=')
	{
		unsigned l;
		decl->init_expr = parse_expr(
			src, &ptr[i + 1], &l);
		if (decl->init_expr) i += (l + 1);
	}
	else if (ptr[i] == '/')
	{
		unsigned l;
		decl->init_clist = parse_clist(
			src, &ptr[i], &l);
		if (decl->init_clist) i += l;
	}

	if (len) *len = i;
	return decl;
}

void parse_decl_delete(
	parse_decl_t* decl)
{
	if (!decl)
		return;

	parse_expr_delete(decl->init_expr);
	parse_clist_delete(decl->init_clist);

{'fraction_non_alphanumeric': 0.191, 'fraction_numerical': 0.005, 'mean_word_length': 3.486547085201794, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3900199', 'n_tokens_mistral': 961, 'n_tokens_neox': 892, 'n_words': 199}