From e2cefa124ef556ac3c97596416528f3988d66902 Mon Sep 17 00:00:00 2001 From: Valk Richard Li <48872266+ValKmjolnir@users.noreply.github.com> Date: Wed, 15 Jul 2020 02:15:38 -0700 Subject: [PATCH] update --- version3.0/nasal.ebnf | 2 +- version3.0/nasal_parse.h | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/version3.0/nasal.ebnf b/version3.0/nasal.ebnf index d7a3d4a..f504974 100644 --- a/version3.0/nasal.ebnf +++ b/version3.0/nasal.ebnf @@ -17,7 +17,7 @@ hash ::= '{' {hashmember ','} '}' ; hashmember::= - id ':' calculation + id|string ':' calculation ; function::= func argument_list expressions diff --git a/version3.0/nasal_parse.h b/version3.0/nasal_parse.h index d31bf32..3fd16f7 100644 --- a/version3.0/nasal_parse.h +++ b/version3.0/nasal_parse.h @@ -205,16 +205,20 @@ bool nasal_parse::check_special_call() // special call means like this: // function_name(a:1,b:2,c:3); int check_ptr=ptr+1; - int curve_cnt=1; + int curve_cnt=1,bracket_cnt=0,brace_cnt=0; bool ret=false; while(check_ptr=tok_list_size) break; + if(tok_list[ptr].type==tok_comma) ++ptr; + else if(tok_list[ptr].type!=tok_comma && tok_list[ptr].type!=tok_right_brace) { error_info(error_line,lack_comma); ++error; @@ -329,14 +334,14 @@ nasal_ast nasal_parse::hash_gen() nasal_ast nasal_parse::hash_member_gen() { nasal_ast node; - if(ptr>=tok_list_size || tok_list[ptr].type!=tok_identifier) + if(ptr>=tok_list_size || (tok_list[ptr].type!=tok_identifier && tok_list[ptr].type!=tok_string)) { error_info(error_line,lack_identifier); return node; } node.set_line(tok_list[ptr].line); node.set_type(ast_hashmember); - node.add_child(id_gen()); + node.add_child(tok_list[ptr].type==tok_identifier?id_gen():string_gen()); ++ptr; if(ptr>=tok_list_size || tok_list[ptr].type!=tok_colon) {