<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <AQueue.h>
#include <AStack.h>
#include "Operator.h"
#include "Token.h"
#include "Error.h"

static void execOperator(AStack* values, Operator op);

double postfix(AQueue* expr)
{
	Token* t;
	AStack* values = AStruct->ANew(AStack);
	double* r;
	double result;

	while ((t = expr->dequeue(expr)) != NULL)
	{
		switch (t->type)
		{
			case value:
				values->push(values, AStruct->ADup(t->token.v));
				break;

			case operator:
				execOperator(values, t->token.op);
				break;

			default:
				break;
		}

		free(t);
	}

	if (values->size != 1)
	{
		error("Wrong number of arguments");
		values->destroy(values, free);
		expr->destroy(expr, NULL);
		return 0;
	}

	r = values->pop(values);
	result = *r;

	free(r);
	values->destroy(values, free);
	expr->destroy(expr, NULL);
<commit_msg>Make sure value stack has values<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <AQueue.h>
#include <AStack.h>
#include "Operator.h"
#include "Token.h"
#include "Error.h"

static void execOperator(AStack* values, Operator op);

double postfix(AQueue* expr)
{
	Token* t;
	AStack* values = AStruct->ANew(AStack);
	double* r;
	double result;

	while ((t = expr->dequeue(expr)) != NULL)
	{
		switch (t->type)
		{
			case value:
				values->push(values, AStruct->ADup(t->token.v));
				break;

			case operator:
				execOperator(values, t->token.op);
				break;

			default:
				break;
		}

		free(t);

		if (values->top(values) == NULL)
		{
			break;
		}
	}

	if (values->size != 1)
	{
		error("Wrong number of arguments");
		values->destroy(values, free);
		expr->destroy(expr, NULL);
		return 0;
	}

	r = values->pop(values);
	result = *r;

	free(r);
	values->destroy(values, free);
	expr->destroy(expr, NULL);

{'fraction_non_alphanumeric': 0.1754089114495206, 'fraction_numerical': 0.0022560631697687537, 'mean_word_length': 3.693121693121693, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 38, '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': '7006206', 'n_tokens_mistral': 761, 'n_tokens_neox': 672, 'n_words': 155}