6 #include "script/parser.h"
7 #include "script/scope.h"
8 #include "system/error.h"
10 #include "script/interpreter.h"
12 /* TODO(#394): region is not integrated with the level format */
21 Region *create_region(Rect rect, const char *script_src)
30 Region *region = PUSH_LT(lt, malloc(sizeof(Region)), free);
32 throw_error(ERROR_TYPE_LIBC);
38 region->gc = PUSH_LT(lt, create_gc(), destroy_gc);
39 if (region->gc == NULL) {
43 region->scope = create_scope(region->gc);
45 while (*script_src != 0) {
46 struct ParseResult parse_result = read_expr_from_string(region->gc, script_src);
47 if (parse_result.is_error) {
48 fprintf(stderr, "Parsing error: %s\n", parse_result.error_message);
52 struct EvalResult eval_result = eval(
56 if (eval_result.is_error) {
57 fprintf(stderr, "Evaluation error: ");
58 /* TODO(#395): eval error is not printed on stderr */
59 print_expr_as_sexpr(eval_result.expr);
63 script_src = next_token(parse_result.end).begin;
69 void destroy_region(Region *region)
72 RETURN_LT0(region->lt);
75 void region_player_enter(Region *region, Player *player)
79 /* TODO(#396): region_player_enter is not implemented */
82 void region_player_leave(Region *region, Player *player)
86 /* TODO(#397): region_player_leave is not implemented */