📄 meridiandsl.cpp
字号:
return thisNode; }ASTNode* mk_continue(ParserState* in_state) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = CONTINUE_TYPE; return thisNode; // Don't bother init the ASTVal}ASTNode* mk_break(ParserState* in_state) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = BREAK_TYPE; return thisNode; // Don't bother init the ASTVal}ASTNode* mk_node_list(ParserState* in_state, ASTNode* a, ASTNode* b) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = AST_TYPE; thisNode->val.b_val.b_left_node = a; thisNode->val.b_val.b_right_node = b; return thisNode; }ASTNode* mk_sep_list(ParserState* in_state, ASTNode* a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = SEP_TYPE; thisNode->val.p_val.p_vector = in_state->get_var_table()->new_stack_vector(); if (thisNode->val.p_val.p_vector == NULL) { return in_state->empty_token(); } thisNode->val.p_val.p_vector->push_back(a); return thisNode; }// Only used by NEW_VAR_ASSIGN_TYPE and RPC_TYPE ASTNode* mk_sep_list(ParserState* in_state, vector<ASTNode*>* a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = SEP_TYPE; thisNode->val.p_val.p_vector = a; return thisNode; }ASTNode* mk_return(ParserState* in_state, ASTNode* a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = RETURN_TYPE; thisNode->val.u_val.u_node = a; return thisNode;}ASTNode* mk_context(ParserState* in_state, ASTNode* a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = CONTEXT_TYPE; thisNode->val.u_val.u_node = a; return thisNode; }ASTNode* mk_new_var(ParserState* in_state, ASTType in_type, string* a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = NEW_VAR_TYPE; thisNode->val.v_val.v_type = in_type; thisNode->val.v_val.v_name = a; return thisNode;}ASTNode* mk_new_var_array( ParserState* in_state, ASTType in_type, string* a, ASTNode* size) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = NEW_VAR_TYPE; thisNode->val.v_val.v_type = ARRAY_TYPE; thisNode->val.v_val.v_name = a; thisNode->val.v_val.v_array_type = in_type; thisNode->val.v_val.v_array_size = size; return thisNode;}ASTNode* mk_new_adt_var_array( ParserState* in_state, string* adt_name, string* a, ASTNode* size) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = NEW_VAR_TYPE; thisNode->val.v_val.v_type = ARRAY_TYPE; thisNode->val.v_val.v_name = a; thisNode->val.v_val.v_adt_name = adt_name; thisNode->val.v_val.v_array_type = ADT_TYPE; thisNode->val.v_val.v_array_size = size; return thisNode;}ASTNode* mk_new_adt_var(ParserState* in_state, string* adt_name, string* a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = NEW_VAR_TYPE; thisNode->val.v_val.v_type = ADT_TYPE; thisNode->val.v_val.v_name = a; thisNode->val.v_val.v_adt_name = adt_name; return thisNode;}ASTNode* mk_new_adt_var_assign( ParserState* in_state, string* adt_name, string* a, ASTNode* b) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = NEW_VAR_ASSIGN_TYPE; thisNode->val.v_val.v_type = ADT_TYPE; thisNode->val.v_val.v_name = a; thisNode->val.v_val.v_adt_name = adt_name; thisNode->val.v_val.v_assign = b; return thisNode;}ASTNode* mk_new_var_assign( ParserState* in_state, ASTType in_type, string* a, ASTNode* b) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = NEW_VAR_ASSIGN_TYPE; thisNode->val.v_val.v_type = in_type; thisNode->val.v_val.v_name = a; thisNode->val.v_val.v_assign = b; return thisNode;}ASTNode* mk_new_var_array_assign(ParserState* in_state, ASTType in_type, string* a, ASTNode* b, ASTNode* size) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = NEW_VAR_ASSIGN_TYPE; thisNode->val.v_val.v_type = ARRAY_TYPE; thisNode->val.v_val.v_name = a; thisNode->val.v_val.v_array_type = in_type; thisNode->val.v_val.v_array_size = size; thisNode->val.v_val.v_assign = b; return thisNode;}ASTNode* mk_new_adt_var_array_assign(ParserState* in_state, string* adt_name, string* a, ASTNode* b, ASTNode* size) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = NEW_VAR_ASSIGN_TYPE; thisNode->val.v_val.v_type = ARRAY_TYPE; thisNode->val.v_val.v_name = a; thisNode->val.v_val.v_adt_name = adt_name; thisNode->val.v_val.v_array_type = ADT_TYPE; thisNode->val.v_val.v_array_size = size; thisNode->val.v_val.v_assign = b; return thisNode;}ASTNode* mk_ref_var(ParserState* in_state, string* a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = REF_VAR_TYPE; // Type info does not need to be init thisNode->val.v_val.v_name = a; return thisNode; }ASTNode* mk_ref_adt_var(ParserState* in_state, ASTNode* a, string* b) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = REF_VAR_ADT_TYPE; // Type info does not need to be init thisNode->val.v_val.v_name_ast = a; thisNode->val.v_val.v_name_dot_name = b; return thisNode; }ASTNode* mk_ref_array_var(ParserState* in_state, ASTNode* a, ASTNode* b) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = REF_VAR_ARRAY_TYPE; // Type info does not need to be init thisNode->val.v_val.v_name_ast = a; thisNode->val.v_val.v_access_ast = b; return thisNode; }ASTNode* mk_int(ParserState* in_state, int a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = INT_TYPE; thisNode->val.i_val = a; return thisNode;}ASTNode* mk_double(ParserState* in_state, double a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = DOUBLE_TYPE; thisNode->val.d_val = a; return thisNode;}ASTNode* mk_native_func_0(ParserState* in_state, int type) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = NATIVE_FUNC_TYPE; thisNode->val.n_val.n_type = type; return thisNode;}ASTNode* mk_native_func_1( ParserState* in_state, int type, ASTNode* a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = NATIVE_FUNC_TYPE; thisNode->val.n_val.n_type = type; thisNode->val.n_val.n_param_1 = a; return thisNode;}ASTNode* mk_native_func_2( ParserState* in_state, int type, ASTNode* a, ASTNode* b) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = NATIVE_FUNC_TYPE; thisNode->val.n_val.n_type = type; thisNode->val.n_val.n_param_1 = a; thisNode->val.n_val.n_param_2 = b; return thisNode;}ASTNode* mk_native_func_3( ParserState* in_state, int type, ASTNode* a, ASTNode* b, ASTNode* c) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = NATIVE_FUNC_TYPE; thisNode->val.n_val.n_type = type; thisNode->val.n_val.n_param_1 = a; thisNode->val.n_val.n_param_2 = b; thisNode->val.n_val.n_param_3 = c; return thisNode;}ASTNode* mk_string(ParserState* in_state, string* a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = STRING_TYPE; // Should create a NEW string, for correct semantics thisNode->val.s_val = in_state->get_var_table()->new_stack_string(); if (thisNode->val.s_val == NULL) { return in_state->empty_token(); } *(thisNode->val.s_val) = *a; return thisNode;}ASTNode* mk_print(ParserState* in_state, ASTNode* a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = PRINT_TYPE; thisNode->val.u_val.u_node = a; return thisNode; }ASTNode* mk_println(ParserState* in_state, ASTNode* a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = PRINTLN_TYPE; thisNode->val.u_val.u_node = a; return thisNode; }ASTNode* mk_function_declare(ParserState* in_state, ASTType in_type, string* in_type_name, ASTType in_array_type, string* func_name, ASTNode* param_list, ASTNode* statements_node) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = FUNC_DECLARE_TYPE; thisNode->val.f_val.f_type = in_type; thisNode->val.f_val.f_type_name = in_type_name; thisNode->val.f_val.f_array_type = in_array_type; thisNode->val.f_val.f_name = func_name; thisNode->val.f_val.f_formal_param = param_list; thisNode->val.f_val.f_node = statements_node; return thisNode;}ASTNode* mk_function_call(ParserState* in_state, ASTType in_type, const string* in_type_name, ASTType in_array_type, const ASTNode* formal_param_list, ASTNode* actual_param_list, ASTNode* statements_node) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = FUNC_CALL_TYPE; thisNode->val.f_val.f_type = in_type; thisNode->val.f_val.f_type_name = in_type_name; thisNode->val.f_val.f_array_type = in_array_type; thisNode->val.f_val.f_formal_param = formal_param_list; thisNode->val.f_val.f_actual_param = actual_param_list; thisNode->val.f_val.f_node = statements_node; return thisNode;}ASTNode* mk_function_ref( ParserState* in_state, string* func_name, ASTNode* a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = FUNC_REF_TYPE; thisNode->val.f_val.f_name = func_name; thisNode->val.f_val.f_actual_param = a; return thisNode;} ASTNode* mk_unary(ParserState* in_state, int op, ASTNode* a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = UNARY_TYPE; thisNode->val.u_val.u_type = op; thisNode->val.u_val.u_node = a; return thisNode;}ASTNode* mk_arith(ParserState* in_state, int op, ASTNode* a, ASTNode* b) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = BIN_TYPE; thisNode->val.b_val.b_type = op; thisNode->val.b_val.b_left_node = a; thisNode->val.b_val.b_right_node = b; //thisNode->val.b_val.b_parser = in_state; return thisNode;}ASTNode* mk_adt_assign(ParserState* in_state, ASTNode* a, ASTNode* b) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = ASSIGN_ADT_TYPE; thisNode->val.b_val.b_left_node = a; thisNode->val.b_val.b_right_node = b; //thisNode->val.b_val.b_parser = in_state; return thisNode;}ASTNode* mk_selection( ParserState* in_state, ASTNode* eval, ASTNode* a, ASTNode* b) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = IF_TYPE; thisNode->val.if_val.if_eval = eval; thisNode->val.if_val.if_left_node = a; thisNode->val.if_val.if_right_node = b; return thisNode;}ASTNode* mk_loop( ParserState* in_state, ASTNode* eval, ASTNode* a) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) { return in_state->empty_token(); } thisNode->type = LOOP_TYPE; thisNode->val.l_val.l_eval = eval; thisNode->val.l_val.l_node = a; return thisNode;}extern ASTNode* mk_for_loop(ParserState* in_state, ASTNode* a, ASTNode* b, ASTNode* c, ASTNode* d) { ASTNode* thisNode = in_state->get_var_table()->new_stack_ast(); if (thisNode == NULL) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -