From acea1c6ee6c61a43a29beee351ffd420bec51c79 Mon Sep 17 00:00:00 2001 From: Valk Richard Li <48872266+ValKmjolnir@users.noreply.github.com> Date: Thu, 17 Oct 2019 21:39:13 +0800 Subject: [PATCH] Update --- version1.1/nasal_parser.h | 414 +++++++++++++------------------------- 1 file changed, 140 insertions(+), 274 deletions(-) diff --git a/version1.1/nasal_parser.h b/version1.1/nasal_parser.h index ce4bcfa..f53c55a 100644 --- a/version1.1/nasal_parser.h +++ b/version1.1/nasal_parser.h @@ -96,10 +96,8 @@ class nasal_parser } void parse_main_work(); void in_curve_calc_expr(); - void number_begin_expr(); - void string_begin_expr(); - void identifier_begin_expr(); - void id_call_expr(); + void calculation_expr(); + void identifier_call_expr(); void call_list_expr(); void call_function_expr(); void call_hash_expr(); @@ -135,12 +133,13 @@ void nasal_parser::return_expr() get_token(); switch(this_token.type) { - case __number:number_begin_expr();break; - case __string:string_begin_expr();break; - case __id:identifier_begin_expr();break; + case __number: + case __string: + case __id:parse.push(this_token);calculation_expr();break; case __func:function_generate_expr();break; case __left_bracket:list_generate_expr();break; case __left_brace:hash_generate_expr();break; + case __left_curve:in_curve_calc_expr();break; case __semi:parse.push(this_token);break; default: ++error; @@ -166,9 +165,9 @@ void nasal_parser::statements_block() switch(this_token.type) { case __var:definition_expr();check_semi_at_end();break; - case __id:identifier_begin_expr();check_semi_at_end();break; - case __number:number_begin_expr();check_semi_at_end();break; - case __string:string_begin_expr();check_semi_at_end();break; + case __id: + case __number: + case __string:parse.push(this_token);calculation_expr();check_semi_at_end();break; case __if:parse.push(this_token);if_else_expr();break; case __left_curve: t=this_token; @@ -185,9 +184,8 @@ void nasal_parser::statements_block() } check_semi_at_end(); break; - case __add_operator: case __sub_operator: - case __nor_operator:one_operator_expr();break; + case __nor_operator:parse.push(this_token);calculation_expr();break; case __while: case __for: case __foreach: @@ -267,9 +265,9 @@ void nasal_parser::list_generate_expr() { switch(this_token.type) { - case __number:number_begin_expr();break; - case __string:string_begin_expr();break; - case __id:identifier_begin_expr();break; + case __number: + case __string: + case __id:parse.push(this_token);calculation_expr();break; case __left_bracket:list_generate_expr();break; case __left_brace:hash_generate_expr();break; case __left_curve:in_curve_calc_expr();break; @@ -298,18 +296,14 @@ void nasal_parser::hash_generate_expr() get_token(); while(this_token.type!=__right_brace) { - switch(this_token.type) + if(this_token.type!=__id) { - //case __number:number_begin_expr();break; - //case __string:string_begin_expr();break; - case __id:identifier_begin_expr();break; - default: - ++error; - std::cout<<">>[Error] line "<>[Error] line "<>[Error] line "<>[Error] line "<>[Error] line "<>[Error] line "<>[Error] line "<>[Error] line "<>[Error] line "<>[Error] line "<>[Error] line "<