瀏覽代碼

实现for i in xxx迭代功能

SongZihuan 5 年之前
父節點
當前提交
3dec2bf324
共有 10 個文件被更改,包括 591 次插入381 次删除
  1. 二進制
      gwarf
  2. 4 3
      gwarf.c
  3. 82 14
      inter/cfunc.c
  4. 99 0
      inter/interpreter.c
  5. 11 3
      inter/interpreter.h
  6. 1 0
      paser/gwarf_lex.l
  7. 19 1
      paser/gwarf_yacc.y
  8. 105 100
      paser/lex.yy.c
  9. 266 258
      paser/y.tab.c
  10. 4 2
      paser/y.tab.h

二進制
gwarf


+ 4 - 3
gwarf.c

@@ -40,9 +40,10 @@ void login(var_list *the_var){
     list_login_official(the_var, list_official_func, tmp_gobject->the_var);  // 注册list
     list_login_official(the_var, list_official_func, tmp_gobject->the_var);  // 注册list
 
 
     // 注册错误类型
     // 注册错误类型
-    class_object *tmp_BaseException = BaseException_login_official(the_var, BaseException_official_func, tmp_object->the_var);  // 注册goobject
-    class_object *tmp_Exception = Exception_login_official(the_var, tmp_BaseException->the_var);  // 注册goobject
-    NameException_login_official(the_var, tmp_Exception->the_var);  // 注册goobject
+    class_object *tmp_BaseException = BaseException_login_official(the_var, BaseException_official_func, tmp_object->the_var);
+    class_object *tmp_Exception = Exception_login_official(the_var, tmp_BaseException->the_var);
+    NameException_login_official(the_var, tmp_Exception->the_var);
+    IterException_login_official(the_var, tmp_Exception->the_var);
 }
 }
 
 
 // 编译指令:cd "/home/songzihuan/文档/CProject/gwarf/" && gcc gwarf.c -lm -o gwarf && "/home/songzihuan/文档/CProject/gwarf/"gwarf
 // 编译指令:cd "/home/songzihuan/文档/CProject/gwarf/" && gcc gwarf.c -lm -o gwarf && "/home/songzihuan/文档/CProject/gwarf/"gwarf

+ 82 - 14
inter/cfunc.c

@@ -361,6 +361,20 @@ class_object *NameException_login_official(var_list *the_var, var_list *father_v
     return class_tmp;
     return class_tmp;
 }
 }
 
 
+class_object *IterException_login_official(var_list *the_var, var_list *father_var_list){
+    // 创建对象[空对象]
+    puts("----set class----");
+    GWARF_result class_value;
+    class_object *class_tmp = make_object(the_var, father_var_list);
+
+    class_value.value.type = CLASS_value;
+    class_value.value.value.class_value = class_tmp;
+
+    assigment_func("IterException", class_value, the_var, 0);  // 注册class 的 位置
+    puts("----stop set class----");
+    return class_tmp;
+}
+
 class_object *gobject_login_official(var_list *the_var, GWARF_result (*paser)(func *, parameter *, var_list *, GWARF_result, var_list *), var_list *father_var_list){  // 内置对象继承的类
 class_object *gobject_login_official(var_list *the_var, GWARF_result (*paser)(func *, parameter *, var_list *, GWARF_result, var_list *), var_list *father_var_list){  // 内置对象继承的类
     // 创建对象[空对象]
     // 创建对象[空对象]
     puts("----set class----");
     puts("----set class----");
@@ -1235,8 +1249,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},{26,1}};
-    char *name[] = {"__init__", "__len__", "__down__", "__set__", "__slice__"};  //  __len__是获取长度,__down__是获取下值,__set__是设置值,__slice__是切片
+    int a[][2] = {{2,1},{23,1},{24,1},{25,1},{26,1},{27,1},{28,1}};
+    char *name[] = {"__init__", "__len__", "__down__", "__set__", "__slice__", "__iter__", "__next__"};  //  __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){
@@ -1287,18 +1301,51 @@ GWARF_result list_official_func(func *the_func, parameter *tmp_s, var_list *the_
                 assigment_func("value", tmp, login_var, 0);  // 注册到self
                 assigment_func("value", tmp, login_var, 0);  // 注册到self
                 return_value.u = statement_end;  // __init__没有return
                 return_value.u = statement_end;  // __init__没有return
             }
             }
