<commit_before>
#include <stdio.h>

#include "symbol.h"
#include "tokens.h"
#include "syntax.h"

static struct node *stmt(void);

static struct node *
_goto(void)
{
	register struct node *np;

	expect(GOTO);
	expect(IDEN);
	if (yyval.sym->ns != NS_LABEL)
		yyval.sym = lookup(yytext, NS_LABEL, CTX_ANY);
	np = node1(OGOTO, nodesym(yyval.sym));
	expect(';');

	return np;
}

static struct node *
_while(void)
{
	register struct node *cond;

	expect(WHILE);
	expect('(');
	cond = expr();
	expect(')');
	return node2(OWHILE, cond, stmt());
}

static struct node *
_do(void)
{
	register struct node *cond, *body;

	expect(DO);
	body = stmt();
	expect(WHILE);
	expect('(');
	cond = expr();
	expect(')');
	expect(';');

	return node2(ODO, body, cond);
}

static struct node *
_for(void)
{
	register struct node *exp1, *exp2, *exp3;

	expect(FOR);
	expect('(');
	exp1 = (yytoken != ';') ? expr() : NULL;
	expect(';');
	exp2 = (yytoken != ';') ? expr() : NULL;
	expect(';');
	exp3 = (yytoken != ')') ? expr() : NULL;
	expect(')');
	
	return node2(OFOR, node3(OFEXP, exp1, exp2, exp3), stmt());
}

static struct node *
_if(void)
{
	register struct node *cond, *body;

	expect(IF);
	expect('(');
	cond = expr();
	expect(')');
	body = stmt();

	return node3(OIF, cond, body, (accept(ELSE)) ? stmt() : NULL);
}

static struct node *
_switch(void)
{
	register struct node *cond;

	expect(SWITCH);
	expect('(');
	cond = expr();
	expect(')');
	return node2(OSWITCH, cond, stmt());
}

static struct node *
label(void)<commit_msg>Added control about nesting levels<commit_after>
#include <assert.h>
#include <stdio.h>

#include "symbol.h"
#include "tokens.h"
#include "syntax.h"
#include "sizes.h"

static struct node *stmt(void);


static unsigned char blocks[NR_BLOCK];
static unsigned char *blockp = blocks;

static void
push(register unsigned char b)
{
	if (blockp == &blocks[NR_BLOCK])
		error("Too much nesting levels");
	*blockp++ = b;
}

static void
pop(void)
{
	assert(blockp >= blocks);
	--blockp;
}

static struct node *
_goto(void)
{
	register struct node *np;

	expect(GOTO);
	expect(IDEN);
	if (yyval.sym->ns != NS_LABEL)
		yyval.sym = lookup(yytext, NS_LABEL, CTX_ANY);
	np = node1(OGOTO, nodesym(yyval.sym));
	expect(';');

	return np;
}

static struct node *
_while(void)
{
	register struct node *cond, *np;

	expect(WHILE);
	expect('(');
	cond = expr();
	expect(')');
	push(OWHILE);
	np = node2(OWHILE, cond, stmt());
	pop();
	return np;
}

static struct node *
_do(void)
{
	register struct node *cond, *body, *np;

	expect(DO);
	body = stmt();
	expect(WHILE);
	expect('(');
	cond = expr();
	expect(')');
	expect(';');

	push(ODO);
	np = node2(ODO, body, cond);
	pop();
	return np;
}

static struct node *
_for(void)
{
	register struct node *exp1, *exp2, *exp3;
	struct node *np;

	expect(FOR);
	expect('(');
	exp1 = (yytoken != ';') ? expr() : NULL;
	expect(';');
	exp2 = (yytoken != ';') ? expr() : NULL;
	expect(';');
	exp3 = (yytoken != ')') ? expr() : NULL;
	expect(')');

	push(OFOR);
	np = node2(OFOR, node3(OFEXP, exp1, exp2, exp3), stmt());
	pop();
	return np;
}

static struct node *
_if(void)
{
	register struct node *cond, *body;

	expect(IF);
	expect('(');
	cond = expr();
	expect(')');
	body = stmt();

	return node3(OIF, cond, body, (accept(ELSE)) ? stmt() : NULL);
}

static struct node *
_switch(void)
{
	register struct node *cond, *np;

	expect(SWITCH);
	expect('(');
	cond = expr();
	expect(')');

	push(OSWITCH);
	np = node2(OSWITCH, cond, stmt());
	pop();
	return np;
}

static struct node *
label(void)
{'fraction_non_alphanumeric': 0.20334656834940443, 'fraction_numerical': 0.009075439591605219, 'mean_word_length': 4.476708074534161, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 9, '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': '5137579', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1421, 'n_words': 365}