瀏覽代碼

修复了函数调用的bug:解析器错误和执行器错误。解析错误为:status表达模糊,系统自动把','匹配为hide_list。执行器错误为当使用tmp_s的name_value时候,进入第二阶段,根据tmp_s的base_var获取值的时候会出错。在svar使用下,因为调用base_value需要to_object而需要out_var(或称为:old_var_list),故特别设计get_value函数

SongZihuan 5 年之前
父節點
當前提交
2ea88552d0
共有 4 個文件被更改,包括 136 次插入70 次删除
  1. 78 13
      inter/interpreter.c
  2. 1 0
      inter/interpreter.h
  3. 6 6
      paser/paser.h
  4. 51 51
      paser/syntax.c

+ 78 - 13
inter/interpreter.c

@@ -119,7 +119,6 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
             break;
             break;
         }
         }
         case call:
         case call:
-            puts("tag 11");
             return_value = call_back(the_statement, the_var);
             return_value = call_back(the_statement, the_var);
             break;
             break;
         case while_cycle:
         case while_cycle:
@@ -281,9 +280,11 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
             break;
             break;
         }
         }
         case base_svar:{    // because the var tmp, we should ues a {} to make a block[name space] for the tmp var;
         case base_svar:{    // because the var tmp, we should ues a {} to make a block[name space] for the tmp var;
+            puts("[tag 2]");
             int from = 0;
             int from = 0;
             if(the_statement->code.base_svar.from == NULL){
             if(the_statement->code.base_svar.from == NULL){
                 from = 0;
                 from = 0;
+                puts("[tag 3]");
             }
             }
             else{
             else{
                 GWARF_result tmp_result, tmp_object = traverse(the_statement->code.base_svar.from, the_var, false);
                 GWARF_result tmp_result, tmp_object = traverse(the_statement->code.base_svar.from, the_var, false);
@@ -417,10 +418,8 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
 
 
             func_value.value.type = FUNC_value;
             func_value.value.type = FUNC_value;
             func_value.value.value.func_value = func_tmp;
             func_value.value.value.func_value = func_tmp;
-            puts("tag 11");
             printf("the_statement->code.def.var = %d\n", the_statement->code.def.var->type);
             printf("the_statement->code.def.var = %d\n", the_statement->code.def.var->type);
             assignment_statement_core(the_statement->code.def.var, the_var, the_login_var, func_value, true);  // 注册函数到指定的位置
             assignment_statement_core(the_statement->code.def.var, the_var, the_login_var, func_value, true);  // 注册函数到指定的位置
-            puts("tag 12");
             // 无返回值
             // 无返回值
             break;
             break;
         }
         }
@@ -813,6 +812,56 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
     return return_value;
     return return_value;
 }
 }
 
 
