浏览代码

list赋值和切片的语法

SongZihuan 5 年之前
父节点
当前提交
1bda10e61c
共有 10 个文件被更改,包括 718 次插入512 次删除
  1. 二进制
      gwarf
  2. 60 7
      inter/cfunc.c
  3. 92 20
      inter/interpreter.c
  4. 18 11
      inter/interpreter.h
  5. 3 3
      inter/parameter.c
  6. 1 0
      paser/gwarf_lex.l
  7. 36 3
      paser/gwarf_yacc.y
  8. 217 210
      paser/lex.yy.c
  9. 287 256
      paser/y.tab.c
  10. 4 2
      paser/y.tab.h

二进制
gwarf


+ 60 - 7
inter/cfunc.c

@@ -79,6 +79,13 @@ GWARF_value to_object(GWARF_value value, var_list *the_var){  // 把GWARF_value
             func_result.value = tmp->value;
             func_result.value = tmp->value;
         }
         }
     }
     }
+    else if(value.type == LIST_value){
+        tmp = find_var(the_var, 0, "list");
+        if(tmp != NULL){
+            func_result.value = tmp->value;
+            puts("list");
+        }
+    }
     else{
     else{
         return value;
         return value;
     }
     }
@@ -1141,8 +1148,8 @@ class_object *list_login_official(var_list *the_var, GWARF_result (*paser)(func
     puts("----stop set class----");
     puts("----stop set class----");
 
 
     // 注册函数
     // 注册函数
-    int a[][2] = {{2,1},{23,1},{24,1},{25,1}};
-    char *name[] = {"__init__", "__len__", "__down__", "__set__"};  //  __len__是获取长度,__down__是获取下值,__set__是设置值,__slice__是切片
+    int a[][2] = {{2,1},{23,1},{24,1},{25,1},{26,1}};
+    char *name[] = {"__init__", "__len__", "__down__", "__set__", "__slice__"};  //  __len__是获取长度,__down__是获取下值,__set__是设置值,__slice__是切片
 
 
     int lenth = sizeof(a)/sizeof(a[0]);
     int lenth = sizeof(a)/sizeof(a[0]);
     for(int i = 0;i < lenth;i+=1){
     for(int i = 0;i < lenth;i+=1){
@@ -1180,6 +1187,7 @@ GWARF_result list_official_func(func *the_func, parameter *tmp_s, var_list *the_
                 return_value.u = statement_end;  // __init__没有return
                 return_value.u = statement_end;  // __init__没有return
             }
             }
             else{
             else{
+                puts("list.__init__");
                 GWARF_result tmp, tmp_result = traverse(tmp_s->u.value, out_var, false);
                 GWARF_result tmp, tmp_result = traverse(tmp_s->u.value, out_var, false);
                 if(tmp_result.u == name_no_found){  // Name Error错误
                 if(tmp_result.u == name_no_found){  // Name Error错误
                     return_value = tmp_result;
                     return_value = tmp_result;
@@ -1209,7 +1217,6 @@ GWARF_result list_official_func(func *the_func, parameter *tmp_s, var_list *the_
         }
         }
         case __down__func:{  // return index
         case __down__func:{  // return index
             var *tmp = find_var(login_var, 0, "value");
             var *tmp = find_var(login_var, 0, "value");
-            int len = (int)(sizeof(tmp->value.value.list_value->list_value) / sizeof(GWARF_value));
             if(tmp != NULL){
             if(tmp != NULL){
                 GWARF_result get_value, tmp_result = traverse(tmp_s->u.value, out_var, false);
                 GWARF_result get_value, tmp_result = traverse(tmp_s->u.value, out_var, false);
                 if(tmp_result.u == name_no_found){  // Name Error错误
                 if(tmp_result.u == name_no_found){  // Name Error错误
@@ -1223,18 +1230,62 @@ GWARF_result list_official_func(func *the_func, parameter *tmp_s, var_list *the_
                 GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
                 GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
                 get_value = get__value__(&base_the_var, the_var);
                 get_value = get__value__(&base_the_var, the_var);
                 get_value.value = to_int(get_value.value, out_var);
                 get_value.value = to_int(get_value.value, out_var);
-
+                // puts("NONE");
                 return_value.value = tmp->value.value.list_value->list_value[get_value.value.value.int_value];
                 return_value.value = tmp->value.value.list_value->list_value[get_value.value.value.int_value];
             }
             }
             else{
             else{
-                return_value.value.type = INT_value;
+                return_value.value.type = NULL_value;
                 return_value.value.value.int_value = 0;
                 return_value.value.value.int_value = 0;
             }
             }
             break;
             break;
         }
         }
-        case __set__func:{  // return index
+        case __slice__func:{  // return index
             var *tmp = find_var(login_var, 0, "value");
             var *tmp = find_var(login_var, 0, "value");
             int len = (int)(sizeof(tmp->value.value.list_value->list_value) / sizeof(GWARF_value));
             int len = (int)(sizeof(tmp->value.value.list_value->list_value) / sizeof(GWARF_value));
+            int start, end;
+            if(tmp != NULL){
+                GWARF_result start_result = traverse(tmp_s->u.value, out_var, false), end_result;
+                if(start_result.u == name_no_found){  // Name Error错误
+                    return_value = start_result;
+                    goto return_result;
+                }
+                else if(is_space(&start_result)){
+                    return_value = start_result;
+                    goto return_result;
+                }
+
+                start = to_int(get__value__(&(start_result.value), the_var).value, out_var).value.int_value;
+                tmp_s = tmp_s->next;
+                if(tmp_s != NULL){
+                    end_result = traverse(tmp_s->u.value, out_var, false);
+                    if(end_result.u == name_no_found){  // Name Error错误
+                        return_value = end_result;
+                        goto return_result;
+                    }
+                    else if(is_space(&end_result)){
+                        return_value = end_result;
+                        goto return_result;
+                    }
+                    end = to_int(get__value__(&(end_result.value), the_var).value, out_var).value.int_value;
+                }
+                else{
+                    end = len;
+                }
+
+                return_value.value.type = LIST_value;
+                return_value.value.value.list_value = malloc(sizeof(the_list));  // 申请list的空间
+                return_value.value.value.list_value->list_value = malloc((size_t)((end - start) * sizeof(GWARF_value)));
+                memcpy(return_value.value.value.list_value->list_value, (tmp->value.value.list_value->list_value + start), (size_t)((end - start) * sizeof(GWARF_value)));
+                return_value.value.value.list_value->index = (end - len) - 1;
+            }
+            else{
+                return_value.value.type = NULL_value;
+                return_value.value.value.int_value = 0;
+            }
+            break;
+        }
+        case __set__func:{  // return index
+            var *tmp = find_var(login_var, 0, "value");
             if(tmp != NULL){
             if(tmp != NULL){
                 GWARF_result get_value, tmp_result = traverse(tmp_s->u.value, out_var, false);
                 GWARF_result get_value, tmp_result = traverse(tmp_s->u.value, out_var, false);
                 if(tmp_result.u == name_no_found){  // Name Error错误
                 if(tmp_result.u == name_no_found){  // Name Error错误
@@ -1264,7 +1315,7 @@ GWARF_result list_official_func(func *the_func, parameter *tmp_s, var_list *the_
                 tmp->value.value.list_value->index += 1;
                 tmp->value.value.list_value->index += 1;
             }
             }
             else{
             else{
-                return_value.value.type = INT_value;
+                return_value.value.type = NULL_value;
                 return_value.value.value.int_value = 0;
                 return_value.value.value.int_value = 0;
             }
             }
             break;
             break;
@@ -1272,6 +1323,8 @@ GWARF_result list_official_func(func *the_func, parameter *tmp_s, var_list *the_
         default:
         default:
             break;
             break;
     }
     }
+    if(the_func->official_func == __slice__func){
+    }
     return_result: return return_value;
     return_result: return return_value;
 }
 }
 
 

+ 92 - 20
inter/interpreter.c

@@ -146,6 +146,43 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
         case base_list:  // get value[所有字面量均为这个表达式]
         case base_list:  // get value[所有字面量均为这个表达式]
             return_value.value = parameter_to_list(the_statement->code.base_list.value, the_var);  // code
             return_value.value = parameter_to_list(the_statement->code.base_list.value, the_var);  // code
             break;
             break;
+        case slice:{  // get value[所有字面量均为这个表达式]
+            GWARF_result tmp_result = traverse((the_statement->code).slice.base_var, the_var, false), get;  // 把a[1:2:3]的a取出来
+            if(is_error(&tmp_result)){  // Name Error错误
+                return_value = tmp_result;
+                goto the_break_slice;
+            }
+            else if(is_space(&tmp_result)){
+                return_value = tmp_result;
+                goto the_break_slice;
+            }
+
+            GWARF_value base_the_var = tmp_result.value;
+
+            if(base_the_var.type == CLASS_value){  // is class so that can use "."
+                var *tmp = find_var(base_the_var.value.class_value->the_var, 0, "__slice__");
+                if(tmp != NULL){
+                    get.value = tmp->value;
+                    get.father = &base_the_var;  // 设置father
+                    return_value = call_back_core(get, the_var, the_statement->code.slice.value);
+                    goto the_break_slice;
+                }
+            }
+            else if(base_the_var.type == OBJECT_value){
+                var *tmp = find_var(base_the_var.value.object_value->the_var, 0, "__slice__");
+                if(tmp != NULL){
+                    get.value = tmp->value;
+                    get.father = &base_the_var;  // 设置father
+                    return_value = call_back_core(get, the_var, the_statement->code.slice.value);
+                    goto the_break_slice;
+                }
+            }
+
+            the_break_slice: 
+            return_value.value = to_object(return_value.value, the_var);
+            // printf("return_value.value.type = %d\n", return_value.value);
+            break;
+        }
         case base_var:{    // because the var tmp, we should ues a {} to make a block[name space] for the tmp var;
         case base_var:{    // because the var tmp, we should ues a {} to make a block[name space] for the tmp var;
             int from = 0;
             int from = 0;
             if(the_statement->code.base_var.from == NULL){
             if(the_statement->code.base_var.from == NULL){
@@ -232,19 +269,21 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
 
 
             return_value.father = malloc(sizeof(return_value.father));  // 记录father的值
             return_value.father = malloc(sizeof(return_value.father));  // 记录father的值
             *(return_value.father) = base_the_var;
             *(return_value.father) = base_the_var;
+
+            the_break: 
             return_value.value = to_object(return_value.value, the_var);
             return_value.value = to_object(return_value.value, the_var);
-            the_break: break;
+            break;
         }
         }
         case down:{
         case down:{
             GWARF_result tmp_result = traverse((the_statement->code).down.base_var, the_var, false), get;
             GWARF_result tmp_result = traverse((the_statement->code).down.base_var, the_var, false), get;
             if(is_error(&tmp_result)){  // Name Error错误
             if(is_error(&tmp_result)){  // Name Error错误
                 // puts("STOP:: Name No Found!");
                 // puts("STOP:: Name No Found!");
                 return_value = tmp_result;
                 return_value = tmp_result;
-                goto the_break;
+                goto the_break_down;
             }
             }
             else if(is_space(&tmp_result)){
             else if(is_space(&tmp_result)){
                 return_value = tmp_result;
                 return_value = tmp_result;
-                goto the_break;
+                goto the_break_down;
             }
             }
 
 
             GWARF_value base_the_var = tmp_result.value;
             GWARF_value base_the_var = tmp_result.value;
@@ -266,25 +305,15 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
                     get.value = tmp->value;
                     get.value = tmp->value;
                     get.father = &base_the_var;  // 设置father
                     get.father = &base_the_var;  // 设置father
                     return_value = call_back_core(get, the_var, pack_value_parameter(child_value.value));
                     return_value = call_back_core(get, the_var, pack_value_parameter(child_value.value));
+                    puts("DOWN");
                     goto the_break_down;
                     goto the_break_down;
                 }
                 }
             }
             }
-            else{  // 其他类型
-                goto the_break_down;
-            }
-
-            if(is_error(&return_value)){  // Name Error错误
-                // puts("STOP:: Name No Found!");
-                goto the_break_down;
-            }
-            else if(is_space(&return_value)){
-                goto the_break_down;
-            }
 
 
-            return_value.father = malloc(sizeof(return_value.father));  // 记录father的值
-            *(return_value.father) = base_the_var;
-            return_value.value = to_object(return_value.value, the_var);
-            the_break_down: break;
+            the_break_down: 
+            return_value.value = to_object(return_value.value, the_var);  // call_back_core 返回值是object
+            printf("down = return_value.value.type = %d\n", return_value.value.type);
+            break;
         }
         }
         case def:{
         case def:{
             GWARF_result func_value;
             GWARF_result func_value;
@@ -1087,6 +1116,7 @@ GWARF_result operation_func(statement *the_statement, var_list *the_var, var_lis
     int func_type = the_statement->code.operation.type;
     int func_type = the_statement->code.operation.type;
     if((func_type != ASSIGMENT_func) && (func_type != NEGATIVE_func)){  // don't run because I don't need[if it's and func ,it will be run twice]
     if((func_type != ASSIGMENT_func) && (func_type != NEGATIVE_func)){  // don't run because I don't need[if it's and func ,it will be run twice]
         left_result = traverse((*the_statement).code.operation.left_exp, the_var, false);
         left_result = traverse((*the_statement).code.operation.left_exp, the_var, false);
+        printf("left_result.value.type = %d\n",left_result.value.type);
         if(is_error(&left_result)){  // Name Error错误
         if(is_error(&left_result)){  // Name Error错误
             // puts("STOP:: Name No Found!");
             // puts("STOP:: Name No Found!");
             return left_result;
             return left_result;
@@ -1152,7 +1182,6 @@ GWARF_result operation_func(statement *the_statement, var_list *the_var, var_lis
                 value = assigment_func(left, right_result, login_var, from);
                 value = assigment_func(left, right_result, login_var, from);
             }
             }
             else if((the_statement->code.operation.left_exp)->type == point){  // 通过point赋值
             else if((the_statement->code.operation.left_exp)->type == point){  // 通过point赋值
-                printf("(the_statement->code).point.base_var = %u\n", (the_statement->code.operation.left_exp)->code.point.base_var);
                 GWARF_result tmp_result = traverse((the_statement->code.operation.left_exp)->code.point.base_var, the_var, false);  // 不用取value
                 GWARF_result tmp_result = traverse((the_statement->code.operation.left_exp)->code.point.base_var, the_var, false);  // 不用取value
                 if(is_error(&tmp_result)){  // Name Error错误
                 if(is_error(&tmp_result)){  // Name Error错误
                     // puts("STOP:: Name No Found!");
                     // puts("STOP:: Name No Found!");
@@ -1194,6 +1223,44 @@ GWARF_result operation_func(statement *the_statement, var_list *the_var, var_lis
                     goto the_else;
                     goto the_else;
                 }
                 }
             }
             }
+            else if((the_statement->code.operation.left_exp)->type == down){  // 通过down赋值
+                GWARF_result tmp_result = traverse((the_statement->code.operation.left_exp)->code.down.base_var, the_var, false), get;  // 不用取value
+                if(is_error(&tmp_result)){  // Name Error错误
+                    // puts("STOP:: Name No Found!");
+                    return tmp_result;
+                }
+                else if(is_space(&tmp_result)){
+                    return tmp_result;
+                }
+                GWARF_value base_the_var = tmp_result.value;  // 不用取value
+                if(base_the_var.type == CLASS_value){  // is class so that can use "."
+                    GWARF_result child_value = traverse((the_statement->code.operation.left_exp)->code.down.child_var, the_var, false);  // 作为参数
+                    var *tmp = find_var(base_the_var.value.class_value->the_var, 0, "__set__");
+                    if(tmp != NULL){
+                        get.value = tmp->value;
+                        get.father = &base_the_var;  // 设置father
+                        parameter *tmp = pack_value_parameter(child_value.value);
+                        tmp->next = pack_value_parameter(right_result.value);
+                        value = call_back_core(get, the_var, tmp);
+                        goto the_else;
+                    }
+                }
+                else if(base_the_var.type == OBJECT_value){
+                    GWARF_result child_value = traverse((the_statement->code.operation.left_exp)->code.down.child_var, the_var, false);  // 作为参数
+                    var *tmp = find_var(base_the_var.value.object_value->the_var, 0, "__set__");
+                    if(tmp != NULL){
+                        get.value = tmp->value;
+                        get.father = &base_the_var;  // 设置father
+                        parameter *tmp = pack_value_parameter(child_value.value);
+                        tmp->next = pack_value_parameter(right_result.value);
+                        value = call_back_core(get, the_var, tmp);
+                        goto the_else;
+                    }
+                }
+                else{
+                    goto the_else;
+                }
+            }
             else{ 
             else{ 
                 the_else: puts("Bad Assigment");
                 the_else: puts("Bad Assigment");
             }
             }
@@ -1502,6 +1569,8 @@ GWARF_result call_back_core(GWARF_result get, var_list *the_var, parameter *tmp_
 
 
 // ---------  ADD
 // ---------  ADD
 GWARF_result add_func(GWARF_result left_result, GWARF_result right_result, var_list *the_var){  // the func for add and call from read_statement_list
 GWARF_result add_func(GWARF_result left_result, GWARF_result right_result, var_list *the_var){  // the func for add and call from read_statement_list
+    puts("come to add");
+    // printf("left_result.value.type = %d\n", left_result.value.type);
     GWARF_result return_value, get;  // the result by call read_statement_list with left and right; value is the result for add
     GWARF_result return_value, get;  // the result by call read_statement_list with left and right; value is the result for add
     if(left_result.value.type == OBJECT_value){  // 调用左add方法
     if(left_result.value.type == OBJECT_value){  // 调用左add方法
         GWARF_result get;
         GWARF_result get;
@@ -1513,6 +1582,7 @@ GWARF_result add_func(GWARF_result left_result, GWARF_result right_result, var_l
             get.value = tmp->value;
             get.value = tmp->value;
             get.father = &base_the_var;  // 设置father
             get.father = &base_the_var;  // 设置father
             return_value = call_back_core(get, the_var, pack_value_parameter(right_result.value));
             return_value = call_back_core(get, the_var, pack_value_parameter(right_result.value));
+            printf("return_value.value.type = %d\n", return_value.value.type);
             goto return_back;
             goto return_back;
         }
         }
         // goto next if
         // goto next if
@@ -2271,7 +2341,9 @@ GWARF_result traverse(statement *the_statement, var_list *the_var, bool new){  /
         if(!lock){
         if(!lock){
             result = result2;
             result = result2;
         }
         }
-
+        else{
+            puts("local");
+        }
         tmp = tmp->next;
         tmp = tmp->next;
     }
     }
     if(new){  // need to make new var
     if(new){  // need to make new var

+ 18 - 11
inter/interpreter.h

@@ -1,7 +1,7 @@
 #ifndef _INTERPRETER_H
 #ifndef _INTERPRETER_H
 #define _INTERPRETER_H
 #define _INTERPRETER_H
 
 
-#define malloc(size) safe_malloc(size)
+// #define malloc(size) safe_malloc(size)
 #define free(p) p=safe_free(p)
 #define free(p) p=safe_free(p)
 #define realloc(p,size) safe_realloc(p,size)
 #define realloc(p,size) safe_realloc(p,size)
 #define memcpy(p1,p2,size) safe_memcpy(p1,p2,size)
 #define memcpy(p1,p2,size) safe_memcpy(p1,p2,size)
@@ -13,15 +13,15 @@
 
 
 // the type of data(GWARF_value)
 // the type of data(GWARF_value)
 typedef enum{
 typedef enum{
-    NUMBER_value = 1,  // [只允许系统使用]
-    INT_value,  // INT 类型[只允许系统使用]
-    BOOL_value,  // bool : true or false [只允许系统使用]
-    STRING_value,  // char * [只允许系统使用]
-    NULL_value,  // 无值类型
-    FUNC_value,  // 函数
-    CLASS_value,  // 对象
-    OBJECT_value,  // 实例
-    LIST_value,  // 列表类型
+    NUMBER_value = 1,  // [只允许系统使用] [1]
+    INT_value,  // INT 类型[只允许系统使用] [2]
+    BOOL_value,  // bool : true or false [只允许系统使用] [3]
+    STRING_value,  // char * [只允许系统使用] [4]
+    NULL_value,  // 无值类型 [5]
+    FUNC_value,  // 函数 [6]
+    CLASS_value,  // 对象 [7]
+    OBJECT_value,  // 实例 [8]
+    LIST_value,  // 列表类型 [9]
 } GWARF_value_type;
 } GWARF_value_type;
 
 
 // all value is GWARF_value
 // all value is GWARF_value
@@ -86,6 +86,7 @@ typedef struct statement{
         call,  // func()
         call,  // func()
         point,  // a.b  注:返回变量同时返回the_var链表[func 用于回调]
         point,  // a.b  注:返回变量同时返回the_var链表[func 用于回调]
         down,  // a[b]  注:返回变量同时返回the_var链表[func 用于回调]
         down,  // a[b]  注:返回变量同时返回the_var链表[func 用于回调]
+        slice,
         return_code,
         return_code,
         set_class,  // class aaa; b = aaa() is ```call```
         set_class,  // class aaa; b = aaa() is ```call```
     } type;  // the statement type
     } type;  // the statement type
@@ -150,9 +151,14 @@ typedef struct statement{
         } base_value;
         } base_value;
 
 
         struct{
         struct{
-            parameter *value;  // return value
+            parameter *value;  // [1,2,3,4] -> to_list
         } base_list;
         } base_list;
 
 
+        struct{
+            struct statement *base_var;  // a[1:2:3] -> a
+            parameter *value;  // a[1:2:3] -> 1 2 3
+        } slice;
+
         struct{
         struct{
             struct statement *times;  // 层数
             struct statement *times;  // 层数
         } break_cycle;
         } break_cycle;
@@ -318,6 +324,7 @@ typedef enum{
     __len__func = 23,
     __len__func = 23,
     __down__func = 24,
     __down__func = 24,
     __set__func = 25,
     __set__func = 25,
+    __slice__func = 26,
 } official_func_type;
 } official_func_type;
 
 
 typedef struct func{
 typedef struct func{

+ 3 - 3
inter/parameter.c

@@ -32,7 +32,7 @@ parameter *make_parameter_value(statement *value){
     return tmp;
     return tmp;
 }
 }
 
 
-void append_parameter_value(statement *value, parameter *parameter_base){
+void append_parameter_value(statement *value, parameter *parameter_base){  // add at last
     parameter *tmp = parameter_base;  // iter var
     parameter *tmp = parameter_base;  // iter var
     while(1){
     while(1){
         if (tmp->next == NULL){  // the last
         if (tmp->next == NULL){  // the last
@@ -44,7 +44,7 @@ void append_parameter_value(statement *value, parameter *parameter_base){
     tmp->next = new_tmp;
     tmp->next = new_tmp;
 }
 }
 
 
-parameter *add_parameter_value(statement *value, parameter *parameter_base){
+parameter *add_parameter_value(statement *value, parameter *parameter_base){  // add at first
     parameter *new_tmp = make_parameter_value(value);
     parameter *new_tmp = make_parameter_value(value);
     new_tmp->next = parameter_base;
     new_tmp->next = parameter_base;
     return new_tmp;
     return new_tmp;
@@ -54,7 +54,7 @@ parameter *pack_value_parameter(GWARF_value value){  // 把value封装成参数
     parameter *tmp;
     parameter *tmp;
     tmp = malloc(sizeof(parameter));  // get an address for base var
     tmp = malloc(sizeof(parameter));  // get an address for base var
     tmp->next = NULL;
     tmp->next = NULL;
-    statement *statement_tmp = malloc(sizeof(statement));
+    statement *statement_tmp = make_statement();
     statement_tmp->type = base_value;
     statement_tmp->type = base_value;
     statement_tmp->code.base_value.value = value;
     statement_tmp->code.base_value.value = value;
     tmp->u.value = statement_tmp;
     tmp->u.value = statement_tmp;

+ 1 - 0
paser/gwarf_lex.l

@@ -36,6 +36,7 @@
 <INITIAL>"rewent" {return REWENT;}
 <INITIAL>"rewent" {return REWENT;}
 <INITIAL>"for" {return FOR;}
 <INITIAL>"for" {return FOR;}
 <INITIAL>"," {return COMMA;}
 <INITIAL>"," {return COMMA;}
+<INITIAL>":" {return COLON;}
 <INITIAL>"default" {return DEFAULT;}
 <INITIAL>"default" {return DEFAULT;}
 <INITIAL>"global" {return GLOBAL;}
 <INITIAL>"global" {return GLOBAL;}
 <INITIAL>"nonlocal" {return NONLOCAL;}
 <INITIAL>"nonlocal" {return NONLOCAL;}

+ 36 - 3
paser/gwarf_yacc.y

@@ -22,11 +22,11 @@
 %token <double_value> NUMBER INT
 %token <double_value> NUMBER INT
 %token <string_value> STRING VAR
 %token <string_value> STRING VAR
 %token ADD SUB DIV MUL EQ LESS MORE RB LB RP LP WHILE POW LOG SQRT EQUAL MOREEQ LESSEQ NOTEQ BREAK IF ELSE ELIF BROKEN CONTINUE CONTINUED RESTART RESTARTED REGO REWENT RI LI DEFAULT FOR COMMA GLOBAL NONLOCAL INDENTA STOPN STOPF BLOCK FALSE TRUE
 %token ADD SUB DIV MUL EQ LESS MORE RB LB RP LP WHILE POW LOG SQRT EQUAL MOREEQ LESSEQ NOTEQ BREAK IF ELSE ELIF BROKEN CONTINUE CONTINUED RESTART RESTARTED REGO REWENT RI LI DEFAULT FOR COMMA GLOBAL NONLOCAL INDENTA STOPN STOPF BLOCK FALSE TRUE
-%token NULL_token DEF RETURN CLASS POINT
+%token NULL_token DEF RETURN CLASS POINT COLON
 %type <statement_value> base_value base_var_token base_var_ element second_number first_number zero_number top_exp command third_number while_block while_exp break_exp if_block if_exp broken_exp break_token broken_token continue_token continue_exp
 %type <statement_value> base_value base_var_token base_var_ element second_number first_number zero_number top_exp command third_number while_block while_exp break_exp if_block if_exp broken_exp break_token broken_token continue_token continue_exp
 %type <statement_value> continued_exp continued_token restart_exp restart_token restarted_exp restarted_token default_token for_exp for_block global_token nonlocal_token block_exp block_block call_number def_block def_exp return_exp return_token
 %type <statement_value> continued_exp continued_token restart_exp restart_token restarted_exp restarted_token default_token for_exp for_block global_token nonlocal_token block_exp block_block call_number def_block def_exp return_exp return_token
-%type <statement_value> eq_number class_block class_exp
-%type <parameter_list> formal_parameter arguments
+%type <statement_value> eq_number class_block class_exp slice_arguments_token
+%type <parameter_list> formal_parameter arguments slice_arguments
 %type <string_value> base_string
 %type <string_value> base_string
 %type <if_list_base> elif_exp
 %type <if_list_base> elif_exp
 %%
 %%
@@ -305,6 +305,14 @@ call_number
         code_tmp->code.call.parameter_list = $3;
         code_tmp->code.call.parameter_list = $3;
         $$ = code_tmp;
         $$ = code_tmp;
     }
     }
+    | element LI slice_arguments RI
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = slice;
+        code_tmp->code.slice.base_var = $1;
+        code_tmp->code.slice.value = $3;
+        $$ = code_tmp; 
+    }
     ;
     ;
 
 
 element
 element
@@ -801,6 +809,31 @@ arguments
         append_parameter_value($3, $1);
         append_parameter_value($3, $1);
         $$ = $1;
         $$ = $1;
     }
     }
+    ;
+
+slice_arguments
+    : slice_arguments_token
+    {
+        $$ = make_parameter_value($1);
+    }
+    | slice_arguments slice_arguments_token
+    {
+        append_parameter_value($2, $1);
+        $$ = $1;
+    }
+    | slice_arguments top_exp
+    {
+        append_parameter_value($2, $1);
+        $$ = $1;
+    }
+    ;
+
+slice_arguments_token
+    : top_exp COLON
+    {
+        $$ = $1;
+    }
+    ;
 
 
 block
 block
     : LP command_list RP
     : LP command_list RP

+ 217 - 210
paser/lex.yy.c

@@ -351,8 +351,8 @@ static void yynoreturn yy_fatal_error ( const char* msg  );
 	(yy_hold_char) = *yy_cp; \
 	(yy_hold_char) = *yy_cp; \
 	*yy_cp = '\0'; \
 	*yy_cp = '\0'; \
 	(yy_c_buf_p) = yy_cp;
 	(yy_c_buf_p) = yy_cp;
-#define YY_NUM_RULES 72
-#define YY_END_OF_BUFFER 73
+#define YY_NUM_RULES 73
+#define YY_END_OF_BUFFER 74
 /* This struct is not used in this scanner,
 /* This struct is not used in this scanner,
    but its presence is necessary. */
    but its presence is necessary. */
 struct yy_trans_info
 struct yy_trans_info
@@ -360,29 +360,29 @@ struct yy_trans_info
 	flex_int32_t yy_verify;
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	flex_int32_t yy_nxt;
 	};
 	};
-static const flex_int16_t yy_accept[195] =
+static const flex_int16_t yy_accept[196] =
     {   0,
     {   0,
-        0,    0,    0,    0,    0,    0,    0,    0,   73,   64,
-       61,   63,   64,   46,   44,   45,   22,   23,   40,   38,
-       17,   39,   57,   41,   59,   59,   62,   30,   32,   29,
-       60,   60,   60,   60,   42,   43,   34,   60,   60,   60,
-       60,   60,   60,   60,   60,   60,   60,   60,   60,   60,
-       24,   25,   35,   63,   67,   65,   66,   71,   70,   69,
-       68,   72,    0,    0,    0,   24,    0,   28,   33,    0,
-       59,   27,   31,   26,   60,   60,   60,   60,   60,   60,
-       60,   60,   60,   60,   60,   60,   60,   60,    5,   60,
-       60,   60,   60,   60,   60,   60,   24,    0,    0,    0,
-
-        0,   58,   60,   60,   60,   60,   60,   60,   60,   60,
-       60,   54,   60,   60,   60,   16,   60,   36,   60,   60,
-       60,   60,   60,   60,   60,   60,   60,    0,    0,    0,
-        0,    3,   60,   52,   51,   49,   60,   60,   60,   60,
-       60,   60,    6,    7,   60,   60,   60,   53,   14,   60,
-       60,   60,   37,   47,   60,    1,    2,    6,    7,   50,
-       21,    8,   60,   56,   60,   60,    0,   48,   60,   60,
-       60,   60,   60,    4,    2,    9,   60,   60,    7,   19,
-       60,   60,   55,   15,   60,   18,   60,   11,   10,   20,
-       60,   13,   12,    0
+        0,    0,    0,    0,    0,    0,    0,    0,   74,   65,
+       62,   64,   65,   47,   45,   46,   23,   24,   41,   39,
+       17,   40,   58,   42,   60,   60,   18,   63,   31,   33,
+       30,   61,   61,   61,   61,   43,   44,   35,   61,   61,
+       61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
+       61,   25,   26,   36,   64,   68,   66,   67,   72,   71,
+       70,   69,   73,    0,    0,    0,   25,    0,   29,   34,
+        0,   60,   28,   32,   27,   61,   61,   61,   61,   61,
+       61,   61,   61,   61,   61,   61,   61,   61,   61,    5,
+       61,   61,   61,   61,   61,   61,   61,   25,    0,    0,
+
+        0,    0,   59,   61,   61,   61,   61,   61,   61,   61,
+       61,   61,   55,   61,   61,   61,   16,   61,   37,   61,
+       61,   61,   61,   61,   61,   61,   61,   61,    0,    0,
+        0,    0,    3,   61,   53,   52,   50,   61,   61,   61,
+       61,   61,   61,    6,    7,   61,   61,   61,   54,   14,
+       61,   61,   61,   38,   48,   61,    1,    2,    6,    7,
+       51,   22,    8,   61,   57,   61,   61,    0,   49,   61,
+       61,   61,   61,   61,    4,    2,    9,   61,   61,    7,
+       20,   61,   61,   56,   15,   61,   19,   61,   11,   10,
+       21,   61,   13,   12,    0
 
 
     } ;
     } ;
 
 
@@ -393,15 +393,15 @@ static const YY_CHAR yy_ec[256] =
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    3,    4,    5,    6,    1,    1,    1,    7,    8,
         1,    3,    4,    5,    6,    1,    1,    1,    7,    8,
         9,   10,   11,   12,   13,   14,   15,   16,   17,   17,
         9,   10,   11,   12,   13,   14,   15,   16,   17,   17,
-       17,   17,   17,   17,   17,   17,   17,    1,   18,   19,
-       20,   21,    1,    1,   22,   22,   22,   22,   22,   23,
-       22,   22,   22,   22,   22,   24,   22,   25,   22,   22,
-       22,   22,   22,   26,   27,   22,   22,   22,   22,   22,
-       28,    1,   29,   30,   22,    1,   31,   32,   33,   34,
-
-       35,   36,   37,   38,   39,   22,   40,   41,   22,   42,
-       43,   22,   44,   45,   46,   47,   48,   22,   49,   22,
-       22,   22,   50,    1,   51,   52,    1,    1,    1,    1,
+       17,   17,   17,   17,   17,   17,   17,   18,   19,   20,
+       21,   22,    1,    1,   23,   23,   23,   23,   23,   24,
+       23,   23,   23,   23,   23,   25,   23,   26,   23,   23,
+       23,   23,   23,   27,   28,   23,   23,   23,   23,   23,
+       29,    1,   30,   31,   23,    1,   32,   33,   34,   35,
+
+       36,   37,   38,   39,   40,   23,   41,   42,   23,   43,
+       44,   23,   45,   46,   47,   48,   49,   23,   50,   23,
+       23,   23,   51,    1,   52,   53,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -418,132 +418,134 @@ static const YY_CHAR yy_ec[256] =
         1,    1,    1,    1,    1
         1,    1,    1,    1,    1
     } ;
     } ;
 
 
-static const YY_CHAR yy_meta[53] =
+static const YY_CHAR yy_meta[54] =
     {   0,
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    2,    2,    1,    1,    1,
         1,    1,    1,    1,    1,    2,    2,    1,    1,    1,
-        1,    2,    2,    2,    2,    2,    2,    1,    1,    1,
+        1,    1,    2,    2,    2,    2,    2,    2,    1,    1,
+        1,    2,    2,    2,    2,    2,    2,    2,    2,    2,
         2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
         2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
-        2,    2,    2,    2,    2,    2,    2,    2,    2,    1,
-        1,    1
+        1,    1,    1
     } ;
     } ;
 
 
-static const flex_int16_t yy_base[199] =
+static const flex_int16_t yy_base[200] =
     {   0,
     {   0,
-        0,  213,   51,   52,   54,   58,    0,    0,  215,  217,
-       64,  211,  193,  217,  217,  217,  217,  217,  202,  217,
-      217,  217,  217,  217,  217,   54,  217,  191,  190,  189,
-        0,  177,   35,  162,  217,  217,  217,   28,   31,  171,
-      164,   33,  163,  167,  159,   32,  166,  156,  154,  160,
-      195,  217,  217,  193,  217,  217,  217,  217,  217,  217,
-      217,  217,   80,  192,  153,  191,  189,  217,  217,   68,
-       72,  217,  217,  217,    0,  150,  166,  147,  140,  144,
-       44,  155,  143,  148,   51,  142,  137,  138,    0,  143,
-      137,  137,   54,  132,  128,  136,  172,  170,  169,   56,
-
-      168,   76,  124,  145,  133,  132,  133,  134,  124,  117,
-      115,  130,  124,  124,  112,    0,  125,    0,  115,  114,
-      111,  106,  104,  116,  103,  114,  107,  144,  143,  109,
-      109,  217,  108,    0,    0,    0,  102,  101,  105,   93,
-       99,   89,    0,  121,   93,   96,   83,    0,    0,   94,
-       79,   81,    0,    0,   87,  217,  119,  217,  112,    0,
-        0,    0,   77,    0,   76,   76,  107,    0,   72,   79,
-       66,   68,   62,    0,  106,    0,   59,   59,  217,    0,
-       74,   57,    0,    0,   63,    0,   55,   59,   47,    0,
-       43,    0,    0,  217,  130,  132,  134,   53
+        0,  214,   52,   53,   55,   59,    0,    0,  216,  218,
+       65,  212,  193,  218,  218,  218,  218,  218,  203,  218,
+      218,  218,  218,  218,  218,   55,  218,  218,  191,  190,
+      189,    0,  177,   35,  162,  218,  218,  218,   28,   31,
+      171,  164,   33,  163,  167,  159,   32,  166,  156,  154,
+      160,  196,  218,  218,  194,  218,  218,  218,  218,  218,
+      218,  218,  218,   81,  193,  153,  192,  190,  218,  218,
+       69,   73,  218,  218,  218,    0,  150,  166,  147,  140,
+      144,   44,  155,  143,  148,   51,  142,  137,  138,    0,
+      143,  137,  137,   55,  132,  128,  136,  173,  171,  170,
+
+       52,  169,   78,  124,  145,  133,  132,  133,  134,  124,
+      117,  115,  130,  124,  124,  112,    0,  125,    0,  115,
+      114,  111,  106,  104,  116,  103,  114,  107,  145,  144,
+      109,  109,  218,  108,    0,    0,    0,  102,  101,  105,
+       93,   99,   82,    0,  122,   93,   96,   83,    0,    0,
+       94,   79,   81,    0,    0,   87,  218,  120,  218,  113,
+        0,    0,    0,   77,    0,   76,   76,  106,    0,   72,
+       79,   66,   68,   62,    0,  107,    0,   59,   59,  218,
+        0,   74,   56,    0,    0,   64,    0,   55,   60,   47,
+        0,   43,    0,    0,  218,  132,  134,  136,   54
 
 
     } ;
     } ;
 
 
-static const flex_int16_t yy_def[199] =
+static const flex_int16_t yy_def[200] =
     {   0,
     {   0,
-      194,    1,  195,  195,  196,  196,  197,  197,  194,  194,
-      194,  194,  194,  194,  194,  194,  194,  194,  194,  194,
-      194,  194,  194,  194,  194,  194,  194,  194,  194,  194,
-      198,  198,  198,  198,  194,  194,  194,  198,  198,  198,
-      198,  198,  198,  198,  198,  198,  198,  198,  198,  198,
-      194,  194,  194,  194,  194,  194,  194,  194,  194,  194,
-      194,  194,  194,  194,  194,  194,  194,  194,  194,  194,
-      194,  194,  194,  194,  198,  198,  198,  198,  198,  198,
-      198,  198,  198,  198,  198,  198,  198,  198,  198,  198,
-      198,  198,  198,  198,  198,  198,  194,  194,  194,  194,
-
-      194,  194,  198,  198,  198,  198,  198,  198,  198,  198,
-      198,  198,  198,  198,  198,  198,  198,  198,  198,  198,
-      198,  198,  198,  198,  198,  198,  198,  194,  194,  194,
-      194,  194,  198,  198,  198,  198,  198,  198,  198,  198,
-      198,  198,  198,  198,  198,  198,  198,  198,  198,  198,
-      198,  198,  198,  198,  198,  194,  194,  194,  194,  198,
-      198,  198,  198,  198,  198,  198,  194,  198,  198,  198,
-      198,  198,  198,  198,  194,  198,  198,  198,  194,  198,
-      198,  198,  198,  198,  198,  198,  198,  198,  198,  198,
-      198,  198,  198,    0,  194,  194,  194,  194
+      195,    1,  196,  196,  197,  197,  198,  198,  195,  195,
+      195,  195,  195,  195,  195,  195,  195,  195,  195,  195,
+      195,  195,  195,  195,  195,  195,  195,  195,  195,  195,
+      195,  199,  199,  199,  199,  195,  195,  195,  199,  199,
+      199,  199,  199,  199,  199,  199,  199,  199,  199,  199,
+      199,  195,  195,  195,  195,  195,  195,  195,  195,  195,
+      195,  195,  195,  195,  195,  195,  195,  195,  195,  195,
+      195,  195,  195,  195,  195,  199,  199,  199,  199,  199,
+      199,  199,  199,  199,  199,  199,  199,  199,  199,  199,
+      199,  199,  199,  199,  199,  199,  199,  195,  195,  195,
+
+      195,  195,  195,  199,  199,  199,  199,  199,  199,  199,
+      199,  199,  199,  199,  199,  199,  199,  199,  199,  199,
+      199,  199,  199,  199,  199,  199,  199,  199,  195,  195,
+      195,  195,  195,  199,  199,  199,  199,  199,  199,  199,
+      199,  199,  199,  199,  199,  199,  199,  199,  199,  199,
+      199,  199,  199,  199,  199,  199,  195,  195,  195,  195,
+      199,  199,  199,  199,  199,  199,  199,  195,  199,  199,
+      199,  199,  199,  199,  199,  195,  199,  199,  199,  195,
+      199,  199,  199,  199,  199,  199,  199,  199,  199,  199,
+      199,  199,  199,  199,    0,  195,  195,  195,  195
 
 
     } ;
     } ;
 
 
-static const flex_int16_t yy_nxt[270] =
+static const flex_int16_t yy_nxt[272] =
     {   0,
     {   0,
        10,   11,   12,   13,   14,   15,   16,   17,   18,   19,
        10,   11,   12,   13,   14,   15,   16,   17,   18,   19,
        20,   21,   22,   23,   24,   25,   26,   27,   28,   29,
        20,   21,   22,   23,   24,   25,   26,   27,   28,   29,
-       30,   31,   32,   31,   33,   34,   31,   35,   36,   37,
-       31,   38,   39,   40,   41,   42,   43,   31,   44,   31,
-       45,   46,   31,   31,   47,   48,   49,   31,   50,   51,
-       52,   53,   56,   56,   75,   59,   57,   57,   60,   59,
-       61,   77,   60,   86,   61,   63,   64,   70,   80,   71,
-       71,   82,   81,   83,   91,   87,  193,   78,  108,   92,
-      192,   63,   64,  102,  102,   70,  109,   71,   71,  113,
-      121,  102,  102,  191,  130,  190,  114,  189,   65,  122,
-
-      123,  131,  124,  188,  187,  186,  185,  175,  184,  183,
-      182,  181,  180,   66,   65,  179,  178,  177,  176,  167,
-      175,  174,  173,  172,  171,  170,  169,  168,  167,   66,
-       55,   55,   58,   58,   62,   62,  166,  165,  164,  163,
-      162,  161,  160,  159,  158,  157,  156,  155,  154,  153,
-      152,  151,  150,  149,  148,  147,  146,  145,  144,  143,
-      142,  141,  140,  139,  138,  137,  136,  135,  134,  133,
-      132,  129,  128,   97,  127,  126,  125,  120,  119,  118,
-      117,  116,  115,  112,  111,  110,  107,  106,  105,  104,
-      103,  101,   97,  100,   99,   98,   97,   96,   95,   94,
-
-       93,   90,   89,   88,   85,   84,   79,   76,   74,   73,
-       72,   69,   68,   67,  194,   54,    9,  194,  194,  194,
-      194,  194,  194,  194,  194,  194,  194,  194,  194,  194,
-      194,  194,  194,  194,  194,  194,  194,  194,  194,  194,
-      194,  194,  194,  194,  194,  194,  194,  194,  194,  194,
-      194,  194,  194,  194,  194,  194,  194,  194,  194,  194,
-      194,  194,  194,  194,  194,  194,  194,  194,  194
+       30,   31,   32,   33,   32,   34,   35,   32,   36,   37,
+       38,   32,   39,   40,   41,   42,   43,   44,   32,   45,
+       32,   46,   47,   32,   32,   48,   49,   50,   32,   51,
+       52,   53,   54,   57,   57,   76,   60,   58,   58,   61,
+       60,   62,   78,   61,   87,   62,   64,   65,   71,   81,
+       72,   72,   83,   82,   84,   92,   88,  194,   79,  109,
+       93,  193,   64,   65,  103,  103,   71,  110,   72,   72,
+      114,  131,  122,  103,  103,  192,  191,  115,  132,  190,
+
+       66,  123,  124,  189,  125,  188,  187,  186,  176,  185,
+      184,  183,  182,  181,  180,   67,   66,  179,  178,  177,
+      168,  176,  175,  174,  173,  172,  171,  170,  169,  168,
+      167,   67,   56,   56,   59,   59,   63,   63,  166,  165,
+      164,  163,  162,  161,  160,  159,  158,  157,  156,  155,
+      154,  153,  152,  151,  150,  149,  148,  147,  146,  145,
+      144,  143,  142,  141,  140,  139,  138,  137,  136,  135,
+      134,  133,  130,  129,   98,  128,  127,  126,  121,  120,
+      119,  118,  117,  116,  113,  112,  111,  108,  107,  106,
+      105,  104,  102,   98,  101,  100,   99,   98,   97,   96,
+
+       95,   94,   91,   90,   89,   86,   85,   80,   77,   75,
+       74,   73,   70,   69,   68,  195,   55,    9,  195,  195,
+      195,  195,  195,  195,  195,  195,  195,  195,  195,  195,
+      195,  195,  195,  195,  195,  195,  195,  195,  195,  195,
+      195,  195,  195,  195,  195,  195,  195,  195,  195,  195,
+      195,  195,  195,  195,  195,  195,  195,  195,  195,  195,
+      195,  195,  195,  195,  195,  195,  195,  195,  195,  195,
+      195
     } ;
     } ;
 
 
-static const flex_int16_t yy_chk[270] =
+static const flex_int16_t yy_chk[272] =
     {   0,
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    3,    4,  198,    5,    3,    4,    5,    6,
-        5,   33,    6,   42,    6,   11,   11,   26,   38,   26,
-       26,   39,   38,   39,   46,   42,  191,   33,   81,   46,
-      189,   63,   63,   70,   70,   71,   81,   71,   71,   85,
-       93,  102,  102,  188,  100,  187,   85,  185,   11,   93,
-
-       93,  100,   93,  182,  181,  178,  177,  175,  173,  172,
-      171,  170,  169,   11,   63,  167,  166,  165,  163,  159,
-      157,  155,  152,  151,  150,  147,  146,  145,  144,   63,
-      195,  195,  196,  196,  197,  197,  142,  141,  140,  139,
-      138,  137,  133,  131,  130,  129,  128,  127,  126,  125,
-      124,  123,  122,  121,  120,  119,  117,  115,  114,  113,
-      112,  111,  110,  109,  108,  107,  106,  105,  104,  103,
-      101,   99,   98,   97,   96,   95,   94,   92,   91,   90,
-       88,   87,   86,   84,   83,   82,   80,   79,   78,   77,
-       76,   67,   66,   65,   64,   54,   51,   50,   49,   48,
-
-       47,   45,   44,   43,   41,   40,   34,   32,   30,   29,
-       28,   19,   13,   12,    9,    2,  194,  194,  194,  194,
-      194,  194,  194,  194,  194,  194,  194,  194,  194,  194,
-      194,  194,  194,  194,  194,  194,  194,  194,  194,  194,
-      194,  194,  194,  194,  194,  194,  194,  194,  194,  194,
-      194,  194,  194,  194,  194,  194,  194,  194,  194,  194,
-      194,  194,  194,  194,  194,  194,  194,  194,  194
+        1,    1,    1,    3,    4,  199,    5,    3,    4,    5,
+        6,    5,   34,    6,   43,    6,   11,   11,   26,   39,
+       26,   26,   40,   39,   40,   47,   43,  192,   34,   82,
+       47,  190,   64,   64,   71,   71,   72,   82,   72,   72,
+       86,  101,   94,  103,  103,  189,  188,   86,  101,  186,
+
+       11,   94,   94,  183,   94,  182,  179,  178,  176,  174,
+      173,  172,  171,  170,  168,   11,   64,  167,  166,  164,
+      160,  158,  156,  153,  152,  151,  148,  147,  146,  145,
+      143,   64,  196,  196,  197,  197,  198,  198,  142,  141,
+      140,  139,  138,  134,  132,  131,  130,  129,  128,  127,
+      126,  125,  124,  123,  122,  121,  120,  118,  116,  115,
+      114,  113,  112,  111,  110,  109,  108,  107,  106,  105,
+      104,  102,  100,   99,   98,   97,   96,   95,   93,   92,
+       91,   89,   88,   87,   85,   84,   83,   81,   80,   79,
+       78,   77,   68,   67,   66,   65,   55,   52,   51,   50,
+
+       49,   48,   46,   45,   44,   42,   41,   35,   33,   31,
+       30,   29,   19,   13,   12,    9,    2,  195,  195,  195,
+      195,  195,  195,  195,  195,  195,  195,  195,  195,  195,
+      195,  195,  195,  195,  195,  195,  195,  195,  195,  195,
+      195,  195,  195,  195,  195,  195,  195,  195,  195,  195,
+      195,  195,  195,  195,  195,  195,  195,  195,  195,  195,
+      195,  195,  195,  195,  195,  195,  195,  195,  195,  195,
+      195
     } ;
     } ;
 
 
 static yy_state_type yy_last_accepting_state;
 static yy_state_type yy_last_accepting_state;
@@ -571,10 +573,10 @@ char *yytext;
     int flat = 0;
     int flat = 0;
     int is_last = 0;  // 是否\n
     int is_last = 0;  // 是否\n
     int is_stop = 0;  // 针对}需要返回一个}的同时返回一个STOP
     int is_stop = 0;  // 针对}需要返回一个}的同时返回一个STOP
-#line 574 "lex.yy.c"
-
 #line 576 "lex.yy.c"
 #line 576 "lex.yy.c"
 
 
+#line 578 "lex.yy.c"
+
 #define INITIAL 0
 #define INITIAL 0
 #define COMMENT 1
 #define COMMENT 1
 #define STRING_TEXT 2
 #define STRING_TEXT 2
@@ -798,7 +800,7 @@ YY_DECL
 	{
 	{
 #line 13 "gwarf_lex.l"
 #line 13 "gwarf_lex.l"
 
 
-#line 801 "lex.yy.c"
+#line 803 "lex.yy.c"
 
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
 		{
@@ -826,13 +828,13 @@ yy_match:
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 				{
 				{
 				yy_current_state = (int) yy_def[yy_current_state];
 				yy_current_state = (int) yy_def[yy_current_state];
-				if ( yy_current_state >= 195 )
+				if ( yy_current_state >= 196 )
 					yy_c = yy_meta[yy_c];
 					yy_c = yy_meta[yy_c];
 				}
 				}
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 			++yy_cp;
 			++yy_cp;
 			}
 			}
-		while ( yy_base[yy_current_state] != 217 );
+		while ( yy_base[yy_current_state] != 218 );
 
 
 yy_find_action:
 yy_find_action:
 		yy_act = yy_accept[yy_current_state];
 		yy_act = yy_accept[yy_current_state];
@@ -955,83 +957,83 @@ YY_RULE_SETUP
 case 18:
 case 18:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 39 "gwarf_lex.l"
 #line 39 "gwarf_lex.l"
-{return DEFAULT;}
+{return COLON;}
 	YY_BREAK
 	YY_BREAK
 case 19:
 case 19:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 40 "gwarf_lex.l"
 #line 40 "gwarf_lex.l"
-{return GLOBAL;}
+{return DEFAULT;}
 	YY_BREAK
 	YY_BREAK
 case 20:
 case 20:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 41 "gwarf_lex.l"
 #line 41 "gwarf_lex.l"
-{return NONLOCAL;}
+{return GLOBAL;}
 	YY_BREAK
 	YY_BREAK
 case 21:
 case 21:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 42 "gwarf_lex.l"
 #line 42 "gwarf_lex.l"
-{return BLOCK;}
+{return NONLOCAL;}
 	YY_BREAK
 	YY_BREAK
 case 22:
 case 22:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 44 "gwarf_lex.l"
-{return LB;}
+#line 43 "gwarf_lex.l"
+{return BLOCK;}
 	YY_BREAK
 	YY_BREAK
 case 23:
 case 23:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 45 "gwarf_lex.l"
 #line 45 "gwarf_lex.l"
-{return RB;}
+{return LB;}
 	YY_BREAK
 	YY_BREAK
 case 24:
 case 24:
-/* rule 24 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 46 "gwarf_lex.l"
 #line 46 "gwarf_lex.l"
-{return LP;}
+{return RB;}
 	YY_BREAK
 	YY_BREAK
 case 25:
 case 25:
+/* rule 25 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 47 "gwarf_lex.l"
 #line 47 "gwarf_lex.l"
-{return RP;}
+{return LP;}
 	YY_BREAK
 	YY_BREAK
 case 26:
 case 26:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 49 "gwarf_lex.l"
-{return MOREEQ;}
+#line 48 "gwarf_lex.l"
+{return RP;}
 	YY_BREAK
 	YY_BREAK
 case 27:
 case 27:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 50 "gwarf_lex.l"
 #line 50 "gwarf_lex.l"
-{return LESSEQ;}
+{return MOREEQ;}
 	YY_BREAK
 	YY_BREAK
 case 28:
 case 28:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 51 "gwarf_lex.l"
 #line 51 "gwarf_lex.l"
-{return NOTEQ;}
+{return LESSEQ;}
 	YY_BREAK
 	YY_BREAK
 case 29:
 case 29:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 52 "gwarf_lex.l"
 #line 52 "gwarf_lex.l"
-{return MORE;}
+{return NOTEQ;}
 	YY_BREAK
 	YY_BREAK
 case 30:
 case 30:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 53 "gwarf_lex.l"
 #line 53 "gwarf_lex.l"
-{return LESS;}
+{return MORE;}
 	YY_BREAK
 	YY_BREAK
 case 31:
 case 31:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 54 "gwarf_lex.l"
 #line 54 "gwarf_lex.l"
-{return EQUAL;}
+{return LESS;}
 	YY_BREAK
 	YY_BREAK
 case 32:
 case 32:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 55 "gwarf_lex.l"
 #line 55 "gwarf_lex.l"
-{return EQ;}
+{return EQUAL;}
 	YY_BREAK
 	YY_BREAK
 case 33:
 case 33:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 56 "gwarf_lex.l"
 #line 56 "gwarf_lex.l"
-{return POW;}
+{return EQ;}
 	YY_BREAK
 	YY_BREAK
 case 34:
 case 34:
 YY_RULE_SETUP
 YY_RULE_SETUP
@@ -1041,57 +1043,57 @@ YY_RULE_SETUP
 case 35:
 case 35:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 58 "gwarf_lex.l"
 #line 58 "gwarf_lex.l"
-{return SQRT;}
+{return POW;}
 	YY_BREAK
 	YY_BREAK
 case 36:
 case 36:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 59 "gwarf_lex.l"
 #line 59 "gwarf_lex.l"
-{return LOG;}
+{return SQRT;}
 	YY_BREAK
 	YY_BREAK
 case 37:
 case 37:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 60 "gwarf_lex.l"
 #line 60 "gwarf_lex.l"
-{return SQRT;}
+{return LOG;}
 	YY_BREAK
 	YY_BREAK
 case 38:
 case 38:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 61 "gwarf_lex.l"
 #line 61 "gwarf_lex.l"
-{return ADD;}
+{return SQRT;}
 	YY_BREAK
 	YY_BREAK
 case 39:
 case 39:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 62 "gwarf_lex.l"
 #line 62 "gwarf_lex.l"
-{return SUB;}
+{return ADD;}
 	YY_BREAK
 	YY_BREAK
 case 40:
 case 40:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 63 "gwarf_lex.l"
 #line 63 "gwarf_lex.l"
-{return MUL;}
+{return SUB;}
 	YY_BREAK
 	YY_BREAK
 case 41:
 case 41:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 64 "gwarf_lex.l"
 #line 64 "gwarf_lex.l"
-{return DIV;}
+{return MUL;}
 	YY_BREAK
 	YY_BREAK
 case 42:
 case 42:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 65 "gwarf_lex.l"
 #line 65 "gwarf_lex.l"
-{return LI;}
+{return DIV;}
 	YY_BREAK
 	YY_BREAK
 case 43:
 case 43:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 66 "gwarf_lex.l"
 #line 66 "gwarf_lex.l"
-{return RI;}
+{return LI;}
 	YY_BREAK
 	YY_BREAK
 case 44:
 case 44:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 68 "gwarf_lex.l"
-{BEGIN COMMENT;}
+#line 67 "gwarf_lex.l"
+{return RI;}
 	YY_BREAK
 	YY_BREAK
 case 45:
 case 45:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 69 "gwarf_lex.l"
 #line 69 "gwarf_lex.l"
-{BEGIN STRING_TEXT;}
+{BEGIN COMMENT;}
 	YY_BREAK
 	YY_BREAK
 case 46:
 case 46:
 YY_RULE_SETUP
 YY_RULE_SETUP
@@ -1100,28 +1102,28 @@ YY_RULE_SETUP
 	YY_BREAK
 	YY_BREAK
 case 47:
 case 47:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 72 "gwarf_lex.l"
-{return TRUE;}
+#line 71 "gwarf_lex.l"
+{BEGIN STRING_TEXT;}
 	YY_BREAK
 	YY_BREAK
 case 48:
 case 48:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 73 "gwarf_lex.l"
 #line 73 "gwarf_lex.l"
-{return FALSE;}
+{return TRUE;}
 	YY_BREAK
 	YY_BREAK
 case 49:
 case 49:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 74 "gwarf_lex.l"
 #line 74 "gwarf_lex.l"
-{return TRUE;}
+{return FALSE;}
 	YY_BREAK
 	YY_BREAK
 case 50:
 case 50:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 75 "gwarf_lex.l"
 #line 75 "gwarf_lex.l"
-{return FALSE;}
+{return TRUE;}
 	YY_BREAK
 	YY_BREAK
 case 51:
 case 51:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 76 "gwarf_lex.l"
 #line 76 "gwarf_lex.l"
-{return NULL_token;}
+{return FALSE;}
 	YY_BREAK
 	YY_BREAK
 case 52:
 case 52:
 YY_RULE_SETUP
 YY_RULE_SETUP
@@ -1136,75 +1138,75 @@ YY_RULE_SETUP
 case 54:
 case 54:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 79 "gwarf_lex.l"
 #line 79 "gwarf_lex.l"
-{return DEF;}
+{return NULL_token;}
 	YY_BREAK
 	YY_BREAK
 case 55:
 case 55:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 80 "gwarf_lex.l"
 #line 80 "gwarf_lex.l"
-{return RETURN;}
+{return DEF;}
 	YY_BREAK
 	YY_BREAK
 case 56:
 case 56:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 81 "gwarf_lex.l"
 #line 81 "gwarf_lex.l"
-{return CLASS;}
+{return RETURN;}
 	YY_BREAK
 	YY_BREAK
 case 57:
 case 57:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 82 "gwarf_lex.l"
 #line 82 "gwarf_lex.l"
-{return POINT;}
+{return CLASS;}
 	YY_BREAK
 	YY_BREAK
 case 58:
 case 58:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 84 "gwarf_lex.l"
+#line 83 "gwarf_lex.l"
+{return POINT;}
+	YY_BREAK
+case 59:
+YY_RULE_SETUP
+#line 85 "gwarf_lex.l"
 {
 {
     yylval.double_value = atof(yytext);
     yylval.double_value = atof(yytext);
     return NUMBER;
     return NUMBER;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 59:
+case 60:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 88 "gwarf_lex.l"
+#line 89 "gwarf_lex.l"
 {
 {
     yylval.double_value = atof(yytext);
     yylval.double_value = atof(yytext);
     return INT;
     return INT;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 60:
+case 61:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 92 "gwarf_lex.l"
+#line 93 "gwarf_lex.l"
 {
 {
     yylval.string_value = yytext;
     yylval.string_value = yytext;
     return VAR;
     return VAR;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 61:
-/* rule 61 can match eol */
-YY_RULE_SETUP
-#line 96 "gwarf_lex.l"
-{return STOPN;}
-	YY_BREAK
 case 62:
 case 62:
+/* rule 62 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 97 "gwarf_lex.l"
 #line 97 "gwarf_lex.l"
-{return STOPF;}
+{return STOPN;}
 	YY_BREAK
 	YY_BREAK
 case 63:
 case 63:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 98 "gwarf_lex.l"
 #line 98 "gwarf_lex.l"
-;
+{return STOPF;}
 	YY_BREAK
 	YY_BREAK
 case 64:
 case 64:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 99 "gwarf_lex.l"
 #line 99 "gwarf_lex.l"
-{printf("other text = [%s];\n", yytext);}
+;
 	YY_BREAK
 	YY_BREAK
 case 65:
 case 65:
-/* rule 65 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 101 "gwarf_lex.l"
-{BEGIN INITIAL;}
+#line 100 "gwarf_lex.l"
+{printf("other text = [%s];\n", yytext);}
 	YY_BREAK
 	YY_BREAK
 case 66:
 case 66:
+/* rule 66 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 102 "gwarf_lex.l"
 #line 102 "gwarf_lex.l"
 {BEGIN INITIAL;}
 {BEGIN INITIAL;}
@@ -1212,12 +1214,12 @@ YY_RULE_SETUP
 case 67:
 case 67:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 103 "gwarf_lex.l"
 #line 103 "gwarf_lex.l"
-;
+{BEGIN INITIAL;}
 	YY_BREAK
 	YY_BREAK
 case 68:
 case 68:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 105 "gwarf_lex.l"
-{BEGIN INITIAL;}
+#line 104 "gwarf_lex.l"
+;
 	YY_BREAK
 	YY_BREAK
 case 69:
 case 69:
 YY_RULE_SETUP
 YY_RULE_SETUP
@@ -1225,28 +1227,33 @@ YY_RULE_SETUP
 {BEGIN INITIAL;}
 {BEGIN INITIAL;}
 	YY_BREAK
 	YY_BREAK
 case 70:
 case 70:
-/* rule 70 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 107 "gwarf_lex.l"
 #line 107 "gwarf_lex.l"
+{BEGIN INITIAL;}
+	YY_BREAK
+case 71:
+/* rule 71 can match eol */
+YY_RULE_SETUP
+#line 108 "gwarf_lex.l"
 {
 {
     yylval.string_value = yytext;
     yylval.string_value = yytext;
     return STRING;
     return STRING;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 71:
+case 72:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 111 "gwarf_lex.l"
+#line 112 "gwarf_lex.l"
 {
 {
     yylval.string_value = yytext;
     yylval.string_value = yytext;
     return STRING;
     return STRING;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 72:
+case 73:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 115 "gwarf_lex.l"
+#line 116 "gwarf_lex.l"
 ECHO;
 ECHO;
 	YY_BREAK
 	YY_BREAK
-#line 1249 "lex.yy.c"
+#line 1256 "lex.yy.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(COMMENT):
 case YY_STATE_EOF(COMMENT):
 case YY_STATE_EOF(STRING_TEXT):
 case YY_STATE_EOF(STRING_TEXT):
@@ -1547,7 +1554,7 @@ static int yy_get_next_buffer (void)
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			{
 			{
 			yy_current_state = (int) yy_def[yy_current_state];
 			yy_current_state = (int) yy_def[yy_current_state];
-			if ( yy_current_state >= 195 )
+			if ( yy_current_state >= 196 )
 				yy_c = yy_meta[yy_c];
 				yy_c = yy_meta[yy_c];
 			}
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -1575,11 +1582,11 @@ static int yy_get_next_buffer (void)
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		{
 		{
 		yy_current_state = (int) yy_def[yy_current_state];
 		yy_current_state = (int) yy_def[yy_current_state];
-		if ( yy_current_state >= 195 )
+		if ( yy_current_state >= 196 )
 			yy_c = yy_meta[yy_c];
 			yy_c = yy_meta[yy_c];
 		}
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
-	yy_is_jam = (yy_current_state == 194);
+	yy_is_jam = (yy_current_state == 195);
 
 
 		return yy_is_jam ? 0 : yy_current_state;
 		return yy_is_jam ? 0 : yy_current_state;
 }
 }
@@ -2257,7 +2264,7 @@ void yyfree (void * ptr )
 
 
 #define YYTABLES_NAME "yytables"
 #define YYTABLES_NAME "yytables"
 
 
-#line 115 "gwarf_lex.l"
+#line 116 "gwarf_lex.l"
 
 
 int yywrap(void) {
 int yywrap(void) {
     return 1;
     return 1;

文件差异内容过多而无法显示
+ 287 - 256
paser/y.tab.c


+ 4 - 2
paser/y.tab.h

@@ -100,7 +100,8 @@ extern int yydebug;
     DEF = 306,
     DEF = 306,
     RETURN = 307,
     RETURN = 307,
     CLASS = 308,
     CLASS = 308,
-    POINT = 309
+    POINT = 309,
+    COLON = 310
   };
   };
 #endif
 #endif
 /* Tokens.  */
 /* Tokens.  */
@@ -156,6 +157,7 @@ extern int yydebug;
 #define RETURN 307
 #define RETURN 307
 #define CLASS 308
 #define CLASS 308
 #define POINT 309
 #define POINT 309
+#define COLON 310
 
 
 /* Value type.  */
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@@ -170,7 +172,7 @@ union YYSTYPE
     struct if_list *if_list_base;
     struct if_list *if_list_base;
     struct parameter *parameter_list;
     struct parameter *parameter_list;
 
 
-#line 174 "y.tab.h"
+#line 176 "y.tab.h"
 
 
 };
 };
 typedef union YYSTYPE YYSTYPE;
 typedef union YYSTYPE YYSTYPE;

部分文件因为文件数量过多而无法显示