~lbnz/xr0

9a65d5ecd5873dcd8e2fce5d1169630bdf5c25d1 — Xr0 Team 4 months ago 25f112d feat/advanced-branch
nearly there
2 files changed, 19 insertions(+), 20 deletions(-)

M src/0v/ast/stmt/verify.c
M tests/3-program/100-lex/parse.x
M src/0v/ast/stmt/verify.c => src/0v/ast/stmt/verify.c +3 -3
@@ 415,8 415,8 @@ sel_absexec(struct ast_stmt *stmt, struct state *state)
static struct decision
sel_decide(struct ast_expr *control, struct state *state)
{
	/*printf("state: %s\n", state_str(state));*/
	/*printf("control: %s\n", ast_expr_str(control));*/
	printf("state: %s\n", state_str(state));
	printf("control: %s\n", ast_expr_str(control));
	struct state *s_copy = state_copy(state);
	struct result *res = ast_expr_eval(control, s_copy);
	free(s_copy);


@@ 426,7 426,7 @@ sel_decide(struct ast_expr *control, struct state *state)
	assert(result_hasvalue(res)); /* TODO: user error */

	struct value *v = result_as_value(res);
	/*printf("value: %s\n", value_str(v));*/
	printf("value: %s\n", value_str(v));
	if (value_issync(v)) {
		struct ast_expr *sync = value_as_sync(v);
		struct props *p = state_getprops(state);

M tests/3-program/100-lex/parse.x => tests/3-program/100-lex/parse.x +16 -17
@@ 32,10 32,13 @@ parse_defsraw(char *input) ~ [
	result.pos = $;
];

/* skipws: skip whitespace */
char *
skipws(char *s);

struct lexer *
parse(char *pos) ~ [
	char *pre;
	char *post;
	char *pre; char *post;
	struct pattern *pattern;
	struct token *token;
	pre = $; post = $; pattern = $; token = $; /* TODO: put in else */


@@ 54,12 57,6 @@ parse(char *pos) ~ [
	result = lexer_create(pre, post, $, pattern, $, token);
];

int
isboundary(char *s)
{
	return strncmp(s, "%%", 2) == 0;
}

void
lexer_destroy(struct lexer *) ~ [
	pre: {


@@ 87,16 84,16 @@ lexer_print(struct lexer *) ~ [
];

int
main()
{
main() ~ [
]{
	char *file;
	struct lexer *l;

	file = read_file("tests/3-program/100-lex/gen.l");

	/*l = parse(file);*/
	/*lexer_print(l);*/
	/*lexer_destroy(l);*/
	l = parse(file);
	lexer_print(l);
	lexer_destroy(l);

	free(file);
}


@@ 201,10 198,6 @@ lexer_print(struct lexer *l)
	}
}

/* skipws: skip whitespace */
char *
skipws(char *s);

struct defsresult {
	char *pre;
	struct pattern *pattern;


@@ 281,6 274,12 @@ parse(char *pos)
		rules.token);
}

int
isboundary(char *s)
{
	return strncmp(s, "%%", 2) == 0;
}

char *
substr(char *s, int n) ~ [ .alloc result; ]
{