~pixelherodev/zyg

7fe6184f8b0197858762db36c1550401dc4aeec4 — Noam Preil 2 months ago 0205ad9
tmp
1 files changed, 11 insertions(+), 10 deletions(-)

M parser.c
M parser.c => parser.c +11 -10
@@ 1166,11 1166,13 @@ p_fnproto(int legacy)
static uint32_t
p_fnexpr(int legacy, int external)
{
	uint32_t type;
	uint32_t block = -1;
	uint32_t ident = -1;
	uint32_t type, block, ident, fn;
	block = -1;
	ident = -1;
	if(legacy){
		ident = p_ident();
		if(ident == -1)
			return -1;
		parser_advance();
	}
	type = p_fnproto(legacy);


@@ 1186,13 1188,17 @@ p_fnexpr(int legacy, int external)
			return -1;
		}
	}
	return c3append(&ctx.tree, C3_VALUE_FN, 3, type, block, ident);
	fn = c3append(&ctx.tree, C3_VALUE_FN, 2, type, block);
	stbds_hmput(ctx.analysis.names, fn, ident);
	return fn;
}

static uint32_t
p_fn_legacy(int external)
{
	uint32_t value = p_fnexpr(1, external);
	if(value == -1)
		return -1;
	if(external){
		parser_advance();
		EXPECT(C3_SCOLON, "Expected semicolon to end vardecl, found '%s'",c3tagstr(ctx.tokens.tags[ctx.i]));


@@ 1203,10 1209,7 @@ p_fn_legacy(int external)
static uint32_t
p_expr(void)
{
	uint32_t expr;
	// TODO: don't special-case these here
	expr = p_boolor_expr();
	return expr;
	return p_boolor_expr();
}

static uint32_t


@@ 1278,8 1281,6 @@ p_var_decl(void)
			ERROR("failed to read expr", 0);
			return -1;
		}
		if(c3nodetag(ctx.tree, value) == C3_VALUE_FN)
			ctx.tree.ast.nodes[value + 1 + 2].node_index = ident;
		parser_advance();
	}
	EXPECT(C3_SCOLON, "Expected semicolon to end vardecl, found '%s'",c3tagstr(ctx.tokens.tags[ctx.i]));