+GWARF_result get_value(statement *the_statement, var_list *the_var, var_list *out_var){  // 为tmp_x和tmp_s注册函数所用  其中out_var是外部函数
+    GWARF_result return_value;
+    return_value.u = statement_end;  // 正常设置[正常语句结束]
+    return_value.value.type = NULL_value;  // 默认设置
+    return_value.value.value.int_value = 0;  // 默认设置
+    switch (the_statement->type)
+    {
+        case base_var:{    // because the var tmp, we should ues a {} to make a block[name space] for the tmp var;
+            int from = 0;
+            var *tmp = find_var(the_var, from, (the_statement->code).base_var.var_name);
+            if(tmp == NULL){  // 输出name error[共两处会输出]
+                char *tmp = malloc((size_t)( 21 + strlen(the_statement->code.base_var.var_name) ));
+                sprintf(tmp, "name not found [%s]\n", the_statement->code.base_var.var_name);
+                return_value = to_error(tmp, "NameException", out_var);
+            }
+            else{
+                return_value.value = tmp->value;  // get_var
+            }
+            break;
+        }
+        case base_svar:{    // because the var tmp, we should ues a {} to make a block[name space] for the tmp var;
+            int from = 0;
+            GWARF_result eq_object = traverse(the_statement->code.base_svar.var, out_var, false);
+            if(is_error(&eq_object)){
+                return eq_object;
+            }
+            else if(is_space(&eq_object)){
+                return eq_object;
+            }
+            char *str = to_str_dict(eq_object.value, out_var).value.string;
+            printf("str = %s\n", str);
+
+            var *tmp = find_var(the_var, from, str);
+            if(tmp == NULL){  // 输出name error[共两处会输出]
+                char *tmp = malloc((size_t)( 21 + strlen(str) ));
+                sprintf(tmp, "name not found [%s]\n", str);
+                return_value = to_error(tmp, "NameException", out_var);
+            }
+            else{
+                return_value.value = tmp->value;  // get_var
+            }
+            break;
+        }
+        default:
+            puts("default");
+            break;
+    }
+    return return_value;
+}
+
 // -----------------include func
 // -----------------include func
 GWARF_result include_func(statement *the_statement, var_list *the_var){
 GWARF_result include_func(statement *the_statement, var_list *the_var){
     GWARF_result return_value;
     GWARF_result return_value;
@@ -1921,7 +1970,7 @@ GWARF_result login_var(var_list *the_var, var_list *old_var_list, parameter *tmp
         }
         }
         if(assignment_type == 0){  // 对位赋值
         if(assignment_type == 0){  // 对位赋值
             if ((tmp_x == NULL)&&(tmp_s != NULL)){  // 参数过多
             if ((tmp_x == NULL)&&(tmp_s != NULL)){  // 参数过多
-                printf("Warning!!!\n");
+                printf("Warning!!![2]\n");
                 break;
                 break;
             }
             }
             else if ((tmp_x != NULL)&&(tmp_s == NULL)){  // 使用默认值
             else if ((tmp_x != NULL)&&(tmp_s == NULL)){  // 使用默认值
@@ -1950,7 +1999,7 @@ GWARF_result login_var(var_list *the_var, var_list *old_var_list, parameter *tmp
                         tmp_x = tmp_x->next;  // get the next to iter
                         tmp_x = tmp_x->next;  // get the next to iter
                     }
                     }
                     else{
                     else{
-                        printf("warning!!!\n");
+                        printf("warning!!![3]\n");
                         break;
                         break;
                     }
                     }
 
 
@@ -2006,7 +2055,8 @@ GWARF_result login_var(var_list *the_var, var_list *old_var_list, parameter *tmp
                         tmp_x->next = NULL;  // 理论上没有下一个
                         tmp_x->next = NULL;  // 理论上没有下一个
                     }
                     }
                     else{
                     else{
-                        GWARF_result tmp_x_var = traverse(tmp_x->u.var, tmp_var, false);  // 使用tmp_x->u.var在tmp_var中获取变量的值
+                        printf("[tag 12221] %d\n",tmp_x->u.var->type);
+                        GWARF_result tmp_x_var = traverse_get_value(tmp_x->u.var, tmp_var, old_var_list);  // 使用tmp_x->u.var在tmp_var中获取变量的值
                         if((!is_error(&tmp_x_var)) && (!is_space(&tmp_x_var))){  // 如果找到了,就赋值
                         if((!is_error(&tmp_x_var)) && (!is_space(&tmp_x_var))){  // 如果找到了,就赋值
                             GWARF_result tmp = assignment_statement(tmp_x->u.var, old_var_list, the_var, tmp_x_var);
                             GWARF_result tmp = assignment_statement(tmp_x->u.var, old_var_list, the_var, tmp_x_var);
                             if(tmp.base_name != NULL){  // 删除变量
                             if(tmp.base_name != NULL){  // 删除变量
@@ -2018,10 +2068,11 @@ GWARF_result login_var(var_list *the_var, var_list *old_var_list, parameter *tmp
                             if(is_error(&tmp) || is_space(&tmp)){
                             if(is_error(&tmp) || is_space(&tmp)){
                                 return tmp;
                                 return tmp;
                             }
                             }
-                            puts("tag 4");
                             assignment_statement(tmp_x->u.var, old_var_list, the_var, tmp);
                             assignment_statement(tmp_x->u.var, old_var_list, the_var, tmp);
+                            puts("FFWWWWWW");
                         }
                         }
                         else{
                         else{
+                            puts("[1]warning!!!");
                             break;
                             break;
                         }
                         }
                     }
                     }
@@ -2031,6 +2082,7 @@ GWARF_result login_var(var_list *the_var, var_list *old_var_list, parameter *tmp
             }
             }
         }
         }
 
 
+        // 默认处理程序
         GWARF_result tmp = traverse(tmp_s->u.value, old_var_list, false);  // 不需要取__value__
         GWARF_result tmp = traverse(tmp_s->u.value, old_var_list, false);  // 不需要取__value__
         if(is_error(&tmp)){
         if(is_error(&tmp)){
             return tmp;
             return tmp;
@@ -2077,7 +2129,6 @@ GWARF_result login_var(var_list *the_var, var_list *old_var_list, parameter *tmp
             // 放入list中
             // 放入list中
             GWARF_result dict_tmp;
             GWARF_result dict_tmp;
             dict_tmp.value = to_object(parameter_to_dict(tmp_s, old_var_list), old_var_list);  // 把所有name_value变成dict
             dict_tmp.value = to_object(parameter_to_dict(tmp_s, old_var_list), old_var_list);  // 把所有name_value变成dict
-            puts("tag 5");
             assignment_statement(tmp_x->u.var, old_var_list, the_var, dict_tmp);
             assignment_statement(tmp_x->u.var, old_var_list, the_var, dict_tmp);
             assignment_type = 1;  // 进入根据实参赋值模式
             assignment_type = 1;  // 进入根据实参赋值模式
             tmp_x = NULL;  // 已经到最后一个了
             tmp_x = NULL;  // 已经到最后一个了
@@ -2089,7 +2140,6 @@ GWARF_result login_var(var_list *the_var, var_list *old_var_list, parameter *tmp
                 break;
                 break;
             }
             }
             assignment_type = 1;
             assignment_type = 1;
-            puts("tag 6");
             assignment_statement(tmp_s->u.var, old_var_list, tmp_var, tmp);  // 先赋值到tmp_var上
             assignment_statement(tmp_s->u.var, old_var_list, tmp_var, tmp);  // 先赋值到tmp_var上
             tmp_s = tmp_s->next;
             tmp_s = tmp_s->next;
         }
         }
@@ -2115,7 +2165,6 @@ GWARF_result login_var(var_list *the_var, var_list *old_var_list, parameter *tmp
             // 放入list中
             // 放入list中
             GWARF_result list_tmp;
             GWARF_result list_tmp;
             list_tmp.value = to_object(parameter_to_list(tmp_s, old_var_list), old_var_list);  // 把所有only_value变成list
             list_tmp.value = to_object(parameter_to_list(tmp_s, old_var_list), old_var_list);  // 把所有only_value变成list
-            puts("tag 7");
             assignment_statement(tmp_x->u.var, old_var_list, the_var, list_tmp);
             assignment_statement(tmp_x->u.var, old_var_list, the_var, list_tmp);
             assignment_type = 1;  // 进入根据实参赋值模式
             assignment_type = 1;  // 进入根据实参赋值模式
             tmp_x = tmp_x->next;
             tmp_x = tmp_x->next;
@@ -2131,7 +2180,7 @@ GWARF_result login_var(var_list *the_var, var_list *old_var_list, parameter *tmp
             }
             }
         }
         }
         else if(assignment_type == 0){
         else if(assignment_type == 0){
-            puts("tag 8");
+            puts("[tag 1]");
             assignment_statement(tmp_x->u.var, old_var_list, the_var, tmp);
             assignment_statement(tmp_x->u.var, old_var_list, the_var, tmp);
             tmp_x = tmp_x->next;  // get the next to iter
             tmp_x = tmp_x->next;  // get the next to iter
             tmp_s = tmp_s->next;
             tmp_s = tmp_s->next;
@@ -2160,12 +2209,11 @@ GWARF_result call_back_core(GWARF_result get, var_list *the_var, parameter *tmp_
             if(func_->is_class){
             if(func_->is_class){
                 if(get.father != NULL){
                 if(get.father != NULL){
                     father.value = *(get.father);
                     father.value = *(get.father);
-                    puts("tag 9");
                     assignment_statement_core(tmp_x->u.var, old_var_list, the_var, father, true);
                     assignment_statement_core(tmp_x->u.var, old_var_list, the_var, father, true);
                     tmp_x = tmp_x->next;  // get the next to iter
                     tmp_x = tmp_x->next;  // get the next to iter
                 }
                 }
                 else{
                 else{
-                    printf("Warning!!!\n");
+                    printf("Warning!!![1]\n");
                     // TODO:: 抛出错误
                     // TODO:: 抛出错误
                 }
                 }
             }
             }
@@ -3749,6 +3797,23 @@ GWARF_result traverse_global(statement *the_statement, var_list *the_var){  // t
     return result;
     return result;
 }
 }
 
 
+GWARF_result traverse_get_value(statement *the_statement, var_list *the_var, var_list *out_var){  // traverse the statement[not break、broken、and others] but error
+    statement *tmp = the_statement;
+    GWARF_result result;
+    while(1){
+        if(tmp == NULL){
+            break;  // off
+        }
+        result = get_value(tmp, the_var, out_var);
+        if(result.u == error){  // Name Error错误
+            printf("%s", result.error_info);
+            break;
+        }
+        tmp = tmp->next;
+    }
+    return result;
+}
+
 inter *get_inter(){
 inter *get_inter(){
     inter *tmp;
     inter *tmp;
     tmp = malloc(sizeof(inter));  // get an address for base var
     tmp = malloc(sizeof(inter));  // get an address for base var

+ 1 - 0
inter/interpreter.h

@@ -694,6 +694,7 @@ statement *pack_call_name(char *, statement *);
 
 
 GWARF_result traverse(statement *, var_list *, bool);
 GWARF_result traverse(statement *, var_list *, bool);
 GWARF_result traverse_global(statement *, var_list *);
 GWARF_result traverse_global(statement *, var_list *);
+GWARF_result traverse_get_value(statement *, var_list *, var_list *);
 
 
 inter *get_inter();
 inter *get_inter();
 void login(var_list *the_var);
 void login(var_list *the_var);

+ 6 - 6
paser/paser.h

@@ -1,17 +1,17 @@
 #ifndef MEM_INCLUDE
 #ifndef MEM_INCLUDE
 #define MEM_INCLUDE
 #define MEM_INCLUDE
 
 
-#define reset_status(status) {status.is_parameter=false,status.is_func=false,status.is_list=false,status.is_dict=false,status.is_left=true,status.is_peq=false,status.is_for=false,status.dict_to_enter=false,status.ignore_enter=false,status.is_slice=false;}
+#define reset_status(status) {status.not_match_eq=false,status.not_match_tuple=false,status.not_match_call=false,status.match_list=false,status.match_dict=false,status.is_left=true,status.is_peq=false,status.is_for=false,status.dict_to_enter=false,status.ignore_enter=false,status.is_slice=false;}
 
 
 FILE *debug = NULL, *status_log = NULL, *token_log = NULL, *token_info = NULL;
 FILE *debug = NULL, *status_log = NULL, *token_log = NULL, *token_info = NULL;
 
 
 typedef struct p_status
 typedef struct p_status
 {
 {
-    bool is_parameter;  // parameter模式不匹配 = 
-    bool is_func;  // func模式不匹配 ()
-    bool is_call;
-    bool is_list;  // 不匹配参数的POW和name_value
-    bool is_dict;  // 不匹配参数的MUL和非only_value选项以及用:取代=
+    bool not_match_eq;  // parameter模式不匹配 = 
+    bool not_match_tuple;  // func模式不匹配 ()
+    bool not_match_call;
+    bool match_list;  // 不匹配参数的POW和name_value
+    bool match_dict;  // 不匹配参数的MUL和非only_value选项以及用:取代=
     bool is_left;  // 是否为最左边的公式
     bool is_left;  // 是否为最左边的公式
     bool is_peq;  // 正在使用解包赋值
     bool is_peq;  // 正在使用解包赋值
     bool is_for;  // for循环,用于排除COMMA的使用[top_exp]
     bool is_for;  // for循环,用于排除COMMA的使用[top_exp]

+ 51 - 51
paser/syntax.c

@@ -454,9 +454,9 @@ void def_class(p_status *status, token_node *list){
     if(def_t.type == DEF_PASER || def_t.type == CLASS_PASER){
     if(def_t.type == DEF_PASER || def_t.type == CLASS_PASER){
         p_status new_status;
         p_status new_status;
         new_status = *status;
         new_status = *status;
-        new_status.is_func = true;
+        new_status.not_match_tuple = true;
+        new_status.not_match_call = true;
         get_right_token(&new_status,list,top_exp,name_t);  // 避免了top_exp把括号捕捉为call_back,不过,可以使用list设置status参数从而让call_back不捕捉[未实现]
         get_right_token(&new_status,list,top_exp,name_t);  // 避免了top_exp把括号捕捉为call_back,不过,可以使用list设置status参数从而让call_back不捕捉[未实现]
-        new_status.is_func = false;
         if(name_t.type != NON_top_exp){  // 不是表达式
         if(name_t.type != NON_top_exp){  // 不是表达式
             paser_error("Don't get 'top_exp'");
             paser_error("Don't get 'top_exp'");
         }
         }
@@ -472,6 +472,7 @@ void def_class(p_status *status, token_node *list){
             if(parameter_t.type != NON_parameter){
             if(parameter_t.type != NON_parameter){
                 paser_error("Don't get formal_parameter");
                 paser_error("Don't get formal_parameter");
             }
             }
+            printf("parameter_t = %d\n", parameter_t.data.parameter_list->u.var->type);
             get_pop_token(status, list, rb_t);
             get_pop_token(status, list, rb_t);
             printf("rb_t.type = %d\n", rb_t.type);
             printf("rb_t.type = %d\n", rb_t.type);
             if(rb_t.type != RB_PASER){
             if(rb_t.type != RB_PASER){
@@ -525,14 +526,14 @@ void formal_parameter(p_status *status, token_node *list){  // 因试分解
         get_pop_token(status, list, comma);
         get_pop_token(status, list, comma);
         if(comma.type == (status->is_slice ? COLON_PASER : COMMA_PASER)){
         if(comma.type == (status->is_slice ? COLON_PASER : COMMA_PASER)){
             get_pop_token(status, list, before);
             get_pop_token(status, list, before);
-            if(before.type == MUL_PASER && !status->is_peq){
-                if(status->is_dict){
+            if(before.type == MUL_PASER){
+                if(status->match_dict){
                     paser_error("dict shouldn't get '*'");
                     paser_error("dict shouldn't get '*'");
                 }
                 }
                 mode = put_args;
                 mode = put_args;
             }
             }
-            else if(before.type == POW_PASER && !status->is_peq){
-                if(status->is_list){
+            else if(before.type == POW_PASER){
+                if(status->match_list){
                     paser_error("list shouldn't get '*'");
                     paser_error("list shouldn't get '*'");
                 }
                 }
                 mode = put_kwargs;
                 mode = put_kwargs;
@@ -543,9 +544,9 @@ void formal_parameter(p_status *status, token_node *list){  // 因试分解
             }
             }
             p_status new_status;
             p_status new_status;
             new_status = *status;
             new_status = *status;
-            new_status.is_parameter = true;
+            new_status.not_match_eq = true;
+            new_status.not_match_tuple = true;
             get_right_token(&new_status, list, top_exp, next);
             get_right_token(&new_status, list, top_exp, next);
-            new_status.is_parameter = false;
             if(next.type != NON_top_exp){  // 结尾分号
             if(next.type != NON_top_exp){  // 结尾分号
                 back_one_token(list, left);  // 分号忽略
                 back_one_token(list, left);  // 分号忽略
                 back_again(list, next);
                 back_again(list, next);
@@ -555,15 +556,16 @@ void formal_parameter(p_status *status, token_node *list){  // 因试分解
             new_token = left;
             new_token = left;
             parameter *tmp = NULL;
             parameter *tmp = NULL;
             get_pop_token(status, list, eq);
             get_pop_token(status, list, eq);
-            if(eq.type == ((status->is_dict || status->is_peq) ? COLON_PASER : EQ_PASER)){  // name_value模式
-                if(status->is_list){
+            printf("eq.type = %d   %d\n", eq.type, status->is_peq);
+            if(eq.type == ((status->match_dict || status->is_peq) ? COLON_PASER : EQ_PASER)){  // name_value模式
+                if(status->match_list){
                     paser_error("list shouldn't get '='");
                     paser_error("list shouldn't get '='");
                 }
                 }
                 p_status new_status;
                 p_status new_status;
                 new_status = *status;
                 new_status = *status;
-                if(status->is_peq) new_status.is_parameter = true;
+                if(!status->match_dict) new_status.not_match_eq = true;  // dict使用了 : 代替 = 
+                new_status.not_match_tuple = true;
                 get_right_token(&new_status, list, top_exp, value_token);
                 get_right_token(&new_status, list, top_exp, value_token);
-                if(status->is_peq) new_status.is_parameter = false;
                 if(value_token.type != NON_top_exp){
                 if(value_token.type != NON_top_exp){
                     paser_error("Don't get a top_exp");
                     paser_error("Don't get a top_exp");
                     return;
                     return;
@@ -573,7 +575,7 @@ void formal_parameter(p_status *status, token_node *list){  // 因试分解
                 tmp->u.value = value_token.data.statement_value;
                 tmp->u.value = value_token.data.statement_value;
             }
             }
             else{
             else{
-                if(status->is_dict){
+                if(status->match_dict){
                     paser_error("dict should get ':'[1]");
                     paser_error("dict should get ':'[1]");
                 }
                 }
                 back_again(list,eq);  // 回退[如果使用back_one_token则会导致add_node在EQ的后面]
                 back_again(list,eq);  // 回退[如果使用back_one_token则会导致add_node在EQ的后面]
@@ -597,9 +599,9 @@ void formal_parameter(p_status *status, token_node *list){  // 因试分解
         fprintf(status_log, "[info][grammar]  (formal_parameter)back one token to (top_exp)[**/*]\n");
         fprintf(status_log, "[info][grammar]  (formal_parameter)back one token to (top_exp)[**/*]\n");
         p_status new_status;
         p_status new_status;
         new_status = *status;
         new_status = *status;
-        new_status.is_parameter = true;
+        new_status.not_match_eq = true;
+        new_status.not_match_tuple = true;
         get_right_token(&new_status, list, top_exp, next);  // 不需要back_one_token
         get_right_token(&new_status, list, top_exp, next);  // 不需要back_one_token
-        new_status.is_parameter = false;
         if(next.type != NON_top_exp){
         if(next.type != NON_top_exp){
             back_one_token(list, next);  // 往回[不匹配类型]
             back_one_token(list, next);  // 往回[不匹配类型]
             return;
             return;
@@ -609,13 +611,13 @@ void formal_parameter(p_status *status, token_node *list){  // 因试分解
         new_token.data.parameter_list = make_parameter_value(next.data.statement_value);
         new_token.data.parameter_list = make_parameter_value(next.data.statement_value);
         new_token.data.parameter_list->u.var = new_token.data.parameter_list->u.value;
         new_token.data.parameter_list->u.var = new_token.data.parameter_list->u.value;
         if(left.type == POW_PASER){
         if(left.type == POW_PASER){
-            if(status->is_list){
+            if(status->match_list){
                 paser_error("list shouldn't get '**'");
                 paser_error("list shouldn't get '**'");
             }
             }
             new_token.data.parameter_list->type = put_kwargs;
             new_token.data.parameter_list->type = put_kwargs;
         }
         }
         else{
         else{
-            if(status->is_dict){
+            if(status->match_dict){
                 paser_error("dict shouldn't get '*'");
                 paser_error("dict shouldn't get '*'");
             }
             }
             new_token.data.parameter_list->type = put_args;
             new_token.data.parameter_list->type = put_args;
@@ -626,13 +628,11 @@ void formal_parameter(p_status *status, token_node *list){  // 因试分解
     else{  // 模式1
     else{  // 模式1
         fprintf(status_log, "[info][grammar]  (formal_parameter)back one token to (top_exp)\n");
         fprintf(status_log, "[info][grammar]  (formal_parameter)back one token to (top_exp)\n");
         back_one_token(list, left);
         back_one_token(list, left);
-        printf("left.type = %d\n", left.type);
         p_status new_status;
         p_status new_status;
         new_status = *status;
         new_status = *status;
-        new_status.is_parameter = true;
-        printf("status->is_parameter = %d\n", new_status.is_parameter);
+        new_status.not_match_eq = true;
+        new_status.not_match_tuple = true;
         get_base_token(&new_status, list, top_exp, next);
         get_base_token(&new_status, list, top_exp, next);
-        new_status.is_parameter = false;
         if(next.type != NON_top_exp){
         if(next.type != NON_top_exp){
             back_one_token(list, next);  // 往回[不匹配类型]
             back_one_token(list, next);  // 往回[不匹配类型]
             return;
             return;
@@ -643,16 +643,15 @@ void formal_parameter(p_status *status, token_node *list){  // 因试分解
 
 
         parameter *tmp = NULL;
         parameter *tmp = NULL;
         get_pop_token(status, list, eq);
         get_pop_token(status, list, eq);
-        printf("eq.type = %d\n", eq.type);
-        if(eq.type == ((status->is_dict || status->is_peq) ? COLON_PASER : EQ_PASER)){  // name_value模式
-            if(status->is_list){
+        if(eq.type == ((status->match_dict || status->is_peq) ? COLON_PASER : EQ_PASER)){  // name_value模式
+            if(status->match_list){
                 paser_error("list shouldn't get '='");
                 paser_error("list shouldn't get '='");
             }
             }
             p_status new_status;
             p_status new_status;
             new_status = *status;
             new_status = *status;
-            if(status->is_peq) new_status.is_parameter = true;
+            new_status.not_match_tuple = true;
+            if(!status->match_dict) new_status.not_match_eq = true;
             get_right_token(&new_status, list, top_exp, value_token);
             get_right_token(&new_status, list, top_exp, value_token);
-            if(status->is_peq) new_status.is_parameter = false;
             if(value_token.type != NON_top_exp){
             if(value_token.type != NON_top_exp){
                 paser_error("Don't get a top_exp");
                 paser_error("Don't get a top_exp");
                 return;
                 return;
@@ -662,7 +661,7 @@ void formal_parameter(p_status *status, token_node *list){  // 因试分解
             new_token.data.parameter_list->type = name_value;
             new_token.data.parameter_list->type = name_value;
         }
         }
         else{
         else{
-            if(status->is_dict){
+            if(status->match_dict){
                 paser_error("dict should get ':'[2]");
                 paser_error("dict should get ':'[2]");
             }
             }
             back_again(list,eq);  // 回退[如果使用back_one_token则会导致add_node在EQ的后面]
             back_again(list,eq);  // 回退[如果使用back_one_token则会导致add_node在EQ的后面]
@@ -910,7 +909,7 @@ void var_ctrl_(p_status *status, token_node *list){
         {
         {
             p_status new_status;
             p_status new_status;
             new_status = *status;
             new_status = *status;
-            new_status.is_list = true;  // 不捕捉,
+            new_status.not_match_tuple = true;  // 不捕捉,
             get_right_token(&new_status, list, top_exp, var);  // 取得base_var
             get_right_token(&new_status, list, top_exp, var);  // 取得base_var
             if(var.type != NON_top_exp && var.data.statement_value->type != base_var){
             if(var.type != NON_top_exp && var.data.statement_value->type != base_var){
                 paser_error("Don't get var");
                 paser_error("Don't get var");
@@ -1182,7 +1181,7 @@ void eq_number(p_status *status, token_node *list){  // 因试分解
         fprintf(status_log, "[info][grammar]  (eq_number)reduce right\n");
         fprintf(status_log, "[info][grammar]  (eq_number)reduce right\n");
         get_pop_token(status, list, symbol);
         get_pop_token(status, list, symbol);
 
 
-        if((symbol.type == EQ_PASER && !status->is_parameter) || symbol.type == AADD_PASER || symbol.type == ASUB_PASER || symbol.type == AMUL_PASER || symbol.type == ADIV_PASER|| 
+        if((symbol.type == EQ_PASER && !status->not_match_eq) || symbol.type == AADD_PASER || symbol.type == ASUB_PASER || symbol.type == AMUL_PASER || symbol.type == ADIV_PASER|| 
             symbol.type == AMOD_PASER || symbol.type == AINTDIV_PASER || symbol.type == APOW_PASER){  // 模式2/3
             symbol.type == AMOD_PASER || symbol.type == AINTDIV_PASER || symbol.type == APOW_PASER){  // 模式2/3
             get_right_token(status, list, hide_list, right);  // 回调右边
             get_right_token(status, list, hide_list, right);  // 回调右边
             if(right.type != NON_hide_list){
             if(right.type != NON_hide_list){
@@ -1237,34 +1236,33 @@ void eq_number(p_status *status, token_node *list){  // 因试分解
         }
         }
     }
     }
     else{  // 模式1
     else{  // 模式1
-        // is_left将会在这里消亡为false
-        fprintf(status_log, "[info][grammar]  (bool_or)back one token to (bool_and)\n");
+        fprintf(status_log, "[info][grammar]  (eq_number)back one token to (hide_list)\n");
         back_one_token(list, left);
         back_one_token(list, left);
         get_base_token(status, list, hide_list, new_token);  // hide_list会处理is_left
         get_base_token(status, list, hide_list, new_token);  // hide_list会处理is_left
         if(new_token.type != NON_hide_list){
         if(new_token.type != NON_hide_list){
             back_one_token(list, new_token);  // 往回[不匹配类型]
             back_one_token(list, new_token);  // 往回[不匹配类型]
             return;
             return;
         }
         }
-        if(status->is_left){  // 必须是在最左边
-            p_status new_status;
-            new_status = *status;
-            new_status.is_left = false;  // 设置为false,随后一切top_exp行为均不执行这一步骤
+        if(status->is_left){  // 必须是在最左边 -> 进入解包赋值
+            status->is_left = false;
+            
             token comma, p_left, eq_t, p_right, tmp;
             token comma, p_left, eq_t, p_right, tmp;
             parameter *the_right;
             parameter *the_right;
-            get_pop_token(&new_status, list,comma);
+            get_pop_token(status, list,comma);
             if(comma.type == COMMA_PASER){  // a,b = [1,2]的赋值方式
             if(comma.type == COMMA_PASER){  // a,b = [1,2]的赋值方式
                 back_one_token(list, new_token);  // 先把new_token和comma一起回退
                 back_one_token(list, new_token);  // 先把new_token和comma一起回退
                 back_again(list, comma);
                 back_again(list, comma);
                 
                 
+                p_status new_status;
+                new_status = *status;
                 new_status.is_peq = true;
                 new_status.is_peq = true;
                 get_base_token(&new_status,list,formal_parameter,p_left);
                 get_base_token(&new_status,list,formal_parameter,p_left);
                 if(p_left.type != NON_parameter){
                 if(p_left.type != NON_parameter){
                     paser_error("Dont get formal_parameter");
                     paser_error("Dont get formal_parameter");
                 }
                 }
-                new_status.is_peq = false;
                 
                 
                 get_pop_token(status, list, eq_t);
                 get_pop_token(status, list, eq_t);
-                if(eq_t.type != EQ_PASER){  // 变成hide_list
+                if(eq_t.type != EQ_PASER || status->not_match_eq){  // 变成hide_list
                     back_again(list, eq_t);
                     back_again(list, eq_t);
                     statement *code_tmp =  make_statement();
                     statement *code_tmp =  make_statement();
                     code_tmp->type = base_tuple;
                     code_tmp->type = base_tuple;
@@ -1287,7 +1285,7 @@ void eq_number(p_status *status, token_node *list){  // 因试分解
                 }
                 }
                 else{
                 else{
                     back_again(list, tmp);
                     back_again(list, tmp);
-                    get_right_token(status,list,hide_list,p_right);
+                    get_right_token(status,list,hide_list,p_right);  // 把后面匹配为list
                     if(p_right.type != NON_hide_list){
                     if(p_right.type != NON_hide_list){
                         paser_error("Don't get hide_list");
                         paser_error("Don't get hide_list");
                     }
                     }
@@ -1321,14 +1319,14 @@ void hide_list(p_status *status, token_node *list){
     p_status new_status;
     p_status new_status;
     new_status = *status;
     new_status = *status;
 
 
-    new_status.is_left = false;
+    new_status.is_left = false;  // 接下去的运算 is_left均为false
     get_base_token(&new_status,list,lambda_,exp);
     get_base_token(&new_status,list,lambda_,exp);
     new_status.is_left = old_is_left;
     new_status.is_left = old_is_left;
     if(exp.type != NON_lambda){
     if(exp.type != NON_lambda){
         back_one_token(list, exp);
         back_one_token(list, exp);
         return;
         return;
     }
     }
-    if(status->is_func + status->is_left + status->is_parameter + status->is_for + status->is_list + status->is_dict + status->is_call == 0){  // 几个会用到逗号的选项先排除
+    if(!status->not_match_tuple && !status->is_left && !status->is_for){  // 几个会用到逗号的选项先排除
         token comma;
         token comma;
         get_pop_token(status,list,comma);
         get_pop_token(status,list,comma);
         if(comma.type == COMMA_PASER){
         if(comma.type == COMMA_PASER){
@@ -1337,9 +1335,8 @@ void hide_list(p_status *status, token_node *list){
             back_again(list, comma);
             back_again(list, comma);
             p_status new_status;
             p_status new_status;
             new_status = *status;
             new_status = *status;
-            new_status.is_list = true;
+            new_status.not_match_tuple = true;
             get_base_token(&new_status, list, formal_parameter, new_token);
             get_base_token(&new_status, list, formal_parameter, new_token);
-            new_status.is_list = false;
             if(new_token.type != NON_parameter){
             if(new_token.type != NON_parameter){
                 paser_error("Don't get formal_parameter");
                 paser_error("Don't get formal_parameter");
             }
             }
@@ -2299,7 +2296,7 @@ void call_down(p_status *status, token_node *list){  // 因试分解
         if(lb_t.type == LI_PASER){
         if(lb_t.type == LI_PASER){
             p_status new_status;
             p_status new_status;
             new_status = *status;
             new_status = *status;
-            new_status.is_list = true;
+            new_status.not_match_tuple = true;
             get_right_token(&new_status, list, top_exp, parameter_t);  // 回调右边
             get_right_token(&new_status, list, top_exp, parameter_t);  // 回调右边
             if(parameter_t.type != NON_top_exp){
             if(parameter_t.type != NON_top_exp){
                 paser_error("Don't get a top_exp");
                 paser_error("Don't get a top_exp");
@@ -2389,13 +2386,14 @@ void call_back_(p_status *status, token_node *list){  // 因试分解
         fprintf(status_log, "[info][grammar]  (call_back_)reduce right\n");
         fprintf(status_log, "[info][grammar]  (call_back_)reduce right\n");
         get_pop_token(status, list, symbol);
         get_pop_token(status, list, symbol);
 
 
-        if(symbol.type == LB_PASER && !status->is_func){
+        if(symbol.type == LB_PASER && !status->not_match_call){
             get_pop_token(status, list, rb_t);
             get_pop_token(status, list, rb_t);
             if(rb_t.type != RB_PASER){  // 带参数
             if(rb_t.type != RB_PASER){  // 带参数
                 back_again(list, rb_t);
                 back_again(list, rb_t);
                 p_status new_status = *status;  // 继承file_p等值
                 p_status new_status = *status;  // 继承file_p等值
                 reset_status(new_status);  // 不会影响 *staus
                 reset_status(new_status);  // 不会影响 *staus
-                new_status.is_call = true;  // 括号内忽略回车
+                new_status.not_match_tuple = true;
+                new_status.is_left = false;
                 get_right_token(&new_status,list,formal_parameter,parameter_t);
                 get_right_token(&new_status,list,formal_parameter,parameter_t);
                 if(parameter_t.type != NON_parameter){
                 if(parameter_t.type != NON_parameter){
                     paser_error("Don't get formal_parameter");
                     paser_error("Don't get formal_parameter");
@@ -2519,7 +2517,8 @@ void element(p_status *status, token_node *list){  // 数字归约
         token exp_token, rb, tmp_var;
         token exp_token, rb, tmp_var;
         p_status new_status;
         p_status new_status;
         new_status = *status;
         new_status = *status;
-        new_status.is_list = true;  // 防止top_exp收走逗号
+        new_status.match_list = true;  // 防止top_exp收走逗号
+        new_status.not_match_tuple = true;
         new_status.ignore_enter = true;  // 括号内忽略回车
         new_status.ignore_enter = true;  // 括号内忽略回车
         get_right_token(&new_status, list, top_exp, exp_token);
         get_right_token(&new_status, list, top_exp, exp_token);
         if(exp_token.type == RI_PASER){  //可以认定为空list
         if(exp_token.type == RI_PASER){  //可以认定为空list
@@ -2624,9 +2623,9 @@ void list_(p_status *status, token_node *list){  // 数字归约
     if(gett.type == LI_PASER){  // var类型
     if(gett.type == LI_PASER){  // var类型
         p_status new_status;
         p_status new_status;
         new_status = *status;
         new_status = *status;
-        new_status.is_list = true;
+        new_status.match_list = true;
+        new_status.not_match_tuple = true;
         get_right_token(&new_status,list,formal_parameter,list_core);
         get_right_token(&new_status,list,formal_parameter,list_core);
-        new_status.is_list = false;
         if(list_core.type == RI_PASER){  // 空列表
         if(list_core.type == RI_PASER){  // 空列表
             base = NULL;
             base = NULL;
             goto make_list;
             goto make_list;
@@ -2676,9 +2675,10 @@ void dict_(p_status *status, token_node *list){  // 数字归约
     if(gett.type == LP_PASER){  // var类型
     if(gett.type == LP_PASER){  // var类型
         p_status new_status;
         p_status new_status;
         new_status = *status;
         new_status = *status;
-        new_status.is_dict = true;
+        new_status.match_dict = true;
+        new_status.not_match_tuple = true;
         get_right_token(&new_status,list,formal_parameter,dict_core);
         get_right_token(&new_status,list,formal_parameter,dict_core);
-        new_status.is_dict = false;
+
         if(dict_core.type == RP_PASER){  // 空列表
         if(dict_core.type == RP_PASER){  // 空列表
             base = NULL;
             base = NULL;
             goto make_dict;
             goto make_dict;