diff --git a/compiler/ast.c b/compiler/ast.c index 6160aba..373ad1a 100644 --- a/compiler/ast.c +++ b/compiler/ast.c @@ -5,11 +5,11 @@ #include "../runtime/classes/string.h" #include "../runtime/classes/symbol.h" -typedef rt_value (*get_node_name_proc)(node_t *node); +typedef rt_value (*get_node_name_proc)(struct node *node); -rt_value get_node_name(node_t *node); +rt_value get_node_name(struct node *node); -rt_value name_unary_op(node_t *node) +rt_value name_unary_op(struct node *node) { rt_value result = rt_string_from_cstr("("); @@ -20,7 +20,7 @@ rt_value name_unary_op(node_t *node) return result; } -rt_value name_binary_op(node_t *node) +rt_value name_binary_op(struct node *node) { rt_value result = rt_string_from_cstr("("); @@ -34,17 +34,17 @@ rt_value name_binary_op(node_t *node) return result; } -rt_value name_num(node_t *node) +rt_value name_num(struct node *node) { return rt_string_from_int((rt_value)node->left); } -rt_value name_var(node_t *node) +rt_value name_var(struct node *node) { return rt_string_from_cstr(variable_name((rt_value)node->left)); } -rt_value name_const(node_t *node) +rt_value name_const(struct node *node) { rt_value result = get_node_name(node->left); @@ -54,7 +54,7 @@ rt_value name_const(node_t *node) return result; } -rt_value name_assign(node_t *node) +rt_value name_assign(struct node *node) { rt_value result = rt_string_from_cstr("("); @@ -66,7 +66,7 @@ rt_value name_assign(node_t *node) return result; } -rt_value name_assign_const(node_t *node) +rt_value name_assign_const(struct node *node) { rt_value result = rt_string_from_cstr("("); @@ -79,7 +79,7 @@ rt_value name_assign_const(node_t *node) return result; } -rt_value name_if(node_t *node) +rt_value name_if(struct node *node) { rt_value result = rt_string_from_cstr("("); @@ -96,7 +96,7 @@ rt_value name_if(node_t *node) return result; } -rt_value name_argument(node_t *node) +rt_value name_argument(struct node *node) { if(node->right) { @@ -111,7 +111,7 @@ rt_value name_argument(node_t *node) return get_node_name(node->left); } -rt_value name_call_tail(node_t *node) +rt_value name_call_tail(struct node *node) { rt_value result = rt_string_from_cstr(token_type_names[node->op]); @@ -122,7 +122,7 @@ rt_value name_call_tail(node_t *node) return result; } -rt_value name_call_arguments(node_t *node) +rt_value name_call_arguments(struct node *node) { rt_value result = rt_string_from_cstr("("); @@ -139,7 +139,7 @@ rt_value name_call_arguments(node_t *node) return result; } -rt_value name_call(node_t *node) +rt_value name_call(struct node *node) { rt_value result = get_node_name(node->left); @@ -150,7 +150,7 @@ rt_value name_call(node_t *node) return result; } -rt_value name_array_call(node_t *node) +rt_value name_array_call(struct node *node) { rt_value result = get_node_name(node->left); @@ -173,12 +173,12 @@ rt_value name_array_call(node_t *node) return result; } -rt_value name_lookup_tail(node_t *node) +rt_value name_lookup_tail(struct node *node) { return rt_string_from_cstr("(tail!"); } -rt_value name_expressions(node_t *node) +rt_value name_expressions(struct node *node) { rt_value result = get_node_name(node->left); @@ -191,7 +191,7 @@ rt_value name_expressions(node_t *node) return result; } -rt_value name_class(node_t *node) +rt_value name_class(struct node *node) { rt_value result = rt_string_from_cstr("class "); @@ -203,7 +203,7 @@ rt_value name_class(node_t *node) return result; } -rt_value name_module(node_t *node) +rt_value name_module(struct node *node) { rt_value result = rt_string_from_cstr("module "); @@ -215,7 +215,7 @@ rt_value name_module(node_t *node) return result; } -rt_value name_scope(node_t *node) +rt_value name_scope(struct node *node) { rt_value result = rt_string_from_cstr("scope:("); @@ -225,7 +225,7 @@ rt_value name_scope(node_t *node) return result; } -rt_value name_method(node_t *node) +rt_value name_method(struct node *node) { rt_value result = rt_string_from_cstr("def "); @@ -237,27 +237,27 @@ rt_value name_method(node_t *node) return result; } -rt_value name_self(node_t *node) +rt_value name_self(struct node *node) { return rt_string_from_cstr("self"); } -rt_value name_true(node_t *node) +rt_value name_true(struct node *node) { return rt_string_from_cstr("true"); } -rt_value name_false(node_t *node) +rt_value name_false(struct node *node) { return rt_string_from_cstr("false"); } -rt_value name_nil(node_t *node) +rt_value name_nil(struct node *node) { return rt_string_from_cstr("nil"); } -rt_value name_string(node_t *node) +rt_value name_string(struct node *node) { rt_value result = rt_string_from_cstr("\""); @@ -267,7 +267,7 @@ rt_value name_string(node_t *node) return result; } -rt_value name_string_continue(node_t *node) +rt_value name_string_continue(struct node *node) { rt_value result; @@ -289,7 +289,7 @@ rt_value name_string_continue(node_t *node) return result; } -rt_value name_string_start(node_t *node) +rt_value name_string_start(struct node *node) { rt_value result = get_node_name(node->left); @@ -299,7 +299,7 @@ rt_value name_string_start(node_t *node) return result; } -rt_value name_array(node_t *node) +rt_value name_array(struct node *node) { rt_value result = rt_string_from_cstr("["); rt_concat_string(result, get_node_name(node->left)); @@ -308,7 +308,7 @@ rt_value name_array(node_t *node) return result; } -rt_value name_array_element(node_t *node) +rt_value name_array_element(struct node *node) { rt_value result = get_node_name(node->left); @@ -321,7 +321,7 @@ rt_value name_array_element(node_t *node) return result; } -rt_value name_boolean(node_t *node) +rt_value name_boolean(struct node *node) { rt_value result = rt_string_from_cstr("("); rt_concat_string(result, get_node_name(node->left)); @@ -334,7 +334,7 @@ rt_value name_boolean(node_t *node) return result; } -rt_value name_not(node_t *node) +rt_value name_not(struct node *node) { rt_value result = rt_string_from_cstr("(not "); rt_concat_string(result, get_node_name(node->left)); @@ -343,12 +343,12 @@ rt_value name_not(node_t *node) return result; } -rt_value name_ivar(node_t *node) +rt_value name_ivar(struct node *node) { return rt_symbol_to_s((rt_value)node->left, 0, 0, 0); } -rt_value name_ivar_assign(node_t *node) +rt_value name_ivar_assign(struct node *node) { rt_value result = rt_string_from_cstr("("); @@ -360,7 +360,7 @@ rt_value name_ivar_assign(node_t *node) return result; } -rt_value name_no_equality(node_t *node) +rt_value name_no_equality(struct node *node) { rt_value result = rt_string_from_cstr("("); @@ -374,7 +374,7 @@ rt_value name_no_equality(node_t *node) return result; } -rt_value name_handler(node_t *node) +rt_value name_handler(struct node *node) { rt_value result = rt_string_from_cstr("(begin ("); @@ -402,7 +402,7 @@ rt_value name_handler(node_t *node) return result; } -rt_value name_break_handler(node_t *node) +rt_value name_break_handler(struct node *node) { rt_value result = rt_string_from_cstr("(begin ("); @@ -413,7 +413,7 @@ rt_value name_break_handler(node_t *node) return result; } -rt_value name_rescue(node_t *node) +rt_value name_rescue(struct node *node) { rt_value result = rt_string_from_cstr("rescue ("); @@ -430,7 +430,7 @@ rt_value name_rescue(node_t *node) return result; } -rt_value name_return(node_t *node) +rt_value name_return(struct node *node) { rt_value result = rt_string_from_cstr("return "); @@ -439,7 +439,7 @@ rt_value name_return(node_t *node) return result; } -rt_value name_break(node_t *node) +rt_value name_break(struct node *node) { rt_value result = rt_string_from_cstr("break "); @@ -448,7 +448,7 @@ rt_value name_break(node_t *node) return result; } -rt_value name_next(node_t *node) +rt_value name_next(struct node *node) { rt_value result = rt_string_from_cstr("next "); @@ -457,7 +457,7 @@ rt_value name_next(node_t *node) return result; } -rt_value name_redo(node_t *node) +rt_value name_redo(struct node *node) { rt_value result = rt_string_from_cstr("redo "); @@ -508,7 +508,7 @@ get_node_name_proc get_node_name_procs[] = { name_method }; -rt_value get_node_name(node_t *node) +rt_value get_node_name(struct node *node) { if (node) return get_node_name_procs[node->type](node); diff --git a/compiler/ast.h b/compiler/ast.h index 1041de9..0905bd4 100644 --- a/compiler/ast.h +++ b/compiler/ast.h @@ -44,12 +44,12 @@ enum node_type { N_PARAMETER }; -typedef struct node { +struct node { struct node *left; struct node *middle; struct node *right; enum node_type type; enum token_type op; -} node_t; +}; -rt_value get_node_name(node_t *node); +rt_value get_node_name(struct node *node); diff --git a/compiler/generator/generator.c b/compiler/generator/generator.c index 1d1e54c..f4d9490 100644 --- a/compiler/generator/generator.c +++ b/compiler/generator/generator.c @@ -4,11 +4,11 @@ #include "../../runtime/classes/fixnum.h" #include "../../runtime/support.h" -typedef void(*generator)(struct block *block, node_t *node, struct variable *var); +typedef void(*generator)(struct block *block, struct node *node, struct variable *var); -static inline void gen_node(struct block *block, node_t *node, struct variable *var); +static inline void gen_node(struct block *block, struct node *node, struct variable *var); -static void gen_unary_op(struct block *block, node_t *node, struct variable *var) +static void gen_unary_op(struct block *block, struct node *node, struct variable *var) { struct variable *temp = var ? var : block_get_var(block); @@ -23,7 +23,7 @@ static void gen_unary_op(struct block *block, node_t *node, struct variable *var block_push(block, B_STORE, (rt_value)var, 0, 0); } -static void gen_binary_op(struct block *block, node_t *node, struct variable *var) +static void gen_binary_op(struct block *block, struct node *node, struct variable *var) { struct variable *temp1 = var ? var : block_get_var(block); struct variable *temp2 = block_get_var(block); @@ -42,13 +42,13 @@ static void gen_binary_op(struct block *block, node_t *node, struct variable *va block_push(block, B_STORE, (rt_value)var, 0, 0); } -static void gen_num(struct block *block, node_t *node, struct variable *var) +static void gen_num(struct block *block, struct node *node, struct variable *var) { if (var) block_push(block, B_MOV_IMM, (rt_value)var, RT_INT2FIX(node->left), 0); } -static void gen_var(struct block *block, node_t *node, struct variable *var) +static void gen_var(struct block *block, struct node *node, struct variable *var) { if(var) { @@ -61,13 +61,13 @@ static void gen_var(struct block *block, node_t *node, struct variable *var) } } -static void gen_string(struct block *block, node_t *node, struct variable *var) +static void gen_string(struct block *block, struct node *node, struct variable *var) { if (var) block_push(block, B_STRING, (rt_value)var, (rt_value)node->left, 0); } -static void gen_string_continue(struct block *block, node_t *node, struct variable *var) +static void gen_string_continue(struct block *block, struct node *node, struct variable *var) { struct variable *temp = var ? var : block_get_var(block); @@ -84,7 +84,7 @@ static void gen_string_continue(struct block *block, node_t *node, struct variab block_push(block, B_PUSH, (rt_value)interpolated, 0, 0); } -static size_t gen_string_arg_count(node_t *node) +static size_t gen_string_arg_count(struct node *node) { if(node->left) return 2 + gen_string_arg_count(node->left); @@ -92,7 +92,7 @@ static size_t gen_string_arg_count(node_t *node) return 2; } -static void gen_string_start(struct block *block, node_t *node, struct variable *var) +static void gen_string_start(struct block *block, struct node *node, struct variable *var) { struct variable *args = block_gen_args(block); @@ -110,7 +110,7 @@ static void gen_string_start(struct block *block, node_t *node, struct variable } -static void gen_const(struct block *block, node_t *node, struct variable *var) +static void gen_const(struct block *block, struct node *node, struct variable *var) { if (var) { @@ -122,7 +122,7 @@ static void gen_const(struct block *block, node_t *node, struct variable *var) } } -static void gen_self(struct block *block, node_t *node, struct variable *var) +static void gen_self(struct block *block, struct node *node, struct variable *var) { if (var) { @@ -131,25 +131,25 @@ static void gen_self(struct block *block, node_t *node, struct variable *var) } } -static void gen_true(struct block *block, node_t *node, struct variable *var) +static void gen_true(struct block *block, struct node *node, struct variable *var) { if (var) block_push(block, B_MOV_IMM, (rt_value)var, RT_TRUE, 0); } -static void gen_false(struct block *block, node_t *node, struct variable *var) +static void gen_false(struct block *block, struct node *node, struct variable *var) { if (var) block_push(block, B_MOV_IMM, (rt_value)var, RT_FALSE, 0); } -static void gen_nil(struct block *block, node_t *node, struct variable *var) +static void gen_nil(struct block *block, struct node *node, struct variable *var) { if (var) block_push(block, B_MOV_IMM, (rt_value)var, RT_NIL, 0); } -static void gen_assign(struct block *block, node_t *node, struct variable *var) +static void gen_assign(struct block *block, struct node *node, struct variable *var) { struct variable *reading = (struct variable *)node->left; @@ -173,7 +173,7 @@ static void gen_assign(struct block *block, node_t *node, struct variable *var) } } -static void gen_const_assign(struct block *block, node_t *node, struct variable *var) +static void gen_const_assign(struct block *block, struct node *node, struct variable *var) { struct variable *self = block_get_var(block); struct variable *value = block_get_var(block); @@ -188,7 +188,7 @@ static void gen_const_assign(struct block *block, node_t *node, struct variable block_push(block, B_MOV, (rt_value)var, (rt_value)value, 0); } -static void gen_if(struct block *block, node_t *node, struct variable *var) +static void gen_if(struct block *block, struct node *node, struct variable *var) { struct variable *temp = var ? var : block_get_var(block); opcode_t *label_else = block_get_label(block); @@ -229,7 +229,7 @@ static void gen_if(struct block *block, node_t *node, struct variable *var) } } -static void gen_expressions(struct block *block, node_t *node, struct variable *var) +static void gen_expressions(struct block *block, struct node *node, struct variable *var) { gen_node(block, node->left, 0); @@ -237,7 +237,7 @@ static void gen_expressions(struct block *block, node_t *node, struct variable * gen_node(block, node->right, var); } -static void gen_class(struct block *block, node_t *node, struct variable *var) +static void gen_class(struct block *block, struct node *node, struct variable *var) { block->self_ref++; block_push(block, B_CLASS, (rt_value)node->left, (rt_value)gen_block(node->right), 0); @@ -246,7 +246,7 @@ static void gen_class(struct block *block, node_t *node, struct variable *var) block_push(block, B_STORE, (rt_value)var, 0, 0); } -static void gen_module(struct block *block, node_t *node, struct variable *var) +static void gen_module(struct block *block, struct node *node, struct variable *var) { block->self_ref++; block_push(block, B_MODULE, (rt_value)node->left, (rt_value)gen_block(node->right), 0); @@ -255,7 +255,7 @@ static void gen_module(struct block *block, node_t *node, struct variable *var) block_push(block, B_STORE, (rt_value)var, 0, 0); } -static void gen_method(struct block *block, node_t *node, struct variable *var) +static void gen_method(struct block *block, struct node *node, struct variable *var) { block->self_ref++; block_push(block, B_METHOD, (rt_value)node->left, (rt_value)gen_block(node->right), 0); @@ -264,7 +264,7 @@ static void gen_method(struct block *block, node_t *node, struct variable *var) block_push(block, B_MOV_IMM, (rt_value)var, RT_NIL, 0); } -static int gen_argument(struct block *block, node_t *node, struct variable *var) +static int gen_argument(struct block *block, struct node *node, struct variable *var) { struct variable *temp = var ? var : block_get_var(block); @@ -301,7 +301,7 @@ static struct variable *get_upval(struct block *block, struct variable *var) } } -static void generate_call(struct block *block, node_t *self, rt_value name, node_t *arguments, node_t *block_node, struct variable *var) +static void generate_call(struct block *block, struct node *self, rt_value name, struct node *arguments, struct node *block_node, struct variable *var) { struct variable *self_var = block_get_var(block); @@ -359,17 +359,17 @@ static void generate_call(struct block *block, node_t *self, rt_value name, node block_push(block, B_STORE, (rt_value)var, 0, 0); } -static void gen_call(struct block *block, node_t *node, struct variable *var) +static void gen_call(struct block *block, struct node *node, struct variable *var) { generate_call(block, node->left, (rt_value)node->middle, node->right->left, node->right->right, var); } -static void gen_array_call(struct block *block, node_t *node, struct variable *var) +static void gen_array_call(struct block *block, struct node *node, struct variable *var) { generate_call(block, node->left, rt_symbol_from_cstr("[]"), node->middle, node->right, var); } -static size_t gen_array_element(struct block *block, node_t *node, struct variable *var) +static size_t gen_array_element(struct block *block, struct node *node, struct variable *var) { gen_node(block, node->left, var); @@ -381,7 +381,7 @@ static size_t gen_array_element(struct block *block, node_t *node, struct variab return 1; } -static void gen_array(struct block *block, node_t *node, struct variable *var) +static void gen_array(struct block *block, struct node *node, struct variable *var) { struct variable *args = block_gen_args(block); @@ -392,7 +392,7 @@ static void gen_array(struct block *block, node_t *node, struct variable *var) block_push(block, B_ARRAY, (rt_value)var, 0, 0); } -static void gen_boolean(struct block *block, node_t *node, struct variable *var) +static void gen_boolean(struct block *block, struct node *node, struct variable *var) { struct variable *temp = var ? var : block_get_var(block); @@ -408,7 +408,7 @@ static void gen_boolean(struct block *block, node_t *node, struct variable *var) block_emmit_label(block, label_end); } -static void gen_not(struct block *block, node_t *node, struct variable *var) +static void gen_not(struct block *block, struct node *node, struct variable *var) { if(var) { @@ -435,12 +435,12 @@ static void gen_not(struct block *block, node_t *node, struct variable *var) gen_node(block, node->left, 0); } -static void gen_warn(struct block *block, node_t *node, struct variable *var) +static void gen_warn(struct block *block, struct node *node, struct variable *var) { printf("node %d entered in code generation\n", node->type); } -static void gen_ivar(struct block *block, node_t *node, struct variable *var) +static void gen_ivar(struct block *block, struct node *node, struct variable *var) { if(var) { @@ -449,7 +449,7 @@ static void gen_ivar(struct block *block, node_t *node, struct variable *var) } } -static void gen_ivar_assign(struct block *block, node_t *node, struct variable *var) +static void gen_ivar_assign(struct block *block, struct node *node, struct variable *var) { struct variable *temp = var ? var : block_get_var(block); @@ -460,7 +460,7 @@ static void gen_ivar_assign(struct block *block, node_t *node, struct variable * block_push(block, B_SET_IVAR, (rt_value)node->left, (rt_value)temp, 0); } -static void gen_no_equality(struct block *block, node_t *node, struct variable *var) +static void gen_no_equality(struct block *block, struct node *node, struct variable *var) { if(var) { @@ -507,7 +507,7 @@ static bool has_ensure_block(struct block *block) return false; } -static void gen_return(struct block *block, node_t *node, struct variable *var) +static void gen_return(struct block *block, struct node *node, struct variable *var) { struct variable *temp = var ? var : block_get_var(block); @@ -529,7 +529,7 @@ static void gen_return(struct block *block, node_t *node, struct variable *var) block_push(block, B_RETURN, (rt_value)temp, 0, 0); } -static void gen_break(struct block *block, node_t *node, struct variable *var) +static void gen_break(struct block *block, struct node *node, struct variable *var) { struct variable *temp = var ? var : block_get_var(block); @@ -538,7 +538,7 @@ static void gen_break(struct block *block, node_t *node, struct variable *var) block_push(block, B_RAISE_BREAK, (rt_value)temp, (rt_value)block->parent->data, block->break_id); } -static void gen_next(struct block *block, node_t *node, struct variable *var) +static void gen_next(struct block *block, struct node *node, struct variable *var) { struct variable *temp = var ? var : block_get_var(block); @@ -547,12 +547,12 @@ static void gen_next(struct block *block, node_t *node, struct variable *var) block_push(block, B_RETURN, (rt_value)temp, 0, 0); } -static void gen_redo(struct block *block, node_t *node, struct variable *var) +static void gen_redo(struct block *block, struct node *node, struct variable *var) { block_push(block, B_REDO, 0, 0, 0); } -static void gen_break_handler(struct block *block, node_t *node, struct variable *var) +static void gen_break_handler(struct block *block, struct node *node, struct variable *var) { struct block *child = (void *)node->right; @@ -581,7 +581,7 @@ static void gen_break_handler(struct block *block, node_t *node, struct variable } } -static void gen_handler(struct block *block, node_t *node, struct variable *var) +static void gen_handler(struct block *block, struct node *node, struct variable *var) { block->require_exceptions = true; // duh @@ -707,14 +707,14 @@ generator generators[] = { gen_method }; -static inline void gen_node(struct block *block, node_t *node, struct variable *var) +static inline void gen_node(struct block *block, struct node *node, struct variable *var) { RT_ASSERT(node != 0); generators[node->type](block, node, var); } -struct block *gen_block(node_t *node) +struct block *gen_block(struct node *node) { struct block *block = (void *)node->left; diff --git a/compiler/generator/generator.h b/compiler/generator/generator.h index fdab3e9..107200e 100644 --- a/compiler/generator/generator.h +++ b/compiler/generator/generator.h @@ -4,4 +4,4 @@ #include "../block.h" #include "../parser/parser.h" -struct block *gen_block(node_t* node); +struct block *gen_block(struct node* node); diff --git a/compiler/parser/calls.c b/compiler/parser/calls.c index ac8ff9f..7349f0b 100644 --- a/compiler/parser/calls.c +++ b/compiler/parser/calls.c @@ -2,7 +2,7 @@ #include "structures.h" #include "../../runtime/classes/symbol.h" -node_t *parse_block(struct compiler *compiler) +struct node *parse_block(struct compiler *compiler) { bool curly; @@ -24,7 +24,7 @@ node_t *parse_block(struct compiler *compiler) struct block *block; - node_t *result = alloc_scope(compiler, &block, S_CLOSURE); + struct node *result = alloc_scope(compiler, &block, S_CLOSURE); skip_lines(compiler); @@ -46,7 +46,7 @@ node_t *parse_block(struct compiler *compiler) return result; } -node_t *secure_block(struct compiler *compiler, node_t *result, node_t *parent) +struct node *secure_block(struct compiler *compiler, struct node *result, struct node *parent) { if(!result) return parent; @@ -55,7 +55,7 @@ node_t *secure_block(struct compiler *compiler, node_t *result, node_t *parent) if(block->can_break) { - node_t *handler = alloc_node(compiler, N_BREAK_HANDLER); + struct node *handler = alloc_node(compiler, N_BREAK_HANDLER); block->break_id = compiler->current_block->break_targets++; // Assign a break id to the block and increase the break target count. @@ -107,13 +107,13 @@ bool has_arguments(struct compiler *compiler) return false; } -node_t *parse_arguments(struct compiler *compiler, bool has_args) +struct node *parse_arguments(struct compiler *compiler, bool has_args) { if (has_args && lexer_current(compiler) != T_CURLY_OPEN) { if (lexer_current(compiler) == T_PARAM_OPEN && !lexer_token(compiler)->whitespace) { - node_t *result = 0; + struct node *result = 0; lexer_next(compiler); @@ -131,11 +131,11 @@ node_t *parse_arguments(struct compiler *compiler, bool has_args) return 0; } -node_t *parse_yield(struct compiler *compiler) +struct node *parse_yield(struct compiler *compiler) { lexer_next(compiler); - node_t *result = alloc_node(compiler, N_CALL); + struct node *result = alloc_node(compiler, N_CALL); result->left = alloc_node(compiler, N_VAR); @@ -153,7 +153,7 @@ node_t *parse_yield(struct compiler *compiler) return result; } -node_t *parse_call(struct compiler *compiler, rt_value symbol, node_t *child, bool default_var) +struct node *parse_call(struct compiler *compiler, rt_value symbol, struct node *child, bool default_var) { if(!symbol) { @@ -184,7 +184,7 @@ node_t *parse_call(struct compiler *compiler, rt_value symbol, node_t *child, bo { if(local) { - node_t *result = alloc_node(compiler, N_VAR); + struct node *result = alloc_node(compiler, N_VAR); result->left = (void *)scope_define(compiler->current_block, symbol, V_LOCAL, true); @@ -192,7 +192,7 @@ node_t *parse_call(struct compiler *compiler, rt_value symbol, node_t *child, bo } else { - node_t *result = alloc_node(compiler, N_CONST); + struct node *result = alloc_node(compiler, N_CONST); result->left = child; result->right = (void *)symbol; @@ -202,7 +202,7 @@ node_t *parse_call(struct compiler *compiler, rt_value symbol, node_t *child, bo } else // Call { - node_t *result = alloc_node(compiler, N_CALL); + struct node *result = alloc_node(compiler, N_CALL); result->left = child; result->middle = (void *)symbol; @@ -220,7 +220,7 @@ static inline bool is_lookup(struct compiler *compiler) return lexer_current(compiler) == T_DOT || lexer_current(compiler) == T_SQUARE_OPEN || lexer_current(compiler) == T_SCOPE; } -node_t *parse_lookup(struct compiler *compiler, node_t *child) +struct node *parse_lookup(struct compiler *compiler, struct node *child) { switch(lexer_current(compiler)) { @@ -235,7 +235,7 @@ node_t *parse_lookup(struct compiler *compiler, node_t *child) if(lexer_require(compiler, T_IDENT)) { rt_value symbol = rt_symbol_from_lexer(compiler); - node_t *result; + struct node *result; if(rt_symbol_is_const(symbol)) { @@ -274,7 +274,7 @@ node_t *parse_lookup(struct compiler *compiler, node_t *child) { lexer_next(compiler); - node_t *result = alloc_node(compiler, N_ARRAY_CALL); + struct node *result = alloc_node(compiler, N_ARRAY_CALL); result->left = child; result->middle = parse_argument(compiler); @@ -290,7 +290,7 @@ node_t *parse_lookup(struct compiler *compiler, node_t *child) } } -node_t *parse_lookup_tail(struct compiler *compiler, node_t *tail) +struct node *parse_lookup_tail(struct compiler *compiler, struct node *tail) { if(tail && tail->type == N_CALL && tail->right) return tail; @@ -311,7 +311,7 @@ node_t *parse_lookup_tail(struct compiler *compiler, node_t *tail) { case N_CONST: { - node_t *result = alloc_node(compiler, N_ASSIGN_CONST); + struct node *result = alloc_node(compiler, N_ASSIGN_CONST); result->left = tail->left; result->middle = tail->right; @@ -352,8 +352,8 @@ node_t *parse_lookup_tail(struct compiler *compiler, node_t *tail) { tail->type = N_CALL; - node_t *block = tail->right; - node_t *argument = tail->middle; + struct node *block = tail->right; + struct node *argument = tail->middle; tail->middle = (void *)rt_symbol_from_cstr("[]="); tail->right = alloc_node(compiler, N_CALL_ARGUMENTS); @@ -390,13 +390,13 @@ node_t *parse_lookup_tail(struct compiler *compiler, node_t *tail) } } -node_t *parse_lookup_chain(struct compiler *compiler) +struct node *parse_lookup_chain(struct compiler *compiler) { - node_t *result = parse_factor(compiler); + struct node *result = parse_factor(compiler); while(is_lookup(compiler)) { - node_t *node = parse_lookup(compiler, result); + struct node *node = parse_lookup(compiler, result); result = node; } diff --git a/compiler/parser/calls.h b/compiler/parser/calls.h index 9f8f45d..769222f 100644 --- a/compiler/parser/calls.h +++ b/compiler/parser/calls.h @@ -2,6 +2,6 @@ #include "parser.h" #include "../../runtime/classes.h" -node_t *parse_call(struct compiler *compiler, rt_value symbol, node_t *child, bool default_var); -node_t *parse_lookup_chain(struct compiler *compiler); -node_t *parse_yield(struct compiler *compiler); +struct node *parse_call(struct compiler *compiler, rt_value symbol, struct node *child, bool default_var); +struct node *parse_lookup_chain(struct compiler *compiler); +struct node *parse_yield(struct compiler *compiler); diff --git a/compiler/parser/control_flow.c b/compiler/parser/control_flow.c index b702dc5..04f2b83 100644 --- a/compiler/parser/control_flow.c +++ b/compiler/parser/control_flow.c @@ -1,10 +1,10 @@ #include "control_flow.h" -node_t *parse_return(struct compiler *compiler) +struct node *parse_return(struct compiler *compiler) { lexer_next(compiler); - node_t *result = alloc_node(compiler, N_RETURN); + struct node *result = alloc_node(compiler, N_RETURN); if(compiler->current_block->type == S_CLOSURE) compiler->current_block->owner->require_exceptions = true; // Make sure our parent can handle the return exception. @@ -17,11 +17,11 @@ node_t *parse_return(struct compiler *compiler) return result; } -node_t *parse_next(struct compiler *compiler) +struct node *parse_next(struct compiler *compiler) { lexer_next(compiler); - node_t *result = alloc_node(compiler, N_NEXT); + struct node *result = alloc_node(compiler, N_NEXT); if(compiler->current_block->type != S_CLOSURE) COMPILER_ERROR(compiler, "Next outside of block."); @@ -34,11 +34,11 @@ node_t *parse_next(struct compiler *compiler) return result; } -node_t *parse_redo(struct compiler *compiler) +struct node *parse_redo(struct compiler *compiler) { lexer_next(compiler); - node_t *result = alloc_node(compiler, N_REDO); + struct node *result = alloc_node(compiler, N_REDO); if(compiler->current_block->type != S_CLOSURE) COMPILER_ERROR(compiler, "Redo outside of block."); @@ -46,11 +46,11 @@ node_t *parse_redo(struct compiler *compiler) return result; } -node_t *parse_break(struct compiler *compiler) +struct node *parse_break(struct compiler *compiler) { lexer_next(compiler); - node_t *result = alloc_node(compiler, N_BREAK); + struct node *result = alloc_node(compiler, N_BREAK); if(compiler->current_block->type == S_CLOSURE) { @@ -67,9 +67,9 @@ node_t *parse_break(struct compiler *compiler) return result; } -node_t *parse_exception_handlers(struct compiler *compiler, node_t *block) +struct node *parse_exception_handlers(struct compiler *compiler, struct node *block) { - node_t *parent = alloc_node(compiler, N_HANDLER); + struct node *parent = alloc_node(compiler, N_HANDLER); parent->left = block; @@ -77,7 +77,7 @@ node_t *parse_exception_handlers(struct compiler *compiler, node_t *block) { lexer_next(compiler); - node_t *rescue = alloc_node(compiler, N_RESCUE); + struct node *rescue = alloc_node(compiler, N_RESCUE); rescue->left = parse_statements(compiler); rescue->right = 0; @@ -87,7 +87,7 @@ node_t *parse_exception_handlers(struct compiler *compiler, node_t *block) { lexer_next(compiler); - node_t *node = alloc_node(compiler, N_RESCUE); + struct node *node = alloc_node(compiler, N_RESCUE); node->left = parse_statements(compiler); node->right = 0; @@ -110,11 +110,11 @@ node_t *parse_exception_handlers(struct compiler *compiler, node_t *block) return parent; } -node_t *parse_begin(struct compiler *compiler) +struct node *parse_begin(struct compiler *compiler) { lexer_next(compiler); - node_t *result = parse_statements(compiler); + struct node *result = parse_statements(compiler); switch (lexer_current(compiler)) { @@ -146,15 +146,15 @@ void parse_then_sep(struct compiler *compiler) } } -node_t *parse_ternary_if(struct compiler *compiler) +struct node *parse_ternary_if(struct compiler *compiler) { - node_t *result = parse_boolean_or(compiler); + struct node *result = parse_boolean_or(compiler); if(lexer_current(compiler) == T_QUESTION) { lexer_next(compiler); - node_t *node = alloc_node(compiler, N_IF); + struct node *node = alloc_node(compiler, N_IF); node->left = result; node->middle = parse_ternary_if(compiler); @@ -169,13 +169,13 @@ node_t *parse_ternary_if(struct compiler *compiler) return result; } -node_t *parse_conditional(struct compiler *compiler) +struct node *parse_conditional(struct compiler *compiler) { - node_t *result = parse_low_boolean(compiler); + struct node *result = parse_low_boolean(compiler); if (lexer_current(compiler) == T_IF || lexer_current(compiler) == T_UNLESS) { - node_t *node = alloc_node(compiler, lexer_current(compiler) == T_IF ? N_IF : N_UNLESS); + struct node *node = alloc_node(compiler, lexer_current(compiler) == T_IF ? N_IF : N_UNLESS); lexer_next(compiler); @@ -189,11 +189,11 @@ node_t *parse_conditional(struct compiler *compiler) return result; } -node_t *parse_unless(struct compiler *compiler) +struct node *parse_unless(struct compiler *compiler) { lexer_next(compiler); - node_t *result = alloc_node(compiler, N_UNLESS); + struct node *result = alloc_node(compiler, N_UNLESS); result->left = parse_expression(compiler); parse_then_sep(compiler); @@ -206,7 +206,7 @@ node_t *parse_unless(struct compiler *compiler) return result; } -node_t *parse_if_tail(struct compiler *compiler) +struct node *parse_if_tail(struct compiler *compiler) { switch (lexer_current(compiler)) { @@ -214,7 +214,7 @@ node_t *parse_if_tail(struct compiler *compiler) { lexer_next(compiler); - node_t *result = alloc_node(compiler, N_IF); + struct node *result = alloc_node(compiler, N_IF); result->left = parse_expression(compiler); parse_then_sep(compiler); @@ -235,11 +235,11 @@ node_t *parse_if_tail(struct compiler *compiler) } } -node_t *parse_if(struct compiler *compiler) +struct node *parse_if(struct compiler *compiler) { lexer_next(compiler); - node_t *result = alloc_node(compiler, N_IF); + struct node *result = alloc_node(compiler, N_IF); result->left = parse_expression(compiler); parse_then_sep(compiler); @@ -252,7 +252,7 @@ node_t *parse_if(struct compiler *compiler) return result; } -node_t *parse_case_body(struct compiler *compiler) +struct node *parse_case_body(struct compiler *compiler) { switch (lexer_current(compiler)) { @@ -260,7 +260,7 @@ node_t *parse_case_body(struct compiler *compiler) { lexer_next(compiler); - node_t *result = alloc_node(compiler, N_IF); + struct node *result = alloc_node(compiler, N_IF); result->left = parse_expression(compiler); parse_then_sep(compiler); @@ -287,11 +287,11 @@ node_t *parse_case_body(struct compiler *compiler) } } -node_t *parse_case(struct compiler *compiler) +struct node *parse_case(struct compiler *compiler) { lexer_next(compiler); - node_t *result = 0; + struct node *result = 0; switch (lexer_current(compiler)) { diff --git a/compiler/parser/control_flow.h b/compiler/parser/control_flow.h index 23d1606..7cfd6e9 100644 --- a/compiler/parser/control_flow.h +++ b/compiler/parser/control_flow.h @@ -1,14 +1,14 @@ #pragma once #include "parser.h" -node_t *parse_if(struct compiler *compiler); -node_t *parse_unless(struct compiler *compiler); -node_t *parse_ternary_if(struct compiler *compiler); -node_t *parse_conditional(struct compiler *compiler); -node_t *parse_case(struct compiler *compiler); -node_t *parse_begin(struct compiler *compiler); -node_t *parse_exception_handlers(struct compiler *compiler, node_t *block); -node_t *parse_return(struct compiler *compiler); -node_t *parse_break(struct compiler *compiler); -node_t *parse_next(struct compiler *compiler); -node_t *parse_redo(struct compiler *compiler); +struct node *parse_if(struct compiler *compiler); +struct node *parse_unless(struct compiler *compiler); +struct node *parse_ternary_if(struct compiler *compiler); +struct node *parse_conditional(struct compiler *compiler); +struct node *parse_case(struct compiler *compiler); +struct node *parse_begin(struct compiler *compiler); +struct node *parse_exception_handlers(struct compiler *compiler, struct node *block); +struct node *parse_return(struct compiler *compiler); +struct node *parse_break(struct compiler *compiler); +struct node *parse_next(struct compiler *compiler); +struct node *parse_redo(struct compiler *compiler); diff --git a/compiler/parser/parser.c b/compiler/parser/parser.c index a7d2c47..d84fc04 100644 --- a/compiler/parser/parser.c +++ b/compiler/parser/parser.c @@ -6,11 +6,11 @@ struct node nil_node = {0, 0, 0, N_NIL, 0}; -node_t *alloc_scope(struct compiler *compiler, struct block **block_var, enum block_type type) +struct node *alloc_scope(struct compiler *compiler, struct block **block_var, enum block_type type) { struct block *block = block_create(compiler, type); - node_t *result = compiler_alloc(compiler, sizeof(node_t)); + struct node *result = compiler_alloc(compiler, sizeof(struct node)); block->parent = compiler->current_block; block->owner = compiler->current_block ? compiler->current_block->owner : 0; @@ -130,9 +130,9 @@ void parse_sep(struct compiler *compiler) } } -node_t *parse_argument(struct compiler *compiler) +struct node *parse_argument(struct compiler *compiler) { - node_t *result = alloc_node(compiler, N_ARGUMENT); + struct node *result = alloc_node(compiler, N_ARGUMENT); result->left = parse_expression(compiler); result->right = 0; @@ -145,7 +145,7 @@ node_t *parse_argument(struct compiler *compiler) return result; } -node_t *parse_identifier(struct compiler *compiler) +struct node *parse_identifier(struct compiler *compiler) { rt_value symbol = rt_symbol_from_lexer(compiler); @@ -158,7 +158,7 @@ node_t *parse_identifier(struct compiler *compiler) case T_ASSIGN_MUL: case T_ASSIGN_DIV: { - node_t *result; + struct node *result; enum token_type op_type = lexer_current(compiler) - OP_TO_ASSIGN; @@ -194,7 +194,7 @@ node_t *parse_identifier(struct compiler *compiler) case T_ASSIGN: { - node_t *result; + struct node *result; lexer_next(compiler); @@ -222,9 +222,9 @@ node_t *parse_identifier(struct compiler *compiler) } } -node_t *parse_array_element(struct compiler *compiler) +struct node *parse_array_element(struct compiler *compiler) { - node_t *result = alloc_node(compiler, N_ARRAY_ELEMENT); + struct node *result = alloc_node(compiler, N_ARRAY_ELEMENT); result->left = parse_expression(compiler); @@ -240,7 +240,7 @@ node_t *parse_array_element(struct compiler *compiler) return result; } -node_t *parse_factor(struct compiler *compiler) +struct node *parse_factor(struct compiler *compiler) { switch (lexer_current(compiler)) { @@ -282,7 +282,7 @@ node_t *parse_factor(struct compiler *compiler) case T_SQUARE_OPEN: { - node_t *result = alloc_node(compiler, N_ARRAY); + struct node *result = alloc_node(compiler, N_ARRAY); lexer_next(compiler); @@ -298,7 +298,7 @@ node_t *parse_factor(struct compiler *compiler) case T_STRING: { - node_t *result = alloc_node(compiler, N_STRING); + struct node *result = alloc_node(compiler, N_STRING); result->left = (void *)lexer_token(compiler)->start; @@ -309,7 +309,7 @@ node_t *parse_factor(struct compiler *compiler) case T_STRING_START: { - node_t *result = alloc_node(compiler, N_STRING_CONTINUE); + struct node *result = alloc_node(compiler, N_STRING_CONTINUE); result->left = 0; result->middle = (void *)lexer_token(compiler)->start; @@ -320,7 +320,7 @@ node_t *parse_factor(struct compiler *compiler) while(lexer_current(compiler) == T_STRING_CONTINUE) { - node_t *node = alloc_node(compiler, N_STRING_CONTINUE); + struct node *node = alloc_node(compiler, N_STRING_CONTINUE); node->left = result; node->middle = (void *)lexer_token(compiler)->start; @@ -334,7 +334,7 @@ node_t *parse_factor(struct compiler *compiler) if(lexer_require(compiler, T_STRING_END)) { - node_t *node = alloc_node(compiler, N_STRING_START); + struct node *node = alloc_node(compiler, N_STRING_START); node->left = result; node->right = (void *)lexer_token(compiler)->start; @@ -377,7 +377,7 @@ node_t *parse_factor(struct compiler *compiler) case T_NUMBER: { - node_t *result = alloc_node(compiler, N_NUMBER); + struct node *result = alloc_node(compiler, N_NUMBER); char *text = get_token_str(lexer_token(compiler)); @@ -401,7 +401,7 @@ node_t *parse_factor(struct compiler *compiler) case T_ASSIGN_MUL: case T_ASSIGN_DIV: { - node_t *result; + struct node *result; enum token_type op_type = lexer_current(compiler) - OP_TO_ASSIGN; @@ -422,7 +422,7 @@ node_t *parse_factor(struct compiler *compiler) case T_ASSIGN: { - node_t *result; + struct node *result; lexer_next(compiler); @@ -435,7 +435,7 @@ node_t *parse_factor(struct compiler *compiler) default: { - node_t *result = alloc_node(compiler, N_IVAR); + struct node *result = alloc_node(compiler, N_IVAR); result->left = (void *)symbol; @@ -454,7 +454,7 @@ node_t *parse_factor(struct compiler *compiler) { lexer_next(compiler); - node_t *result = parse_statements(compiler); + struct node *result = parse_statements(compiler); lexer_match(compiler, T_PARAM_CLOSE); @@ -472,11 +472,11 @@ node_t *parse_factor(struct compiler *compiler) } } -node_t *parse_unary(struct compiler *compiler) +struct node *parse_unary(struct compiler *compiler) { if(lexer_current(compiler) == T_ADD || lexer_current(compiler) == T_SUB) { - node_t *result = alloc_node(compiler, N_UNARY_OP); + struct node *result = alloc_node(compiler, N_UNARY_OP); result->op = lexer_current(compiler) + OP_TO_UNARY; @@ -490,13 +490,13 @@ node_t *parse_unary(struct compiler *compiler) return parse_lookup_chain(compiler); } -node_t *parse_term(struct compiler *compiler) +struct node *parse_term(struct compiler *compiler) { - node_t *result = parse_unary(compiler); + struct node *result = parse_unary(compiler); while(lexer_current(compiler) == T_MUL || lexer_current(compiler) == T_DIV) { - node_t *node = alloc_node(compiler, N_BINARY_OP); + struct node *node = alloc_node(compiler, N_BINARY_OP); node->op = lexer_current(compiler); node->left = result; @@ -510,13 +510,13 @@ node_t *parse_term(struct compiler *compiler) return result; } -node_t *parse_arithmetic(struct compiler *compiler) +struct node *parse_arithmetic(struct compiler *compiler) { - node_t *result = parse_term(compiler); + struct node *result = parse_term(compiler); while (lexer_current(compiler) == T_ADD || lexer_current(compiler) == T_SUB) { - node_t *node = alloc_node(compiler, N_BINARY_OP); + struct node *node = alloc_node(compiler, N_BINARY_OP); node->op = lexer_current(compiler); node->left = result; @@ -530,11 +530,11 @@ node_t *parse_arithmetic(struct compiler *compiler) return result; } -node_t *parse_boolean_unary(struct compiler *compiler) +struct node *parse_boolean_unary(struct compiler *compiler) { if(lexer_current(compiler) == T_NOT_SIGN) { - node_t *result = alloc_node(compiler, N_NOT); + struct node *result = alloc_node(compiler, N_NOT); lexer_next(compiler); @@ -560,13 +560,13 @@ static inline bool is_equality_op(struct compiler *compiler) } } -node_t *parse_equality(struct compiler *compiler) +struct node *parse_equality(struct compiler *compiler) { - node_t *result = parse_boolean_unary(compiler); + struct node *result = parse_boolean_unary(compiler); while(is_equality_op(compiler)) { - node_t *node; + struct node *node; if(lexer_current(compiler) == T_NO_EQUALITY) node = alloc_node(compiler, N_NO_EQUALITY); @@ -587,13 +587,13 @@ node_t *parse_equality(struct compiler *compiler) return result; } -node_t *parse_boolean_and(struct compiler *compiler) +struct node *parse_boolean_and(struct compiler *compiler) { - node_t *result = parse_equality(compiler); + struct node *result = parse_equality(compiler); while(lexer_current(compiler) == T_AND_BOOLEAN) { - node_t *node = alloc_node(compiler, N_BOOLEAN); + struct node *node = alloc_node(compiler, N_BOOLEAN); node->op = lexer_current(compiler); node->left = result; @@ -607,13 +607,13 @@ node_t *parse_boolean_and(struct compiler *compiler) return result; } -node_t *parse_boolean_or(struct compiler *compiler) +struct node *parse_boolean_or(struct compiler *compiler) { - node_t *result = parse_boolean_and(compiler); + struct node *result = parse_boolean_and(compiler); while(lexer_current(compiler) == T_OR_BOOLEAN) { - node_t *node = alloc_node(compiler, N_BOOLEAN); + struct node *node = alloc_node(compiler, N_BOOLEAN); node->op = lexer_current(compiler); node->left = result; @@ -627,16 +627,16 @@ node_t *parse_boolean_or(struct compiler *compiler) return result; } -node_t *parse_expression(struct compiler *compiler) +struct node *parse_expression(struct compiler *compiler) { return parse_ternary_if(compiler); } -node_t *parse_low_boolean_unary(struct compiler *compiler) +struct node *parse_low_boolean_unary(struct compiler *compiler) { if(lexer_current(compiler) == T_NOT) { - node_t *result = alloc_node(compiler, N_NOT); + struct node *result = alloc_node(compiler, N_NOT); lexer_next(compiler); @@ -648,13 +648,13 @@ node_t *parse_low_boolean_unary(struct compiler *compiler) return parse_expression(compiler); } -node_t *parse_low_boolean(struct compiler *compiler) +struct node *parse_low_boolean(struct compiler *compiler) { - node_t *result = parse_low_boolean_unary(compiler); + struct node *result = parse_low_boolean_unary(compiler); while(lexer_current(compiler) == T_AND || lexer_current(compiler) == T_OR) { - node_t *node = alloc_node(compiler, N_BOOLEAN); + struct node *node = alloc_node(compiler, N_BOOLEAN); node->op = lexer_current(compiler); node->left = result; @@ -668,7 +668,7 @@ node_t *parse_low_boolean(struct compiler *compiler) return result; } -node_t *parse_statement(struct compiler *compiler) +struct node *parse_statement(struct compiler *compiler) { return parse_conditional(compiler); } @@ -684,13 +684,13 @@ static inline void skip_seps(struct compiler *compiler) lexer_next(compiler); } -node_t *parse_statements(struct compiler *compiler) +struct node *parse_statements(struct compiler *compiler) { skip_seps(compiler); if(is_expression(compiler)) { - node_t *result = parse_statement(compiler); + struct node *result = parse_statement(compiler); if (is_sep(compiler)) { @@ -698,7 +698,7 @@ node_t *parse_statements(struct compiler *compiler) if(is_expression(compiler)) { - node_t *node = alloc_node(compiler, N_STATEMENTS); + struct node *node = alloc_node(compiler, N_STATEMENTS); node->left = result; node->right = parse_statements(compiler); @@ -714,11 +714,11 @@ node_t *parse_statements(struct compiler *compiler) return &nil_node; } -node_t *parse_main(struct compiler *compiler) +struct node *parse_main(struct compiler *compiler) { struct block *block; - node_t *result = alloc_scope(compiler, &block, S_MAIN); + struct node *result = alloc_scope(compiler, &block, S_MAIN); block->owner = block; diff --git a/compiler/parser/parser.h b/compiler/parser/parser.h index cb4ce27..ab30609 100644 --- a/compiler/parser/parser.h +++ b/compiler/parser/parser.h @@ -10,16 +10,16 @@ bool scope_defined(struct block *block, rt_value name, bool recursive); struct variable *scope_declare_var(struct block *block, rt_value name, enum variable_type type); struct variable *scope_define(struct block *block, rt_value name, enum variable_type type, bool recursive); -node_t *parse_factor(struct compiler *compiler); -node_t *parse_expression(struct compiler *compiler); -node_t *parse_argument(struct compiler *compiler); -node_t *parse_arithmetic(struct compiler *compiler); -node_t *parse_boolean_or(struct compiler *compiler); -node_t *parse_low_boolean(struct compiler *compiler); -node_t *parse_statement(struct compiler *compiler); -node_t *parse_statements(struct compiler *compiler); +struct node *parse_factor(struct compiler *compiler); +struct node *parse_expression(struct compiler *compiler); +struct node *parse_argument(struct compiler *compiler); +struct node *parse_arithmetic(struct compiler *compiler); +struct node *parse_boolean_or(struct compiler *compiler); +struct node *parse_low_boolean(struct compiler *compiler); +struct node *parse_statement(struct compiler *compiler); +struct node *parse_statements(struct compiler *compiler); void parse_sep(struct compiler *compiler); -node_t *parse_main(struct compiler *compiler); +struct node *parse_main(struct compiler *compiler); static inline void skip_lines(struct compiler *compiler) { @@ -66,11 +66,11 @@ static inline bool is_expression(struct compiler *compiler) } } -node_t *alloc_scope(struct compiler *compiler, struct block **block_var, enum block_type type); +struct node *alloc_scope(struct compiler *compiler, struct block **block_var, enum block_type type); -static inline node_t *alloc_node(struct compiler *compiler, node_type_t type) +static inline struct node *alloc_node(struct compiler *compiler, enum node_type type) { - node_t *result = compiler_alloc(compiler, sizeof(node_t)); + struct node *result = compiler_alloc(compiler, sizeof(struct node)); result->type = type; return result; diff --git a/compiler/parser/structures.c b/compiler/parser/structures.c index 0410bd9..ffef1f9 100644 --- a/compiler/parser/structures.c +++ b/compiler/parser/structures.c @@ -1,11 +1,11 @@ #include "structures.h" #include "../../runtime/classes/symbol.h" -node_t *parse_class(struct compiler *compiler) +struct node *parse_class(struct compiler *compiler) { lexer_next(compiler); - node_t *result = alloc_node(compiler, N_CLASS); + struct node *result = alloc_node(compiler, N_CLASS); if(lexer_require(compiler, T_IDENT)) { @@ -30,11 +30,11 @@ node_t *parse_class(struct compiler *compiler) return result; } -node_t *parse_module(struct compiler *compiler) +struct node *parse_module(struct compiler *compiler) { lexer_next(compiler); - node_t *result = alloc_node(compiler, N_MODULE); + struct node *result = alloc_node(compiler, N_MODULE); if(lexer_require(compiler, T_IDENT)) { @@ -106,7 +106,7 @@ void parse_parameter(struct compiler *compiler, struct block *block) COMPILER_ERROR(compiler, "Expected paramater, but found %s.", token_type_names[lexer_current(compiler)]); } -node_t *parse_method(struct compiler *compiler) +struct node *parse_method(struct compiler *compiler) { lexer_state(compiler, TS_NOKEYWORDS); @@ -114,7 +114,7 @@ node_t *parse_method(struct compiler *compiler) lexer_state(compiler, TS_DEFAULT); - node_t *result = alloc_node(compiler, N_METHOD); + struct node *result = alloc_node(compiler, N_METHOD); switch(lexer_current(compiler)) { diff --git a/compiler/parser/structures.h b/compiler/parser/structures.h index 993a98e..c79798c 100644 --- a/compiler/parser/structures.h +++ b/compiler/parser/structures.h @@ -2,6 +2,6 @@ #include "parser.h" void parse_parameter(struct compiler *compiler, struct block *block); -node_t *parse_class(struct compiler *compiler); -node_t *parse_module(struct compiler *compiler); -node_t *parse_method(struct compiler *compiler); +struct node *parse_class(struct compiler *compiler); +struct node *parse_module(struct compiler *compiler); +struct node *parse_method(struct compiler *compiler); diff --git a/main.c b/main.c index 7f63a28..7cdc1f9 100644 --- a/main.c +++ b/main.c @@ -28,7 +28,7 @@ int main() break; } - node_t* expression = parse_main(compiler); + struct node* expression = parse_main(compiler); if(compiler->err_count == 0) { diff --git a/runtime/runtime.c b/runtime/runtime.c index 48c8667..6c92299 100644 --- a/runtime/runtime.c +++ b/runtime/runtime.c @@ -48,12 +48,12 @@ rt_value rt_eval(rt_value self, const char *input, const char *filename) { struct compiler *compiler = compiler_create(input, filename); - node_t* expression = parse_main(compiler); + struct node* expression = parse_main(compiler); if(compiler->err_count != 0) return RT_NIL; - extern rt_value get_node_name(node_t *node); + extern rt_value get_node_name(struct node *node); #ifdef DEBUG printf("Tree: %s\n", rt_string_to_cstr(get_node_name(expression)));