lang: ast: fix compiler warnings
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
#include "ctx.h"
|
||||
#include "node.h"
|
||||
|
||||
#include <blue/object/string.h>
|
||||
#include <ivy/lang/lex.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ctx.h"
|
||||
#include "node.h"
|
||||
|
||||
struct class_parser_state {
|
||||
struct parser_state s_base;
|
||||
enum {
|
||||
@@ -14,23 +14,10 @@ struct class_parser_state {
|
||||
int s_prev_token;
|
||||
};
|
||||
|
||||
static enum ivy_status parse_dot(struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
static enum ivy_status parse_ident(struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= parser_get_state(ctx, struct unit_import_parser_state);
|
||||
|
||||
if (state->s_prev_token != IVY_TOK_IDENT) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
state->s_prev_token = IVY_SYM_DOT;
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status parse_ident(struct ivy_parser* ctx, struct ivy_token* tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= parser_get_state(ctx, struct unit_import_parser_state);
|
||||
= parser_get_state(ctx, struct class_parser_state);
|
||||
|
||||
struct ivy_ast_class_node *node
|
||||
= (struct ivy_ast_class_node *)(state->s_base.s_node);
|
||||
@@ -43,7 +30,7 @@ static enum ivy_status parse_ident(struct ivy_parser* ctx, struct ivy_token* tok
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
b_queue_push_back(&node->n_ident, &tok->t_entry);
|
||||
node->n_ident = tok;
|
||||
state->s_prev_token = IVY_TOK_IDENT;
|
||||
return IVY_OK;
|
||||
}
|
||||
@@ -51,7 +38,7 @@ static enum ivy_status parse_ident(struct ivy_parser* ctx, struct ivy_token* tok
|
||||
static enum ivy_status parse_end(struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= parser_get_state(ctx, struct unit_import_parser_state);
|
||||
= parser_get_state(ctx, struct class_parser_state);
|
||||
|
||||
struct ivy_ast_class_node *node
|
||||
= (struct ivy_ast_class_node *)(state->s_base.s_node);
|
||||
@@ -67,7 +54,7 @@ static enum ivy_status parse_end(struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
static enum ivy_status parse_linefeed(struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= parser_get_state(ctx, struct unit_import_parser_state);
|
||||
= parser_get_state(ctx, struct class_parser_state);
|
||||
|
||||
if (state->s_current_area != AREA_IDENT) {
|
||||
return IVY_OK;
|
||||
@@ -86,7 +73,7 @@ static enum ivy_status add_child(
|
||||
struct ivy_ast_node *parent, struct ivy_ast_node *child)
|
||||
{
|
||||
struct ivy_ast_class_node *c = (struct ivy_ast_class_node *)parent;
|
||||
|
||||
|
||||
switch (child->n_type) {
|
||||
case IVY_AST_MSGH:
|
||||
b_queue_push_back(&c->n_msg_handlers, &child->n_entry);
|
||||
@@ -103,28 +90,15 @@ static enum ivy_status add_child(
|
||||
|
||||
static void print(struct ivy_ast_node *node)
|
||||
{
|
||||
struct ivy_ast_class_node *unit_import = (struct ivy_ast_class_node *)node;
|
||||
b_string *str = b_string_create();
|
||||
struct ivy_ast_class_node *c = (struct ivy_ast_class_node *)node;
|
||||
|
||||
b_queue_iterator it = {0};
|
||||
b_queue_foreach (&it, &unit_import->n_ident) {
|
||||
struct ivy_token *tok = b_unbox(struct ivy_token, it.entry, t_entry);
|
||||
|
||||
if (b_string_get_size(str, B_STRLEN_NORMAL) > 0) {
|
||||
b_string_append_cstr(str, ".");
|
||||
}
|
||||
|
||||
b_string_append_cstr(str, tok->t_str);
|
||||
}
|
||||
|
||||
printf("%s(%s)\n", ivy_ast_node_type_to_string(node->n_type), b_string_ptr(str));
|
||||
b_string_release(str);
|
||||
printf("%s(%s)\n", ivy_ast_node_type_to_string(node->n_type),
|
||||
c->n_ident->t_str);
|
||||
}
|
||||
|
||||
static void init_state(struct parser_state *sp)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= (struct unit_import_parser_state *)sp;
|
||||
struct class_parser_state *state = (struct class_parser_state *)sp;
|
||||
state->s_prev_token = IVY_KW_CLASS;
|
||||
state->s_current_area = AREA_IDENT;
|
||||
}
|
||||
@@ -135,9 +109,6 @@ struct ast_node_type class_node_ops = {
|
||||
.n_init_state = init_state,
|
||||
.n_state_size = sizeof(struct class_parser_state),
|
||||
.n_node_size = sizeof(struct ivy_ast_class_node),
|
||||
.n_symbol_parsers = {
|
||||
[IVY_SYM_DOT] = parse_dot,
|
||||
},
|
||||
.n_token_parsers = {
|
||||
[IVY_TOK_IDENT] = parse_ident,
|
||||
[IVY_TOK_LINEFEED] = parse_linefeed,
|
||||
|
||||
Reference in New Issue
Block a user