~lbnz/xr0

3e4fc49d5a8664714d8bcae86c89b9284fed4ce4 — Amisi Kiarie 5 months ago c44a52d feat/linking-steps
checkpoint
3 files changed, 42 insertions(+), 15 deletions(-)

M src/0v/ast/expr/verify.c
M src/0v/ast/function/function.c
M tests/3-program/100-lex/parse.x
M src/0v/ast/expr/verify.c => src/0v/ast/expr/verify.c +0 -2
@@ 457,8 457,6 @@ expr_call_eval(struct ast_expr *expr, struct state *state)
		return result_error_create(err);
	}

	printf("state: %s\n", state_str(state));
	printf("call: %s\n", ast_expr_str(expr));
	struct result *res = ast_function_absexec(f, state);
	if (result_iserror(res)) {
		return res;

M src/0v/ast/function/function.c => src/0v/ast/function/function.c +1 -1
@@ 221,7 221,7 @@ path_verify_withstate(struct ast_function *f, struct externals *ext)
	struct state *state = state_create(
		dynamic_str(ast_function_name(f)), ext, ast_function_type(f)
	);
	/*printf("state: %s\n", state_str(state));*/
	printf("state: %s\n", state_str(state));
	struct error *err = path_verify(f, state, ext);
	state_destroy(state);
	return err;

M tests/3-program/100-lex/parse.x => tests/3-program/100-lex/parse.x +41 -12
@@ 15,10 15,30 @@ struct lexer *
parse(char *input);

void
lexer_destroy(struct lexer *);
lexer_destroy(struct lexer *) ~ [
	pre: {
		l = lexer_create(
			$, $,
			$, malloc(1),
			$, malloc(1)
		);
	}

	.dealloc l->pattern;
	.dealloc l->token;
	.dealloc l;
];

void
lexer_print(struct lexer *);
lexer_print(struct lexer *) ~ [
	pre: {
		l = lexer_create(
			$, $,
			$, malloc(1),
			$, malloc(1)
		);
	}
];

int
main()


@@ 76,8 96,11 @@ struct lexer {

struct lexer *
lexer_create(char *pre, char *post, int npat, struct pattern *pattern,
		int ntok, struct token *token)
{
		int ntok, struct token *token) ~ [
	.alloc result; 
	result->pattern = pattern;
	result->token = token;
]{
	struct lexer *l;

	l = malloc(sizeof(struct lexer));


@@ 104,19 127,25 @@ lexer_print(struct lexer *l)
{
	int i;

	printf("\tpre: %s\n", l->pre);
	printf("\tpost: %s\n", l->post);
	printf("\tpatterns:\n");
	puts("\tpre:");
	puts(l->pre);

	puts("\tpost:");
	puts(l->post);

	puts("\tpatterns:");
	for (i = 0; i < l->npat; i++) {
		printf("\t\t");
		putchar('\t');
		putchar('\t');
		pattern_print(&l->pattern[i]);
		printf("\n");
		putchar('\n');
	}
	printf("\ttokens:\n");
	puts("\ttokens:");
	for (i = 0; i < l->ntok; i++) {
		printf("\t\t");
		putchar('\t');
		putchar('\t');
		token_print(&l->token[i]);
		printf("\n");
		putchar('\n');
	}
}