expr_val * compile_statement(base_node * stmt, scope * scope, str_list * lines) { int op; switch (stmt->type) { case BINARY_OP_NODE: op = ((binary_op_node*) stmt)->op; switch(op) { case OP_EQUAL: return compile_assignment(((binary_op_node*) stmt), scope, lines); case OP_PLUS: return compile_addition(((binary_op_node*) stmt), scope, lines); case OP_TYPE_ASS: return compile_type_assignment(((binary_op_node*) stmt), scope, lines); case EQUAL: case LESS: case LESS_EQUAL: case GREATER: case GREATER_EQUAL: return compile_comparison_assignment(((binary_op_node*) stmt), scope, lines); } case IF_NODE: return compile_if((if_node*) stmt, scope, lines); case BLOCK_NODE: return compile_block((block_node *) stmt, scope, lines, 1); case ID_NODE: return compile_id(((id_node*) stmt), scope, lines); case INT_NODE: return compile_int((int_node*) stmt, scope, lines); case CHAR_NODE: return compile_char((char_node*) stmt, scope, lines); case INT_TYPE_NODE: return compile_int_type((type_node *) stmt, scope, lines); case CHAR_TYPE_NODE: return compile_char_type((type_node *) stmt, scope, lines); case FUNC_NODE: return compile_function((function_node*) stmt, scope, lines); case FUNC_ARGS_NODE: return compile_args((argument_node *) stmt, scope, lines); case RETURN_NODE: return compile_return((return_node *) stmt, scope, lines); case CALL_NODE: return compile_call((call_node *) stmt, scope, lines); case CALL_ARGS_NODE: return compile_call_args((argument_node *) stmt, scope, lines); case END_NODE: break; } return NULL; }
// Main compiler dispatch system void compile(compiler_wrapper *cw, ast_node *root) { switch(root->type) { case ABINARY_EXPRESSION: compile_binary(cw, root); break; case AUNARY_EXPRESSION: compile_unary(cw, root); break; case AVALUE: compile_value(cw, root); break; case AUNIT: compile_unit_value(cw, root); break; case ACOND_CHAIN: compile_cond(cw, root); break; case AIF: compile_if(cw, root); break; case ALOOP: compile_loop(cw, root); break; case AITERLOOP: compile_iter_loop(cw, root); break; case AFUNC_DECL: compile_function(cw, root); break; case AFUNC_CALL: compile_function_call(cw, root); break; case ACLASS_DECL: compile_class_decl(cw, root); break; case ATERNARY: compile_ternary(cw, root); break; case AMEMBER_ACCESS: compile_member_access(cw, root); break; case AARRAY: compile_array(cw, root); break; case ATABLE: compile_table(cw, root); break; case AOBJDECL: compile_object(cw, root); break; case AINDEX: compile_indx(cw, root); break; case ATRIPLESET: compile_triple_set(cw, root); break; case ATRYCATCH: compile_try_catch(cw, root); break; case AONEOFF: compile_one_off(cw, root); break; case ALOAD: compile_load(cw, root); break; case AREGEX: compile_regex(cw, root); break; default: break; } }