+            GWARF_result iter_value;
+            iter_value.value.type = INT_value;
+            iter_value.value.value.int_value = 0;
+            assigment_func("iter_value", iter_value, login_var, 0);  // 注册到self
             break;
             break;
         }
         }
         case __len__func:{  // return index
         case __len__func:{  // return index
             var *tmp = find_var(login_var, 0, "value");
             var *tmp = find_var(login_var, 0, "value");
-            if(tmp != NULL){
-                return_value.value.type = INT_value;
-                return_value.value.value.int_value = (int)(sizeof(tmp->value.value.list_value->list_value) / sizeof(GWARF_value));  // 获取长度
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = tmp->value.value.list_value->index;
+            break;
+        }
+        case __iter__func:{  // return self
+            GWARF_result iter_value;
+            iter_value.value.type = INT_value;
+            iter_value.value.value.int_value = 0;
+            assigment_func("iter_value", iter_value, login_var, 0);  // 注册到self
+
+            return_value.value = *(father.father);
+            break;
+        }
+        case __next__func:{  // return index
+            var *tmp = find_var(login_var, 0, "iter_value");
+            int iter_index, len;
+            if(tmp == NULL){
+                iter_index = 0;
             }
             }
             else{
             else{
-                return_value.value.type = INT_value;
-                return_value.value.value.int_value = 0;
+                iter_index = to_int(tmp->value, out_var).value.int_value;
+            }
+
+            tmp = find_var(login_var, 0, "value");
+            len = tmp->value.value.list_value->index;
+            printf("len = %d, iter_index = %d\n", len, iter_index);
+            if(iter_index >= len){  // 已经超出
+                return_value = to_error("Max Iter", "IterException", the_var);
+            }
+            else{
+                return_value.value = tmp->value.value.list_value->list_value[iter_index];
+                GWARF_result iter_value;
+                iter_value.value.type = INT_value;
+                iter_value.value.value.int_value = iter_index + 1;
+                assigment_func("iter_value", iter_value, login_var, 0);  // 注册到self
             }
             }
+
             break;
             break;
         }
         }
         case __down__func:{  // return index
         case __down__func:{  // return index
@@ -1327,7 +1374,7 @@ GWARF_result list_official_func(func *the_func, parameter *tmp_s, var_list *the_
         }
         }
         case __slice__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 = tmp->value.value.list_value->index;
             int start, end;
             int start, end;
             if(tmp != NULL){
             if(tmp != NULL){
                 GWARF_result start_result = traverse(tmp_s->u.value, out_var, false), end_result;
                 GWARF_result start_result = traverse(tmp_s->u.value, out_var, false), end_result;
@@ -1362,7 +1409,7 @@ GWARF_result list_official_func(func *the_func, parameter *tmp_s, var_list *the_
                 return_value.value.value.list_value = malloc(sizeof(the_list));  // 申请list的空间
                 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)));
                 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)));
                 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;
+                return_value.value.value.list_value->index = (end - start) - 1;
             }
             }
             else{
             else{
                 return_value.value.type = NULL_value;
                 return_value.value.type = NULL_value;
@@ -1463,6 +1510,22 @@ GWARF_value parameter_to_list(parameter *tmp_s, var_list *the_var){  // 把param
 }
 }
 
 
 
 
+GWARF_result get__next__(GWARF_value *base_the_var, var_list *the_var){  // 获取__next__
+    GWARF_result tmp = run_func_core(base_the_var, the_var, "__next__", true);
+    //  不需要捕获IterException[表示到达尽头]
+    return tmp;
+}
+
+GWARF_result get__iter__(GWARF_value *base_the_var, var_list *the_var){  // 获取__iter__
+    GWARF_result tmp = run_func_core(base_the_var, the_var, "__iter__", true);
+    if(is_error(&tmp)){
+        tmp.u = statement_end;
+        tmp.value.type = NULL_value;
+        tmp.value.value.int_value = 0;
+    }
+    return tmp;
+}
+
 GWARF_result get__value__(GWARF_value *base_the_var, var_list *the_var){  // 用于计算的get__value__统一核心
 GWARF_result get__value__(GWARF_value *base_the_var, var_list *the_var){  // 用于计算的get__value__统一核心
     GWARF_result tmp = run_func(base_the_var, the_var, "__value__");
     GWARF_result tmp = run_func(base_the_var, the_var, "__value__");
     if(is_error(&tmp)){
     if(is_error(&tmp)){
@@ -1473,9 +1536,9 @@ GWARF_result get__value__(GWARF_value *base_the_var, var_list *the_var){  // 用
     return tmp;
     return tmp;
 }
 }
 
 
-GWARF_result get__bool__(GWARF_value *base_the_var, var_list *the_var){  // 用于计算的get__value__统一核心
+GWARF_result get__bool__(GWARF_value *base_the_var, var_list *the_var){  // 获取__bool__  [所有转换为bool的object都执行这个]
     GWARF_result tmp = run_func(base_the_var, the_var, "__bool__");
     GWARF_result tmp = run_func(base_the_var, the_var, "__bool__");
-    if(is_error(&tmp)){
+    if(is_error(&tmp)){  // 检查是否为name_error
         tmp.u = statement_end;
         tmp.u = statement_end;
         tmp.value.type = BOOL_value;
         tmp.value.type = BOOL_value;
         tmp.value.value.bool_value = true;
         tmp.value.value.bool_value = true;
@@ -1483,7 +1546,7 @@ GWARF_result get__bool__(GWARF_value *base_the_var, var_list *the_var){  // 用
     return tmp;
     return tmp;
 }
 }
 
 
-GWARF_result run_func(GWARF_value *base_the_var, var_list *the_var, char *name){  // 无参数func->直到返回GWARF_value[not class]
+GWARF_result run_func_core(GWARF_value *base_the_var, var_list *the_var, char *name, bool only){  // 无参数func->直到返回GWARF_value[not class]
     GWARF_result reight_tmp, get;
     GWARF_result reight_tmp, get;
     reight_tmp.u = statement_end;
     reight_tmp.u = statement_end;
     int times = 0;
     int times = 0;
@@ -1506,8 +1569,13 @@ GWARF_result run_func(GWARF_value *base_the_var, var_list *the_var, char *name){
             get.value = tmp_var->value;  // TODO:: 需要检查__value__是否存在
             get.value = tmp_var->value;  // TODO:: 需要检查__value__是否存在
             get.father = base_the_var;  // 设置father
             get.father = base_the_var;  // 设置father
             reight_tmp = call_back_core(get, the_var, NULL);
             reight_tmp = call_back_core(get, the_var, NULL);
-            times = reight_tmp.return_times;
-            base_the_var = &(reight_tmp.value);  // 重复获取__value__[直到类型不是object或class]
+            if(only){  // 不需要重复获取,比如__iter__,__next__
+                goto return_result;
+            }
+            else{
+                times = reight_tmp.return_times;
+                base_the_var = &(reight_tmp.value);  // 重复获取__value__[直到类型不是object或class]
+            }
         }
         }
         else{
         else{
             char *tmp = malloc((size_t)( 21 + strlen(name)) );
             char *tmp = malloc((size_t)( 21 + strlen(name)) );

+ 99 - 0
inter/interpreter.c

@@ -118,6 +118,15 @@ GWARF_result read_statement(statement *the_statement, var_list *the_var, var_lis
                 return_value.value.value.int_value = 0;
                 return_value.value.value.int_value = 0;
             }
             }
             break;
             break;
+        case for_in_cycle:
+            puts("----for code----");
+            return_value = forin_func(the_statement, the_var);
+            puts("----for while code----");
+            if(return_value.u == statement_end){  // while循环不需要返回值[避免GWARF_value 进入 the_var]
+                return_value.value.type = NULL_value;
+                return_value.value.value.int_value = 0;
+            }
+            break;
         case if_branch:
         case if_branch:
             puts("----if code----");
             puts("----if code----");
             return_value = if_func(the_statement->code.if_branch.done, the_var);
             return_value = if_func(the_statement->code.if_branch.done, the_var);
@@ -1307,6 +1316,96 @@ GWARF_result block_func(statement *the_statement, var_list *the_var){  // read t
     return value;
     return value;
 }
 }
 
 
+// -----------------forin func
+
+GWARF_result forin_func(statement *the_statement, var_list *the_var){  // read the statement list with case to run by func
+    GWARF_result value;
+    var *tmp = make_var();  // base_var
+    the_var = append_var_list(tmp, the_var);
+
+    char *name = the_statement->code.for_in_cycle.name;
+    
+    GWARF_result tmp_result = traverse(the_statement->code.for_in_cycle.iter, the_var, false);  // 取得迭代器
+    if(is_error(&tmp_result)){  // Name Error错误
+        // puts("STOP:: Name No Found!");
+        value = tmp_result;
+        goto return_value;
+    }
+    else if(is_space(&tmp_result)){
+        value = tmp_result;
+        goto return_value;
+    }
+    
+    // puts("[tag 1]goto for in");
+    GWARF_value iter_value = get__iter__(&(tmp_result.value), the_var).value;  // 获取迭代object,一般是返回self
+    while (1){
+        GWARF_result tmp_next = get__next__(&(iter_value), the_var);// 执行__next__的返回值
+        if(is_error(&tmp_next)){  // TODO:: 检查是否为IterException
+            value.u = statement_end;
+            value.value.type = NULL_value;
+            value.value.value.int_value = 0;
+            break;  // goto return_value;
+        }
+        else{
+            assigment_func(name, tmp_next, the_var, 0);  // 赋值
+        }
+        restart_again: 
+        puts("----for in----");
+        value = traverse(the_statement->code.for_in_cycle.done, the_var, false);
+        puts("----stop for in----");
+
+        // break的操作
+        if((value.u == cycle_break) || (value.u == code_broken)){
+            if(value.value.type != INT_value){
+                value.value.type = INT_value;
+                value.value.value.int_value = 0;
+            }
+            if(value.value.value.int_value <= 0){
+                value.u = statement_end;  // 正常设置[正常语句结束]
+            }
+            else{
+                value.value.value.int_value -= 1;
+            }
+            break;
+        }
+
+        // continue的操作
+        if((value.u == cycle_continue) || (value.u == code_continued)){
+            if(value.value.type != INT_value){
+                value.value.type = INT_value;
+                value.value.value.int_value = 0;
+            }
+            if(value.value.value.int_value <= 0){
+                value.u = statement_end;
+                continue;
+            }
+            else{
+                value.value.value.int_value -= 1;
+                break;
+            }
+        }
+
+        // restart的操作
+        if((value.u == cycle_restart) || (value.u == code_restarted)){
+            if(value.value.type != INT_value){
+                value.value.type = INT_value;
+                value.value.value.int_value = 0;
+            }
+            if(value.value.value.int_value <= 0){
+                value.u = statement_end;
+                goto restart_again;
+            }
+            else{
+                value.value.value.int_value -= 1;
+                break;
+            }
+        }
+    }
+    return_value: 
+    the_var = free_var_list(the_var);  // free the new var
+    return value;
+}
+
 // -----------------while func
 // -----------------while func
 
 
 GWARF_result while_func(statement *the_statement, var_list *the_var){  // read the statement list with case to run by func
 GWARF_result while_func(statement *the_statement, var_list *the_var){  // read the statement list with case to run by func

+ 11 - 3
inter/interpreter.h

@@ -9,7 +9,9 @@
 #define false 0
 #define false 0
 #define true 1
 #define true 1
 #define bool int
 #define bool int
-#define read_statement_list(the_statement, the_var) read_statement(the_statement, the_var, NULL)
+
+#define read_statement_list(the_statement,the_var) read_statement(the_statement,the_var,NULL)
+#define run_func(base_the_var,the_var,name) run_func_core(base_the_var,the_var,name,false)
 
 
 // the type of data(GWARF_value)
 // the type of data(GWARF_value)
 typedef enum{
 typedef enum{
@@ -268,7 +270,7 @@ typedef struct statement{
 
 
         struct
         struct
         {
         {
-            struct statement *name;  // for i in a -> i
+            char *name;  // for i in a -> i
             struct statement *iter;  // for i in a -> a
             struct statement *iter;  // for i in a -> a
             struct statement *done;  // for while to do
             struct statement *done;  // for while to do
         } for_in_cycle;
         } for_in_cycle;
@@ -370,6 +372,8 @@ typedef enum{
     __down__func = 24,
     __down__func = 24,
     __set__func = 25,
     __set__func = 25,
     __slice__func = 26,
     __slice__func = 26,
+    __iter__func = 27,
+    __next__func = 28,
 } official_func_type;
 } official_func_type;
 
 
 typedef struct func{
 typedef struct func{
@@ -410,6 +414,7 @@ GWARF_result try_func(statement *, var_list *);
 GWARF_result raise_func(statement *, var_list *, bool);
 GWARF_result raise_func(statement *, var_list *, bool);
 GWARF_result import_func(statement *, var_list *);
 GWARF_result import_func(statement *, var_list *);
 GWARF_result include_func(statement *, var_list *);
 GWARF_result include_func(statement *, var_list *);
+GWARF_result forin_func(statement *, var_list *);
 
 
 GWARF_result add_func(GWARF_result, GWARF_result, var_list *);
 GWARF_result add_func(GWARF_result, GWARF_result, var_list *);
 GWARF_result sub_func(GWARF_result, GWARF_result, var_list *);
 GWARF_result sub_func(GWARF_result, GWARF_result, var_list *);
@@ -435,7 +440,9 @@ bool to_bool(GWARF_value);
 
 
 GWARF_result get__value__(GWARF_value *, var_list *);
 GWARF_result get__value__(GWARF_value *, var_list *);
 GWARF_result get__bool__(GWARF_value *, var_list *);
 GWARF_result get__bool__(GWARF_value *, var_list *);
-GWARF_result run_func(GWARF_value *, var_list *, char *);
+GWARF_result get__iter__(GWARF_value *, var_list *);
+GWARF_result get__next__(GWARF_value *, var_list *);
+GWARF_result run_func_core(GWARF_value *, var_list *, char *, bool);
 
 
 int len_only_double(double num);
 int len_only_double(double num);
 int len_double(double num);
 int len_double(double num);
@@ -484,6 +491,7 @@ GWARF_result BaseException_official_func(func *the_func, parameter *tmp_s, var_l
 
 
 class_object *Exception_login_official(var_list *the_var, var_list *father_var_list);
 class_object *Exception_login_official(var_list *the_var, var_list *father_var_list);
 class_object *NameException_login_official(var_list *the_var, var_list *father_var_list);
 class_object *NameException_login_official(var_list *the_var, var_list *father_var_list);
+class_object *IterException_login_official(var_list *the_var, var_list *father_var_list);
 
 
 // 生成错误
 // 生成错误
 GWARF_result to_error(char *error_info, char *error_type, var_list *the_var);
 GWARF_result to_error(char *error_info, char *error_type, var_list *the_var);

+ 1 - 0
paser/gwarf_lex.l

@@ -41,6 +41,7 @@
 <INITIAL>"global" {return GLOBAL;}
 <INITIAL>"global" {return GLOBAL;}
 <INITIAL>"nonlocal" {return NONLOCAL;}
 <INITIAL>"nonlocal" {return NONLOCAL;}
 <INITIAL>"block" {return BLOCK;}
 <INITIAL>"block" {return BLOCK;}
+<INITIAL>"in" {return IN;}
 
 
 <INITIAL>"import" {return IMPORT;}
 <INITIAL>"import" {return IMPORT;}
 <INITIAL>"include" {return INCLUDE;}
 <INITIAL>"include" {return INCLUDE;}

+ 19 - 1
paser/gwarf_yacc.y

@@ -23,7 +23,7 @@
 %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 COLON TRY EXCEPT AS RAISE THROW IMPORT INCLUDE
+%token NULL_token DEF RETURN CLASS POINT COLON TRY EXCEPT AS RAISE THROW IMPORT INCLUDE IN
 
 
 %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
@@ -695,6 +695,24 @@ for_exp
         statement_base = append_statement_list(for_tmp->code.for_cycle.done, statement_base);  // new statement_base (FILO)
         statement_base = append_statement_list(for_tmp->code.for_cycle.done, statement_base);  // new statement_base (FILO)
         $$ = for_tmp;
         $$ = for_tmp;
     }
     }
+    | FOR LB base_var_ IN top_exp RB
+    {
+        statement *for_tmp =  make_statement();
+        for_tmp->type = for_in_cycle;
+        for_tmp->type = for_in_cycle;
+        for_tmp->code.for_in_cycle.iter = $5;
+
+        for_tmp->code.for_in_cycle.name = malloc(sizeof($3->code.base_var.var_name));
+        char *name_tmp = for_tmp->code.for_in_cycle.name;
+        strcpy(name_tmp, $3->code.base_var.var_name);
+
+        for_tmp->code.for_in_cycle.done = make_statement();
+        statement_base = append_statement_list(for_tmp->code.for_in_cycle.done, statement_base);  // new statement_base (FILO)
+
+        free($3->code.base_var.var_name);  // 实际上会内存泄露[from没有被释放]
+        free($3);
+        $$ = for_tmp;
+    }
     ;
     ;
 
 
 include_exp
 include_exp

+ 105 - 100
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 80
-#define YY_END_OF_BUFFER 81
+#define YY_NUM_RULES 81
+#define YY_END_OF_BUFFER 82
 /* 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
@@ -362,31 +362,31 @@ struct yy_trans_info
 	};
 	};
 static const flex_int16_t yy_accept[228] =
 static const flex_int16_t yy_accept[228] =
     {   0,
     {   0,
-        0,    0,    0,    0,    0,    0,    0,    0,   81,   72,
-       69,   71,   72,   49,   47,   48,   25,   26,   43,   41,
-       17,   42,   65,   44,   67,   67,   18,   70,   33,   35,
-       32,   68,   68,   68,   68,   45,   46,   37,   68,   68,
-       68,   68,   68,   68,   68,   68,   68,   68,   68,   68,
-       68,   68,   27,   28,   38,   71,   75,   73,   74,   79,
-       78,   77,   76,   80,    0,    0,    0,   27,    0,   31,
-       36,    0,   67,   30,   34,   29,   68,   68,   68,   68,
-       68,   52,   68,   68,   68,   68,   68,   68,   68,   68,
-       68,   68,    5,   68,   68,   68,   68,   68,   68,   68,
-
-       68,   68,   68,   68,   27,    0,    0,    0,    0,    0,
-       66,   68,   68,   68,   68,   68,   68,   68,   68,   68,
-       62,   68,   68,   68,   68,   16,   68,   68,   68,   39,
-       68,   68,   68,   68,   68,   68,   68,   68,   68,   68,
-       50,   68,    0,    0,    0,    0,    0,    3,   68,   60,
-       59,   57,   68,   68,   68,   68,   68,   68,    6,    7,
-       68,   68,   68,   68,   68,   68,   61,   68,   14,   68,
-       68,   68,   40,   68,   55,   68,    1,    2,    6,    7,
-        0,   58,   22,    8,   68,   64,   68,   68,    0,   68,
-       56,   68,   68,   68,   68,   53,   68,   68,   68,   54,
-
-        4,    2,    0,    9,   68,   68,    7,   51,   20,   23,
-       68,   68,   68,   63,   15,   51,   68,   19,   24,   68,
-       11,   10,   21,   68,   13,   12,    0
+        0,    0,    0,    0,    0,    0,    0,    0,   82,   73,
+       70,   72,   73,   50,   48,   49,   26,   27,   44,   42,
+       17,   43,   66,   45,   68,   68,   18,   71,   34,   36,
+       33,   69,   69,   69,   69,   46,   47,   38,   69,   69,
+       69,   69,   69,   69,   69,   69,   69,   69,   69,   69,
+       69,   69,   28,   29,   39,   72,   76,   74,   75,   80,
+       79,   78,   77,   81,    0,    0,    0,   28,    0,   32,
+       37,    0,   68,   31,   35,   30,   69,   69,   69,   69,
+       69,   53,   69,   69,   69,   69,   69,   69,   69,   69,
+       69,   69,    5,   69,   23,   69,   69,   69,   69,   69,
+
+       69,   69,   69,   69,   28,    0,    0,    0,    0,    0,
+       67,   69,   69,   69,   69,   69,   69,   69,   69,   69,
+       63,   69,   69,   69,   69,   16,   69,   69,   69,   40,
+       69,   69,   69,   69,   69,   69,   69,   69,   69,   69,
+       51,   69,    0,    0,    0,    0,    0,    3,   69,   61,
+       60,   58,   69,   69,   69,   69,   69,   69,    6,    7,
+       69,   69,   69,   69,   69,   69,   62,   69,   14,   69,
+       69,   69,   41,   69,   56,   69,    1,    2,    6,    7,
+        0,   59,   22,    8,   69,   65,   69,   69,    0,   69,
+       57,   69,   69,   69,   69,   54,   69,   69,   69,   55,
+
+        4,    2,    0,    9,   69,   69,    7,   52,   20,   24,
+       69,   69,   69,   64,   15,   52,   69,   19,   25,   69,
+       11,   10,   21,   69,   13,   12,    0
     } ;
     } ;
 
 
 static const YY_CHAR yy_ec[256] =
 static const YY_CHAR yy_ec[256] =
@@ -1000,74 +1000,74 @@ YY_RULE_SETUP
 	YY_BREAK
 	YY_BREAK
 case 23:
 case 23:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 45 "gwarf_lex.l"
-{return IMPORT;}
+#line 44 "gwarf_lex.l"
+{return IN;}
 	YY_BREAK
 	YY_BREAK
 case 24:
 case 24:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 46 "gwarf_lex.l"
 #line 46 "gwarf_lex.l"
-{return INCLUDE;}
+{return IMPORT;}
 	YY_BREAK
 	YY_BREAK
 case 25:
 case 25:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 48 "gwarf_lex.l"
-{return LB;}
+#line 47 "gwarf_lex.l"
+{return INCLUDE;}
 	YY_BREAK
 	YY_BREAK
 case 26:
 case 26:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 49 "gwarf_lex.l"
 #line 49 "gwarf_lex.l"
-{return RB;}
+{return LB;}
 	YY_BREAK
 	YY_BREAK
 case 27:
 case 27:
-/* rule 27 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 50 "gwarf_lex.l"
 #line 50 "gwarf_lex.l"
-{return LP;}
+{return RB;}
 	YY_BREAK
 	YY_BREAK
 case 28:
 case 28:
+/* rule 28 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 51 "gwarf_lex.l"
 #line 51 "gwarf_lex.l"
-{return RP;}
+{return LP;}
 	YY_BREAK
 	YY_BREAK
 case 29:
 case 29:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 53 "gwarf_lex.l"
-{return MOREEQ;}
+#line 52 "gwarf_lex.l"
+{return RP;}
 	YY_BREAK
 	YY_BREAK
 case 30:
 case 30:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 54 "gwarf_lex.l"
 #line 54 "gwarf_lex.l"
-{return LESSEQ;}
+{return MOREEQ;}
 	YY_BREAK
 	YY_BREAK
 case 31:
 case 31:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 55 "gwarf_lex.l"
 #line 55 "gwarf_lex.l"
-{return NOTEQ;}
+{return LESSEQ;}
 	YY_BREAK
 	YY_BREAK
 case 32:
 case 32:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 56 "gwarf_lex.l"
 #line 56 "gwarf_lex.l"
-{return MORE;}
+{return NOTEQ;}
 	YY_BREAK
 	YY_BREAK
 case 33:
 case 33:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 57 "gwarf_lex.l"
 #line 57 "gwarf_lex.l"
-{return LESS;}
+{return MORE;}
 	YY_BREAK
 	YY_BREAK
 case 34:
 case 34:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 58 "gwarf_lex.l"
 #line 58 "gwarf_lex.l"
-{return EQUAL;}
+{return LESS;}
 	YY_BREAK
 	YY_BREAK
 case 35:
 case 35:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 59 "gwarf_lex.l"
 #line 59 "gwarf_lex.l"
-{return EQ;}
+{return EQUAL;}
 	YY_BREAK
 	YY_BREAK
 case 36:
 case 36:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 60 "gwarf_lex.l"
 #line 60 "gwarf_lex.l"
-{return POW;}
+{return EQ;}
 	YY_BREAK
 	YY_BREAK
 case 37:
 case 37:
 YY_RULE_SETUP
 YY_RULE_SETUP
@@ -1077,57 +1077,57 @@ YY_RULE_SETUP
 case 38:
 case 38:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 62 "gwarf_lex.l"
 #line 62 "gwarf_lex.l"
-{return SQRT;}
+{return POW;}
 	YY_BREAK
 	YY_BREAK
 case 39:
 case 39:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 63 "gwarf_lex.l"
 #line 63 "gwarf_lex.l"
-{return LOG;}
+{return SQRT;}
 	YY_BREAK
 	YY_BREAK
 case 40:
 case 40:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 64 "gwarf_lex.l"
 #line 64 "gwarf_lex.l"
-{return SQRT;}
+{return LOG;}
 	YY_BREAK
 	YY_BREAK
 case 41:
 case 41:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 65 "gwarf_lex.l"
 #line 65 "gwarf_lex.l"
-{return ADD;}
+{return SQRT;}
 	YY_BREAK
 	YY_BREAK
 case 42:
 case 42:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 66 "gwarf_lex.l"
 #line 66 "gwarf_lex.l"
-{return SUB;}
+{return ADD;}
 	YY_BREAK
 	YY_BREAK
 case 43:
 case 43:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 67 "gwarf_lex.l"
 #line 67 "gwarf_lex.l"
-{return MUL;}
+{return SUB;}
 	YY_BREAK
 	YY_BREAK
 case 44:
 case 44:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 68 "gwarf_lex.l"
 #line 68 "gwarf_lex.l"
-{return DIV;}
+{return MUL;}
 	YY_BREAK
 	YY_BREAK
 case 45:
 case 45:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 69 "gwarf_lex.l"
 #line 69 "gwarf_lex.l"
-{return LI;}
+{return DIV;}
 	YY_BREAK
 	YY_BREAK
 case 46:
 case 46:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 70 "gwarf_lex.l"
 #line 70 "gwarf_lex.l"
-{return RI;}
+{return LI;}
 	YY_BREAK
 	YY_BREAK
 case 47:
 case 47:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 72 "gwarf_lex.l"
-{BEGIN COMMENT;}
+#line 71 "gwarf_lex.l"
+{return RI;}
 	YY_BREAK
 	YY_BREAK
 case 48:
 case 48:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 73 "gwarf_lex.l"
 #line 73 "gwarf_lex.l"
-{BEGIN STRING_TEXT;}
+{BEGIN COMMENT;}
 	YY_BREAK
 	YY_BREAK
 case 49:
 case 49:
 YY_RULE_SETUP
 YY_RULE_SETUP
@@ -1136,54 +1136,54 @@ YY_RULE_SETUP
 	YY_BREAK
 	YY_BREAK
 case 50:
 case 50:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 76 "gwarf_lex.l"
-{return TRY;}
+#line 75 "gwarf_lex.l"
+{BEGIN STRING_TEXT;}
 	YY_BREAK
 	YY_BREAK
 case 51:
 case 51:
-/* rule 51 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 77 "gwarf_lex.l"
 #line 77 "gwarf_lex.l"
-{return EXCEPT;}
+{return TRY;}
 	YY_BREAK
 	YY_BREAK
 case 52:
 case 52:
+/* rule 52 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 78 "gwarf_lex.l"
 #line 78 "gwarf_lex.l"
-{return AS;}
+{return EXCEPT;}
 	YY_BREAK
 	YY_BREAK
 case 53:
 case 53:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 79 "gwarf_lex.l"
 #line 79 "gwarf_lex.l"
-{return RAISE;}
+{return AS;}
 	YY_BREAK
 	YY_BREAK
 case 54:
 case 54:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 80 "gwarf_lex.l"
 #line 80 "gwarf_lex.l"
-{return THROW;}
+{return RAISE;}
 	YY_BREAK
 	YY_BREAK
 case 55:
 case 55:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 81 "gwarf_lex.l"
 #line 81 "gwarf_lex.l"
-{return TRUE;}
+{return THROW;}
 	YY_BREAK
 	YY_BREAK
 case 56:
 case 56:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 82 "gwarf_lex.l"
 #line 82 "gwarf_lex.l"
-{return FALSE;}
+{return TRUE;}
 	YY_BREAK
 	YY_BREAK
 case 57:
 case 57:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 83 "gwarf_lex.l"
 #line 83 "gwarf_lex.l"
-{return TRUE;}
+{return FALSE;}
 	YY_BREAK
 	YY_BREAK
 case 58:
 case 58:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 84 "gwarf_lex.l"
 #line 84 "gwarf_lex.l"
-{return FALSE;}
+{return TRUE;}
 	YY_BREAK
 	YY_BREAK
 case 59:
 case 59:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 85 "gwarf_lex.l"
 #line 85 "gwarf_lex.l"
-{return NULL_token;}
+{return FALSE;}
 	YY_BREAK
 	YY_BREAK
 case 60:
 case 60:
 YY_RULE_SETUP
 YY_RULE_SETUP
@@ -1198,75 +1198,75 @@ YY_RULE_SETUP
 case 62:
 case 62:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 88 "gwarf_lex.l"
 #line 88 "gwarf_lex.l"
-{return DEF;}
+{return NULL_token;}
 	YY_BREAK
 	YY_BREAK
 case 63:
 case 63:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 89 "gwarf_lex.l"
 #line 89 "gwarf_lex.l"
-{return RETURN;}
+{return DEF;}
 	YY_BREAK
 	YY_BREAK
 case 64:
 case 64:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 90 "gwarf_lex.l"
 #line 90 "gwarf_lex.l"
-{return CLASS;}
+{return RETURN;}
 	YY_BREAK
 	YY_BREAK
 case 65:
 case 65:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 91 "gwarf_lex.l"
 #line 91 "gwarf_lex.l"
-{return POINT;}
+{return CLASS;}
 	YY_BREAK
 	YY_BREAK
 case 66:
 case 66:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 93 "gwarf_lex.l"
+#line 92 "gwarf_lex.l"
+{return POINT;}
+	YY_BREAK
+case 67:
+YY_RULE_SETUP
+#line 94 "gwarf_lex.l"
 {
 {
     yylval.double_value = atof(yytext);
     yylval.double_value = atof(yytext);
     return NUMBER;
     return NUMBER;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 67:
+case 68:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 97 "gwarf_lex.l"
+#line 98 "gwarf_lex.l"
 {
 {
     yylval.double_value = atof(yytext);
     yylval.double_value = atof(yytext);
     return INT;
     return INT;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 68:
+case 69:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 101 "gwarf_lex.l"
+#line 102 "gwarf_lex.l"
 {
 {
     yylval.string_value = yytext;
     yylval.string_value = yytext;
     return VAR;
     return VAR;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 69:
-/* rule 69 can match eol */
-YY_RULE_SETUP
-#line 105 "gwarf_lex.l"
-{return STOPN;}
-	YY_BREAK
 case 70:
 case 70:
+/* rule 70 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 106 "gwarf_lex.l"
 #line 106 "gwarf_lex.l"
-{return STOPF;}
+{return STOPN;}
 	YY_BREAK
 	YY_BREAK
 case 71:
 case 71:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 107 "gwarf_lex.l"
 #line 107 "gwarf_lex.l"
-;
+{return STOPF;}
 	YY_BREAK
 	YY_BREAK
 case 72:
 case 72:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 108 "gwarf_lex.l"
 #line 108 "gwarf_lex.l"
-{printf("other text = [%s];\n", yytext);}
+;
 	YY_BREAK
 	YY_BREAK
 case 73:
 case 73:
-/* rule 73 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 110 "gwarf_lex.l"
-{BEGIN INITIAL;}
+#line 109 "gwarf_lex.l"
+{printf("other text = [%s];\n", yytext);}
 	YY_BREAK
 	YY_BREAK
 case 74:
 case 74:
+/* rule 74 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 111 "gwarf_lex.l"
 #line 111 "gwarf_lex.l"
 {BEGIN INITIAL;}
 {BEGIN INITIAL;}
@@ -1274,12 +1274,12 @@ YY_RULE_SETUP
 case 75:
 case 75:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 112 "gwarf_lex.l"
 #line 112 "gwarf_lex.l"
-;
+{BEGIN INITIAL;}
 	YY_BREAK
 	YY_BREAK
 case 76:
 case 76:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 114 "gwarf_lex.l"
-{BEGIN INITIAL;}
+#line 113 "gwarf_lex.l"
+;
 	YY_BREAK
 	YY_BREAK
 case 77:
 case 77:
 YY_RULE_SETUP
 YY_RULE_SETUP
@@ -1287,28 +1287,33 @@ YY_RULE_SETUP
 {BEGIN INITIAL;}
 {BEGIN INITIAL;}
 	YY_BREAK
 	YY_BREAK
 case 78:
 case 78:
-/* rule 78 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 116 "gwarf_lex.l"
 #line 116 "gwarf_lex.l"
+{BEGIN INITIAL;}
+	YY_BREAK
+case 79:
+/* rule 79 can match eol */
+YY_RULE_SETUP
+#line 117 "gwarf_lex.l"
 {
 {
     yylval.string_value = yytext;
     yylval.string_value = yytext;
     return STRING;
     return STRING;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 79:
+case 80:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 120 "gwarf_lex.l"
+#line 121 "gwarf_lex.l"
 {
 {
     yylval.string_value = yytext;
     yylval.string_value = yytext;
     return STRING;
     return STRING;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 80:
+case 81:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 124 "gwarf_lex.l"
+#line 125 "gwarf_lex.l"
 ECHO;
 ECHO;
 	YY_BREAK
 	YY_BREAK
-#line 1311 "lex.yy.c"
+#line 1316 "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):
@@ -2319,7 +2324,7 @@ void yyfree (void * ptr )
 
 
 #define YYTABLES_NAME "yytables"
 #define YYTABLES_NAME "yytables"
 
 
-#line 124 "gwarf_lex.l"
+#line 125 "gwarf_lex.l"
 
 
 int yywrap(void) {
 int yywrap(void) {
     return 1;
     return 1;

File diff suppressed because it is too large
+ 266 - 258
paser/y.tab.c


+ 4 - 2
paser/y.tab.h

@@ -108,7 +108,8 @@ extern int yydebug;
     RAISE = 314,
     RAISE = 314,
     THROW = 315,
     THROW = 315,
     IMPORT = 316,
     IMPORT = 316,
-    INCLUDE = 317
+    INCLUDE = 317,
+    IN = 318
   };
   };
 #endif
 #endif
 /* Tokens.  */
 /* Tokens.  */
@@ -172,6 +173,7 @@ extern int yydebug;
 #define THROW 315
 #define THROW 315
 #define IMPORT 316
 #define IMPORT 316
 #define INCLUDE 317
 #define INCLUDE 317
+#define IN 318
 
 
 /* Value type.  */
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@@ -186,7 +188,7 @@ union YYSTYPE
     struct if_list *if_list_base;
     struct if_list *if_list_base;
     struct parameter *parameter_list;
     struct parameter *parameter_list;
 
 
-#line 190 "y.tab.h"
+#line 192 "y.tab.h"
 
 
 };
 };
 typedef union YYSTYPE YYSTYPE;
 typedef union YYSTYPE YYSTYPE;

Some files were not shown because too many files changed in this diff