Commit c30d4d93 authored by Guillaume Charifi's avatar Guillaume Charifi

compiler/parser: Parse prop.

parent 0dbdc4d1
......@@ -1426,6 +1426,52 @@ static int parse_function(struct parser_ctx *ctx, unsigned long *cur_tok_id)
return 0;
}
static int prop_dtor(struct bm_ast_node *node)
{
destroy_decl(&node->data.as_prop.decl);
return 0;
}
static int prop_debug_data(const struct bm_ast_node *node, int indent_lvl)
{
const struct bm_ast_node_data_prop *data = &node->data.as_prop;
debug_decl(&data->decl, indent_lvl);
wprintf(L",\n%*ls\"visibility\": \"%ls\"", indent_lvl * 2, L"", debug_visibility(data->visibility));
return 0;
}
static int parse_prop(struct parser_ctx *ctx, unsigned long *cur_tok_id, struct bm_ast_node *out)
{
int result;
unsigned long i = *cur_tok_id;
struct bm_ast_node prop;
parser_node_init(&prop, BM_AST_NODE_PROP);
prop.dtor = prop_dtor;
prop.debug_data = prop_debug_data;
prop.data.as_prop.visibility = parser_visibility_from_token_type(ctx->in->tokens[i].type);
if (prop.data.as_prop.visibility == BM_AST_VISIBILITY_INVAL)
goto failed;
i++;
result = parse_decl(ctx, &i, &prop.data.as_prop.decl);
if (result < 0)
goto failed;
*out = prop;
*cur_tok_id = i;
return 0;
failed:
parser_node_destroy(&prop);
return -1;
}
static int proto_dtor(struct bm_ast_node *node)
{
destroy_decl_func(&node->data.as_proto.decl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment