From ef6632aa3f8372aaca71c301ebeb6888c2d7b4ed Mon Sep 17 00:00:00 2001 From: Valk Richard Li <48872266+ValKmjolnir@users.noreply.github.com> Date: Thu, 23 Jan 2020 15:53:01 +0800 Subject: [PATCH] update --- version2.0/nasal_enum.h | 66 ++++++++++++++++++---------------------- version2.0/nasal_parse.h | 9 ++---- 2 files changed, 32 insertions(+), 43 deletions(-) diff --git a/version2.0/nasal_enum.h b/version2.0/nasal_enum.h index 9e9176e..3c5698a 100644 --- a/version2.0/nasal_enum.h +++ b/version2.0/nasal_enum.h @@ -153,27 +153,29 @@ void print_parse_token(int type) enum parse_error_type { - parse_unknown_error, // unknown error + parse_unknown_error=0, // unknown error error_token_in_main, // when a token should not be the begin of a statement in main error_token_in_block, // when a token should not be the begin of a statement in block lack_semi, lack_id, + lack_left_curve, // lack left curve + lack_right_curve, // lack right curve definition_lack_id, // lack identifier definition_lack_equal, // lack '=' when not getting ';' - definition_wrong_type, // need identifier but get number or string multi_definition_need_curve, // lack right curve when generating 'var (id,id,id)' + multi_assignment_need_curve, // lack right curve when generating (scalar,scalar)=(scalar,scalar) multi_assignment_need_equal, // lack '=' when generating (scalar,scalar)=(scalar,scalar) + error_begin_token_of_scalar, // in scalar_generate() - lack_left_curve, // lack left curve - lack_right_curve, // lack right curve + parameter_lack_part, // parameter lack a ')' or identifier parameter_lack_curve, // parameter lack a ',' or ')' - special_call_lack_id, - special_call_lack_colon, + special_call_func_lack_id, + special_call_func_lack_colon, call_func_lack_comma, call_hash_lack_id, // lack identifier when calling a hash call_vector_lack_bracket, // lack ']' when calling a vector @@ -193,7 +195,7 @@ void print_parse_error(int error_type,int line,int error_token_type=__stack_end) switch(error_type) { case parse_unknown_error: - std::cout< parse_token_stream; std::stack checked_tokens; token this_token; @@ -278,8 +277,6 @@ bool nasal_parse::check_var_in_curve() void nasal_parse::main_generate() { - statement_generate_state=stat_null; - // initialize state error=0; // initialize error root.set_clear(); @@ -814,7 +811,7 @@ abstract_syntax_tree nasal_parse::scalar_generate() if(this_token.type!=__id) { ++error; - print_parse_error(special_call_lack_id,this_token.line,this_token.type); + print_parse_error(special_call_func_lack_id,this_token.line,this_token.type); break; } id_node.set_node_line(this_token.line); @@ -825,7 +822,7 @@ abstract_syntax_tree nasal_parse::scalar_generate() if(this_token.type!=__colon) { ++error; - print_parse_error(special_call_lack_colon,this_token.line,this_token.type); + print_parse_error(special_call_func_lack_colon,this_token.line,this_token.type); break; } special_para_node.add_children(calculation()); @@ -1247,7 +1244,7 @@ abstract_syntax_tree nasal_parse::definition() { this->push_token(); ++error; - print_parse_error(definition_wrong_type,this_token.line,this_token.type); + print_parse_error(definition_lack_id,this_token.line,this_token.type); break; } else