Browse Source

增加了面向对象的基础功能

SongZihuan 5 năm trước cách đây
mục cha
commit
cac444a65e

+ 2 - 1
.vscode/settings.json

@@ -31,6 +31,7 @@
         "streambuf": "c",
         "streambuf": "c",
         "interprete.h": "c",
         "interprete.h": "c",
         "mutex": "c",
         "mutex": "c",
-        "cmath": "c"
+        "cmath": "c",
+        "string_view": "c"
     }
     }
 }
 }

BIN
gwarf


+ 35 - 5
gwarf_interpreter/interprete.h

@@ -2,14 +2,25 @@
 #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)
 
 
-// the func
 typedef struct func{
 typedef struct func{
-    char *name;
     struct parameter *parameter_list;  // def parameter
     struct parameter *parameter_list;  // def parameter
     struct statement *done;  // def to do
     struct statement *done;  // def to do
+    struct var_list *the_var;  // func会记录the_var,因为不同地方调用var如果var链不统一那就会很乱
+    int is_class; 
 } func;
 } func;
 
 
+typedef struct class_object{
+    struct var_list *out_var;  // 外部the_var list
+    struct var_list *the_var;  // 记录class_object的  -- 相当与cls
+} class_object;
+
+typedef struct the_object{
+    struct var_list *cls;  // 记录class_object的  -- 相当与cls
+    struct var_list *the_var;  // 记录class_object的实例  -- 相当与self
+} the_object;
+
 // the type of data(GWARF_value)
 // the type of data(GWARF_value)
 typedef enum{
 typedef enum{
     NUMBER_value = 1,
     NUMBER_value = 1,
@@ -18,6 +29,8 @@ typedef enum{
     STRING_value,  // char *
     STRING_value,  // char *
     NULL_value,
     NULL_value,
     FUNC_value,
     FUNC_value,
+    CLASS_value,
+    OBJECT_value,
 } GWARF_value_type;
 } GWARF_value_type;
 
 
 // all value is GWARF_value
 // all value is GWARF_value
@@ -30,6 +43,8 @@ typedef struct GWARF_value{
         bool bool_value;
         bool bool_value;
         char *string;  // STRING
         char *string;  // STRING
         func *func_value;
         func *func_value;
+        class_object *class_value;
+        the_object *object_value;
     } value;
     } value;
 } GWARF_value;
 } GWARF_value;
 
 
@@ -57,7 +72,7 @@ typedef struct statement{
     enum statement_type{
     enum statement_type{
         start=1,  // for base statement
         start=1,  // for base statement
         operation,  // such as + - * /
         operation,  // such as + - * /
-        base_var,  // return var address
+        base_var,  // return var value by name
         base_value,  // return an number or number
         base_value,  // return an number or number
         while_cycle,  // while
         while_cycle,  // while
         for_cycle,
         for_cycle,
@@ -76,7 +91,9 @@ typedef struct statement{
         code_block,
         code_block,
         def,  // func
         def,  // func
         call,  // func()
         call,  // func()
+        point,  // a.b  注:返回变量同时返回the_var链表[func 用于回调]
         return_code,
         return_code,
+        set_class,  // class aaa; b = aaa() is ```call```
     } type;  // the statement type
     } type;  // the statement type
 
 
     union
     union
@@ -124,6 +141,11 @@ typedef struct statement{
             struct statement *from;  // from where [double->int]
             struct statement *from;  // from where [double->int]
         } base_var;
         } base_var;
 
 
+        struct{
+            struct statement *base_var;  // a.b --> a
+            struct statement *child_var;  // a.b --> b
+        } point;
+
         struct{
         struct{
             GWARF_value value;  // return value
             GWARF_value value;  // return value
         } base_value;
         } base_value;
@@ -172,7 +194,7 @@ typedef struct statement{
         } set_nonlocal;
         } set_nonlocal;
 
 
         struct{
         struct{
-            struct statement *done;  // while to do
+            struct statement *done;  // block to do
         } code_block;
         } code_block;
 
 
         struct{
         struct{
@@ -190,6 +212,12 @@ typedef struct statement{
             struct statement *times;  // 层数
             struct statement *times;  // 层数
             struct statement *value;  // return value
             struct statement *value;  // return value
         } return_code;
         } return_code;
+
+        struct{
+            char *name;  // class name
+            struct statement *done;  // class to do
+        } set_class;
+
     } code;
     } code;
     struct statement *next;
     struct statement *next;
 } statement;
 } statement;
@@ -198,6 +226,7 @@ typedef struct statement{
 
 
 typedef struct GWARF_result{
 typedef struct GWARF_result{
     GWARF_value value;
     GWARF_value value;
+    GWARF_value *father;  // a.b --> a
     enum{
     enum{
         return_def=1,
         return_def=1,
         statement_end,
         statement_end,
@@ -215,7 +244,7 @@ typedef struct GWARF_result{
     int return_times;  // return用
     int return_times;  // return用
 } GWARF_result;
 } GWARF_result;
 
 
-// ------------------------- default_var [记录默认变量[层]]
+// ------------------------- default_var [记录默认变量[层]] 用于default语句
 typedef struct default_var{
 typedef struct default_var{
     char *name;
     char *name;
     int from;
     int from;
@@ -301,6 +330,7 @@ void append_parameter_name(char *, parameter *);
 // ---- parameter func[实参]
 // ---- parameter func[实参]
 parameter *make_parameter_value(statement *);
 parameter *make_parameter_value(statement *);
 void append_parameter_value(statement *, parameter *);
 void append_parameter_value(statement *, parameter *);
+parameter *add_parameter_value(statement *, parameter *);
 
 
 // main
 // main
 inter *global_inter;
 inter *global_inter;

+ 194 - 60
gwarf_interpreter/interpreter.c

@@ -5,7 +5,7 @@
 
 
 // running code
 // running code
 GWARF_result while_func(statement *, var_list *);
 GWARF_result while_func(statement *, var_list *);
-GWARF_result operation_func(statement *, var_list *);
+GWARF_result operation_func(statement *, var_list *, 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 *);
 GWARF_result mul_func(GWARF_result, GWARF_result, var_list *);
 GWARF_result mul_func(GWARF_result, GWARF_result, var_list *);
@@ -19,7 +19,11 @@ GWARF_result if_func(if_list *, var_list *);
 GWARF_result for_func(statement *, var_list *);
 GWARF_result for_func(statement *, var_list *);
 GWARF_result negative_func(GWARF_result, var_list *);
 GWARF_result negative_func(GWARF_result, var_list *);
 GWARF_result call_back(statement *, var_list *);
 GWARF_result call_back(statement *, var_list *);
+
 int get_var_list_len(var_list *);
 int get_var_list_len(var_list *);
+var_list *copy_var_list(var_list *);
+var_list * append_by_var_list(var_list *, var_list *);
+
 GWARF_result block_func(statement *, var_list *);
 GWARF_result block_func(statement *, var_list *);
 
 
 // math
 // math
@@ -100,6 +104,12 @@ 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 *new_tmp = make_parameter_value(value);
+    new_tmp->next = parameter_base;
+    return new_tmp;
+}
+
 // ---- var func
 // ---- var func
 
 
 var *make_var(){  // make var with base
 var *make_var(){  // make var with base
@@ -199,7 +209,6 @@ void append_default_var_base(char *name ,int from, default_var *base_default_var
     default_var *start = base_default_var;
     default_var *start = base_default_var;
     while(1){
     while(1){
         if (!strcmp(start->name, name)){  // if tmp->name == name , strcmp will return 0, if not strcmp return not 0
         if (!strcmp(start->name, name)){  // if tmp->name == name , strcmp will return 0, if not strcmp return not 0
-            puts("SECOND");
             return;  // 不可以二次设置
             return;  // 不可以二次设置
         }
         }
         if (start->next == NULL){  // not var name *name
         if (start->next == NULL){  // not var name *name
@@ -274,6 +283,18 @@ var_list *append_var_list(var *var_base, var_list *var_list_base){  // make var_
     return tmp;
     return tmp;
 }
 }
 
 
+var_list *append_by_var_list(var_list *back_var_list, var_list *var_list_base){  // make var_list[FILO]
+    var_list *start = back_var_list;
+    while(1){
+        if(start->next == NULL){  // to the last
+            break;
+        }
+        start = start->next;
+    }
+    start->next = var_list_base;
+    return back_var_list;
+}
+
 var_list *free_var_list(var_list *var_list_base){  // free one var_list[FILO]
 var_list *free_var_list(var_list *var_list_base){  // free one var_list[FILO]
     var_list *tmp = var_list_base->next;
     var_list *tmp = var_list_base->next;
     if(tmp==NULL){
     if(tmp==NULL){
@@ -300,14 +321,13 @@ var *find_var(var_list *var_base,int from, char *name){  // find var by func get
     var_list *start = var_base;
     var_list *start = var_base;
     var *return_var;
     var *return_var;
     from += get_default(name, var_base->default_list);
     from += get_default(name, var_base->default_list);
-    printf("find from = %d\n", from);
     for(int i = 0;i < from;i+= 1){
     for(int i = 0;i < from;i+= 1){
         if(start->next == NULL){
         if(start->next == NULL){
             break;
             break;
         }
         }
         start = start->next;
         start = start->next;
     }
     }
-    printf("----find address = %d----\n", start);
+    printf("----var find address = %d----\n", start);
     while (1)
     while (1)
     {
     {
         return_var = get_var(name, start->var_base);
         return_var = get_var(name, start->var_base);
@@ -325,19 +345,34 @@ var *find_var(var_list *var_base,int from, char *name){  // find var by func get
 void add_var(var_list *var_base,int from, char *name, GWARF_value value){  // add var by func append_var in var_list[iter to find]
 void add_var(var_list *var_base,int from, char *name, GWARF_value value){  // add var by func append_var in var_list[iter to find]
     var_list *start = var_base;
     var_list *start = var_base;
     var *return_var;
     var *return_var;
-    printf("base from = %d\n", from);
     from += get_default(name, var_base->default_list);
     from += get_default(name, var_base->default_list);
-    printf("add from = %d\n", from);
     for(int i = 0;i < from;i+= 1){
     for(int i = 0;i < from;i+= 1){
         if(start->next == NULL){
         if(start->next == NULL){
             break;
             break;
         }
         }
         start = start->next;
         start = start->next;
     }
     }
-    printf("----add address = %d----\n", start);
+    printf("----var add address = %d----\n", start);
     append_var(name, value, start->var_base);
     append_var(name, value, start->var_base);
 }
 }
 
 
+var_list *copy_var_list(var_list *var_list_base){  // 复制一条var链到另一个内存地址上[base不复制]
+    var_list *start = malloc(sizeof(var_list_base)), *tmp;
+    memcpy(start, var_list_base, sizeof(var_list_base));  // 复制base节点
+    tmp = start;  // 记录base节点
+    while(1){  // 复制var_list链
+        if((start == NULL) || (start->next == NULL)){
+            break;
+        }
+        puts("F1");
+        var_list *next_tmp = malloc(sizeof(start->next));
+        memcpy(next_tmp, start->next, sizeof(start->next));  // 复制到新的地方
+        start->next = next_tmp;  // 应用新的地方
+        start = start->next;
+    }
+    return tmp;
+}
+
 // ---- statement_list
 // ---- statement_list
 statement_list *make_statement_list(){  // make a empty var_list node
 statement_list *make_statement_list(){  // make a empty var_list node
     statement_list *tmp;
     statement_list *tmp;
@@ -411,7 +446,10 @@ if_list *append_elif(if_list *tmp ,if_list *base_if_list){  // elif
 
 
 // ---- run code
 // ---- run code
 
 
-GWARF_result read_statement_list(statement *the_statement, var_list *the_var){  // read the statement list with case to run by func
+GWARF_result read_statement(statement *the_statement, var_list *the_var, var_list *login_var){  // read the statement list with case to run by func
+    if(login_var == NULL){
+        login_var = the_var;
+    }
     GWARF_result return_value;
     GWARF_result return_value;
     return_value.u = statement_end;  // 正常设置[正常语句结束]
     return_value.u = statement_end;  // 正常设置[正常语句结束]
     return_value.value.type = NUMBER_value;  // 默认设置
     return_value.value.type = NUMBER_value;  // 默认设置
@@ -420,7 +458,7 @@ GWARF_result read_statement_list(statement *the_statement, var_list *the_var){
     {
     {
         case operation:  // 表达式运算
         case operation:  // 表达式运算
             puts("----code----");
             puts("----code----");
-            return_value = operation_func(the_statement, the_var);
+            return_value = operation_func(the_statement, the_var, login_var);
             if((return_value.value.type == INT_value)){
             if((return_value.value.type == INT_value)){
                 printf("operation value = %d\n", return_value.value.value.int_value);
                 printf("operation value = %d\n", return_value.value.value.int_value);
             }
             }
@@ -473,14 +511,14 @@ GWARF_result read_statement_list(statement *the_statement, var_list *the_var){
                 printf("get value = %f\n", return_value.value.value.double_value);
                 printf("get value = %f\n", return_value.value.value.double_value);
             }
             }
             else if(return_value.value.type == NULL_value){
             else if(return_value.value.type == NULL_value){
-                printf("operation value = None\n");
+                printf("get value = None\n");
             }
             }
             else if(return_value.value.type == STRING_value){
             else if(return_value.value.type == STRING_value){
                 printf("get value = %s\n", return_value.value.value.string);
                 printf("get value = %s\n", return_value.value.value.string);
             }
             }
             else{
             else{
-                    printf("var value = other\n");
-                }
+                printf("get value = other\n");
+            }
             break;
             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;
@@ -504,28 +542,76 @@ GWARF_result read_statement_list(statement *the_statement, var_list *the_var){
                     printf("var value = %f\n", return_value.value.value.double_value);
                     printf("var value = %f\n", return_value.value.value.double_value);
                 }
                 }
                 else if(return_value.value.type == NULL_value){
                 else if(return_value.value.type == NULL_value){
-                    printf("operation value = None\n");
+                    printf("var value = None\n");
                 }
                 }
                 else if(return_value.value.type == STRING_value){
                 else if(return_value.value.type == STRING_value){
                     printf("var value = %s\n", return_value.value.value.string);
                     printf("var value = %s\n", return_value.value.value.string);
                 }
                 }
                 else{
                 else{
-                    printf("var value = other\n");
+                    printf("var value = other[%d]\n", return_value.value.type);
                 }
                 }
             }
             }
             break;
             break;
         }
         }
+        case point:{
+            puts("----point----");
+            GWARF_value base_the_var = traverse((the_statement->code).point.base_var, the_var, false).value;
+            if(base_the_var.type == CLASS_value){  // is class so that can use "."
+                puts("func: point");
+                return_value = traverse((the_statement->code).point.child_var, base_the_var.value.class_value->the_var, false);
+            }
+            else if(base_the_var.type == OBJECT_value){
+                puts("func: point");
+                return_value = traverse((the_statement->code).point.child_var, base_the_var.value.object_value->the_var, false);
+            }
+            return_value.father = malloc(sizeof(return_value.father));  // 记录father的值
+            *(return_value.father) = base_the_var;
+            puts("----stop point----");
+            break;
+        }
         case def:{
         case def:{
             GWARF_result func_value;
             GWARF_result func_value;
             func *func_tmp = malloc(sizeof(func));
             func *func_tmp = malloc(sizeof(func));
 
 
             func_tmp->done = the_statement->code.def.done;
             func_tmp->done = the_statement->code.def.done;
             func_tmp->parameter_list = the_statement->code.def.parameter_list;
             func_tmp->parameter_list = the_statement->code.def.parameter_list;
+            func_tmp->the_var = copy_var_list(the_var);
+            if(login_var != the_var){  // 定义为类方法
+                func_tmp->is_class = 1;
+            }
+            else{
+                func_tmp->is_class = 0;
+            }
 
 
             func_value.value.type = FUNC_value;
             func_value.value.type = FUNC_value;
             func_value.value.value.func_value = func_tmp;
             func_value.value.value.func_value = func_tmp;
 
 
-            assigment_func(the_statement->code.def.name, func_value, the_var, 0);
+            assigment_func(the_statement->code.def.name, func_value, login_var, 0);  // 注册函数到指定的位置
+            break;
+        }
+        case set_class:{
+            puts("----set class----");
+            GWARF_result class_value;
+            class_object *class_tmp = malloc(sizeof(class_object));
+
+            class_tmp->the_var = make_var_base(make_var());  // make class var list
+            class_tmp->out_var = append_by_var_list(class_tmp->the_var, copy_var_list(the_var));  // make class var list with out var
+            class_value.value.type = CLASS_value;
+            class_value.value.value.class_value = class_tmp;
+
+            statement *tmp = the_statement->code.set_class.done;
+            GWARF_result result;
+            while(1){
+                if(tmp == NULL){
+                    break;  // off
+                }
+                read_statement(tmp, the_var, class_tmp->the_var);
+                tmp = tmp->next;
+            }
+
+            assigment_func(the_statement->code.set_class.name, class_value, login_var, 0);  // 注册class 的 位置
+            puts("----stop set class----");
+            break;
         }
         }
         case break_cycle:
         case break_cycle:
             return_value.u = cycle_break;
             return_value.u = cycle_break;
@@ -1000,7 +1086,7 @@ GWARF_result while_func(statement *the_statement, var_list *the_var){  // read t
 
 
 // -----------------operation func
 // -----------------operation func
 
 
-GWARF_result operation_func(statement *the_statement, var_list *the_var){  // read the statement list with case to run by func
+GWARF_result operation_func(statement *the_statement, var_list *the_var, var_list *login_var){  // read the statement list with case to run by func
     GWARF_result value, left_result, right_result;
     GWARF_result value, left_result, right_result;
     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]
@@ -1025,21 +1111,53 @@ GWARF_result operation_func(statement *the_statement, var_list *the_var){  // re
             value = negative_func(right_result, the_var);
             value = negative_func(right_result, the_var);
             break;
             break;
         case ASSIGMENT_func:{  // because the var char, we should ues a {} to make a block[name space] for the tmp var;
         case ASSIGMENT_func:{  // because the var char, we should ues a {} to make a block[name space] for the tmp var;
-            char *left = (the_statement->code.operation.left_exp)->code.base_var.var_name;  // get var name but not value
-            int from = 0;
-            if((the_statement->code.operation.left_exp)->code.base_var.from == NULL){
-                from = 0;
+            if((the_statement->code.operation.left_exp)->type == base_var){  // 通过base_var赋值
+                char *left = (the_statement->code.operation.left_exp)->code.base_var.var_name;  // get var name but not value
+                int from = 0;
+                if((the_statement->code.operation.left_exp)->code.base_var.from == NULL){
+                    from = 0;
+                }
+                else{
+                    GWARF_result tmp_result = traverse((the_statement->code.operation.left_exp)->code.base_var.from, the_var, false);
+                    if(tmp_result.value.type = INT_value){
+                        from = tmp_result.value.value.int_value;
+                    }
+                    else{
+                        from = (int)tmp_result.value.value.double_value;
+                    }
+                }
+                value = assigment_func(left, right_result, login_var, from);
             }
             }
-            else{
-                GWARF_result tmp_result = traverse((the_statement->code.operation.left_exp)->code.base_var.from, the_var, false);
-                if(tmp_result.value.type = INT_value){
-                    from = tmp_result.value.value.int_value;
+            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_value base_the_var = traverse((the_statement->code.operation.left_exp)->code.point.base_var, the_var, false).value;
+                if(((the_statement->code.operation.left_exp)->code.point.child_var)->type == base_var){
+                    char *left = ((the_statement->code.operation.left_exp)->code.point.child_var)->code.base_var.var_name;
+                    int from = 0;
+                    if(((the_statement->code.operation.left_exp)->code.point.child_var)->code.base_var.from == NULL){
+                        from = 0;
+                    }
+                    else{
+                        GWARF_result tmp_result = traverse(((the_statement->code.operation.left_exp)->code.point.child_var)->code.base_var.from, the_var, false);
+                        if(tmp_result.value.type = INT_value){
+                            from = tmp_result.value.value.int_value;
+                        }
+                        else{
+                            from = (int)tmp_result.value.value.double_value;
+                        }
+                    }
+                    value = assigment_func(left, right_result, base_the_var.value.object_value->the_var, from);
                 }
                 }
                 else{
                 else{
-                    from = (int)tmp_result.value.value.double_value;
+                    puts("Bad assigment");
+                    goto the_else;
                 }
                 }
             }
             }
-            value = assigment_func(left, right_result, the_var, from);
+            else{  // 若不是变量[或者切片、成员访问]则当作==处理 ...... 这种处理不是期望的
+                the_else: 
+                left_result = traverse((*the_statement).code.operation.left_exp, the_var, false);
+                value = equal_func(left_result, right_result, the_var, 0);
+            }
             break;
             break;
         }
         }
         case EQUAL_func:
         case EQUAL_func:
@@ -1078,46 +1196,62 @@ GWARF_result operation_func(statement *the_statement, var_list *the_var){  // re
 
 
 GWARF_result call_back(statement *the_statement, var_list *the_var){  // the func for add and call from read_statement_list
 GWARF_result call_back(statement *the_statement, var_list *the_var){  // the func for add and call from read_statement_list
     GWARF_result result, get = traverse(the_statement->code.call.func, the_var, false);
     GWARF_result result, get = traverse(the_statement->code.call.func, the_var, false);
-    if(get.value.type != FUNC_value){
-        goto return_result;
-    }
-
-    func *func_ = get.value.value.func_value;
-    parameter *tmp_x = func_->parameter_list, *tmp_s = the_statement->code.call.parameter_list;
-    // tmp_x:形参,tmp_s:实参
+    if(get.value.type == FUNC_value){
+        func *func_ = get.value.value.func_value;
+        parameter *tmp_x = func_->parameter_list, *tmp_s = the_statement->code.call.parameter_list;
+        the_var = func_->the_var;
+        // tmp_x:形参,tmp_s:实参
 
 
-    printf("----address = %d----\n", the_var);
-    var *tmp = make_var();  // base_var
-    the_var = append_var_list(tmp, the_var);
-    printf("----new address = %d----\n", the_var);
+        printf("----address = %d----\n", the_var);
+        var *tmp = make_var();  // base_var
+        the_var = append_var_list(tmp, the_var);
+        printf("----new address = %d----\n", the_var);
 
 
-    if(tmp_x == NULL){
-        puts("No tmp_x");
-        goto no_tmp_x;  // 无形参
-    }
-    while(1){
-        GWARF_result tmp = traverse(tmp_s->u.value, the_var, false);
-        assigment_func(tmp_x->u.name, tmp, the_var, 0);
-        puts("set func var: tmp_x->u.name");
-        if ((tmp_x->next == NULL)||(tmp_s->next == NULL)){  // the last
-            break;
+        if(tmp_x == NULL){
+            puts("No tmp_x");
+            goto no_tmp_x;  // 无形参
         }
         }
-        tmp_x = tmp_x->next;  // get the next to iter
-        tmp_s = tmp_s->next;
-    }
-    no_tmp_x: 
-    puts("run func");
-    result = traverse(func_->done, the_var, false);  // 执行func_value->done
-    the_var = free_var_list(the_var);  // free the new var
-    if(result.u == code_return){
-        if(result.return_times <= 0){
-            result.u = return_def;
+        GWARF_result father;
+        father.value = *(get.father);
+        if(func_->is_class  == 1){
+            assigment_func(tmp_x->u.name, father, the_var, 0);
+            if (tmp_x->next == NULL){  // the last
+                goto no_tmp_x;
+            }
+            tmp_x = tmp_x->next;  // get the next to iter
         }
         }
-        else{
-           result.return_times -= 1; 
+        while(1){
+            GWARF_result tmp = traverse(tmp_s->u.value, the_var, false);
+            assigment_func(tmp_x->u.name, tmp, the_var, 0);
+            if ((tmp_x->next == NULL)||(tmp_s->next == NULL)){  // the last
+                break;
+            }
+            tmp_x = tmp_x->next;  // get the next to iter
+            tmp_s = tmp_s->next;
         }
         }
+        no_tmp_x: 
+        puts("----start func----");
+        result = traverse(func_->done, the_var, false);  // 执行func_value->done
+        the_var = free_var_list(the_var);  // free the new var
+        if(result.u == code_return){
+            if(result.return_times <= 0){
+                result.u = return_def;
+            }
+            else{
+            result.return_times -= 1; 
+            }
+        }
+        puts("----stop start func----");
     }
     }
-    return_result: return result;
+    else if(get.value.type == CLASS_value){  // 生成实例
+        the_object *object_tmp = malloc(sizeof(the_object));  // 生成object的空间
+        object_tmp->cls = get.value.value.class_value->the_var;
+        object_tmp->the_var = append_by_var_list(make_var_base(make_var()), object_tmp->cls);
+        GWARF_value tmp;
+        tmp.type = OBJECT_value;
+        tmp.value.object_value = object_tmp;
+    }
+    return result;
 }
 }
 
 
 // ---------  ADD
 // ---------  ADD

+ 2 - 0
paser/gwarf_lex.l

@@ -78,6 +78,8 @@
 <INITIAL>"null" {return NULL_token;}
 <INITIAL>"null" {return NULL_token;}
 <INITIAL>"def" {return DEF;}
 <INITIAL>"def" {return DEF;}
 <INITIAL>"return" {return RETURN;}
 <INITIAL>"return" {return RETURN;}
+<INITIAL>"class" {return CLASS;}
+<INITIAL>"." {return POINT;}
 
 
 <INITIAL>[1-9][0-9]*\.[0-9]+ {
 <INITIAL>[1-9][0-9]*\.[0-9]+ {
     yylval.double_value = atof(yytext);
     yylval.double_value = atof(yytext);

+ 47 - 3
paser/gwarf_yacc.y

@@ -18,9 +18,10 @@
 %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
+%token NULL_token DEF RETURN CLASS POINT
 %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 <parameter_list> formal_parameter arguments
 %type <string_value> base_string
 %type <string_value> base_string
 %type <if_list_base> elif_exp
 %type <if_list_base> elif_exp
@@ -123,14 +124,22 @@ command
     {
     {
         $$ = $1;
         $$ = $1;
     }
     }
+    | class_block stop_token
+    {
+        $$ = $1;
+    }
     ;
     ;
 
 
 top_exp
 top_exp
-    : third_number
+    : eq_number
     {
     {
         $$ = $1;
         $$ = $1;
     }
     }
-    | base_var_ EQ top_exp
+    ;
+
+eq_number
+    : third_number
+    | eq_number EQ third_number
     {
     {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
         code_tmp->type = operation;
@@ -306,6 +315,14 @@ element
         code_tmp->code.operation.right_exp = $2;
         code_tmp->code.operation.right_exp = $2;
         $$ = code_tmp;
         $$ = code_tmp;
     }
     }
+    | element POINT element
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = point;
+        code_tmp->code.point.base_var = $1;
+        code_tmp->code.point.child_var = $3;
+        $$ = code_tmp; 
+    }
     | LB top_exp RB
     | LB top_exp RB
     {
     {
         $$ = $2;
         $$ = $2;
@@ -619,6 +636,33 @@ while_exp
     }
     }
     ;
     ;
 
 
+class_block
+    : class_exp block
+    {
+        statement_base = free_statement_list(statement_base);  // new statement_base (FILO)
+    }
+    ;
+
+class_exp
+    : CLASS  base_var_ LB RB
+    {   
+        //无参数方法
+        statement *class_tmp =  make_statement();
+        class_tmp->type = set_class;
+
+        class_tmp->code.set_class.name = malloc(sizeof($2->code.base_var.var_name));
+        char *name_tmp = class_tmp->code.set_class.name;
+        strcpy(name_tmp, $2->code.base_var.var_name);
+
+        class_tmp->code.set_class.done = make_statement();
+        statement_base = append_statement_list(class_tmp->code.set_class.done, statement_base);  // new statement_base (FILO)
+
+        free($2->code.base_var.var_name);
+        free($2);
+        $$ = class_tmp;
+    }
+    ;
+
 def_block
 def_block
     : def_exp block
     : def_exp block
     {
     {

+ 174 - 162
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 70
-#define YY_END_OF_BUFFER 71
+#define YY_NUM_RULES 72
+#define YY_END_OF_BUFFER 73
 /* 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,28 +360,30 @@ 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[190] =
+static const flex_int16_t yy_accept[195] =
     {   0,
     {   0,
-        0,    0,    0,    0,    0,    0,    0,    0,   71,   62,
-       59,   61,   62,   46,   44,   45,   22,   23,   40,   38,
-       17,   39,   41,   57,   57,   60,   30,   32,   29,   58,
-       58,   58,   58,   42,   43,   34,   58,   58,   58,   58,
-       58,   58,   58,   58,   58,   58,   58,   58,   58,   24,
-       25,   35,   61,   65,   63,   64,   69,   68,   67,   66,
-       70,    0,    0,    0,   24,    0,   28,   33,    0,   57,
-       27,   31,   26,   58,   58,   58,   58,   58,   58,   58,
-       58,   58,   58,   58,   58,   58,    5,   58,   58,   58,
-       58,   58,   58,   58,   24,    0,    0,    0,    0,   56,
-
-       58,   58,   58,   58,   58,   58,   58,   58,   54,   58,
-       58,   58,   16,   58,   36,   58,   58,   58,   58,   58,
-       58,   58,   58,   58,    0,    0,    0,    0,    3,   58,
-       52,   51,   49,   58,   58,   58,   58,   58,    6,    7,
-       58,   58,   58,   53,   14,   58,   58,   58,   37,   47,
-       58,    1,    2,    6,    7,   50,   21,    8,   58,   58,
-       58,    0,   48,   58,   58,   58,   58,   58,    4,    2,
-        9,   58,   58,    7,   19,   58,   58,   55,   15,   58,
-       18,   58,   11,   10,   20,   58,   13,   12,    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
+
     } ;
     } ;
 
 
 static const YY_CHAR yy_ec[256] =
 static const YY_CHAR yy_ec[256] =
@@ -426,122 +428,122 @@ static const YY_CHAR yy_meta[53] =
         1,    1
         1,    1
     } ;
     } ;
 
 
-static const flex_int16_t yy_base[194] =
+static const flex_int16_t yy_base[199] =
     {   0,
     {   0,
-        0,  209,   51,   52,   54,   58,    0,    0,  211,  213,
-       64,  207,  189,  213,  213,  213,  213,  213,  198,  213,
-      213,  213,  213,  213,   54,  213,  187,  186,  185,    0,
-      173,   35,  158,  213,  213,  213,   28,  159,  166,  159,
-       33,  158,  162,  154,   29,  161,  151,  149,  155,  190,
-      213,  213,  188,  213,  213,  213,  213,  213,  213,  213,
-      213,   72,  187,  148,  186,  184,  213,  213,   63,   67,
-      213,  213,  213,    0,  145,  161,  142,  135,  139,   47,
-      139,  144,   46,  138,  133,  134,    0,  139,  133,  133,
-       49,  128,  124,  132,  168,  166,  165,   48,  164,   72,
-
-      120,  141,  129,  128,  129,  130,  120,  112,  127,  121,
-      121,  109,    0,  122,    0,  112,  111,  108,  103,  101,
-      113,  100,  111,  104,  141,  140,  106,  106,  213,  105,
-        0,    0,    0,   99,   98,  102,   97,   87,    0,  126,
-       98,  101,   88,    0,    0,   99,   84,   79,    0,    0,
-       85,  213,  117,  213,  110,    0,    0,    0,   75,   74,
-       74,  104,    0,   71,   78,   65,   67,   61,    0,  104,
-        0,   57,   57,  213,    0,   72,   55,    0,    0,   66,
-        0,   59,   62,   59,    0,   57,    0,    0,  213,  122,
-      124,  126,   53
+        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
 
 
     } ;
     } ;
 
 
-static const flex_int16_t yy_def[194] =
+static const flex_int16_t yy_def[199] =
     {   0,
     {   0,
-      189,    1,  190,  190,  191,  191,  192,  192,  189,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  193,
-      193,  193,  193,  189,  189,  189,  193,  193,  193,  193,
-      193,  193,  193,  193,  193,  193,  193,  193,  193,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  193,  193,  193,  193,  193,  193,  193,
-      193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
-      193,  193,  193,  193,  189,  189,  189,  189,  189,  189,
-
-      193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
-      193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
-      193,  193,  193,  193,  189,  189,  189,  189,  189,  193,
-      193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
-      193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
-      193,  189,  189,  189,  189,  193,  193,  193,  193,  193,
-      193,  189,  193,  193,  193,  193,  193,  193,  193,  189,
-      193,  193,  193,  189,  193,  193,  193,  193,  193,  193,
-      193,  193,  193,  193,  193,  193,  193,  193,    0,  189,
-      189,  189,  189
+      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
 
 
     } ;
     } ;
 
 
-static const flex_int16_t yy_nxt[266] =
+static const flex_int16_t yy_nxt[270] =
     {   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,   10,   23,   24,   25,   26,   27,   28,
-       29,   30,   31,   30,   32,   33,   30,   34,   35,   36,
-       30,   37,   38,   39,   40,   41,   42,   30,   43,   30,
-       44,   45,   30,   30,   46,   47,   48,   30,   49,   50,
-       51,   52,   55,   55,   74,   58,   56,   56,   59,   58,
-       60,   76,   59,   84,   60,   62,   63,   69,   79,   70,
-       70,   89,   80,   62,   63,   85,   90,   77,  100,  100,
-       69,  106,   70,   70,  110,  118,  127,  100,  100,  107,
-      188,  111,  187,  128,  119,  120,  186,  121,   64,  185,
-
-      184,  183,  182,  181,  180,  170,   64,  179,  178,  177,
-      176,  175,  174,   65,  173,  172,  171,  162,  170,  169,
-      168,   65,   54,   54,   57,   57,   61,   61,  167,  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,  131,  130,  129,  126,  125,   95,
-      124,  123,  122,  117,  116,  115,  114,  113,  112,  109,
-      108,  105,  104,  103,  102,  101,   99,   95,   98,   97,
-       96,   95,   94,   93,   92,   91,   88,   87,   86,   83,
-
-       82,   81,   78,   75,   73,   72,   71,   68,   67,   66,
-      189,   53,    9,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189
+       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
     } ;
     } ;
 
 
-static const flex_int16_t yy_chk[266] =
+static const flex_int16_t yy_chk[270] =
     {   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,  193,    5,    3,    4,    5,    6,
-        5,   32,    6,   41,    6,   11,   11,   25,   37,   25,
-       25,   45,   37,   62,   62,   41,   45,   32,   69,   69,
-       70,   80,   70,   70,   83,   91,   98,  100,  100,   80,
-      186,   83,  184,   98,   91,   91,  183,   91,   11,  182,
-
-      180,  177,  176,  173,  172,  170,   62,  168,  167,  166,
-      165,  164,  162,   11,  161,  160,  159,  155,  153,  151,
-      148,   62,  190,  190,  191,  191,  192,  192,  147,  146,
-      143,  142,  141,  140,  138,  137,  136,  135,  134,  130,
-      128,  127,  126,  125,  124,  123,  122,  121,  120,  119,
-      118,  117,  116,  114,  112,  111,  110,  109,  108,  107,
-      106,  105,  104,  103,  102,  101,   99,   97,   96,   95,
-       94,   93,   92,   90,   89,   88,   86,   85,   84,   82,
-       81,   79,   78,   77,   76,   75,   66,   65,   64,   63,
-       53,   50,   49,   48,   47,   46,   44,   43,   42,   40,
-
-       39,   38,   33,   31,   29,   28,   27,   19,   13,   12,
-        9,    2,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189
+        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
     } ;
     } ;
 
 
 static yy_state_type yy_last_accepting_state;
 static yy_state_type yy_last_accepting_state;
@@ -569,10 +571,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 572 "lex.yy.c"
-
 #line 574 "lex.yy.c"
 #line 574 "lex.yy.c"
 
 
+#line 576 "lex.yy.c"
+
 #define INITIAL 0
 #define INITIAL 0
 #define COMMENT 1
 #define COMMENT 1
 #define STRING_TEXT 2
 #define STRING_TEXT 2
@@ -796,7 +798,7 @@ YY_DECL
 	{
 	{
 #line 13 "gwarf_lex.l"
 #line 13 "gwarf_lex.l"
 
 
-#line 799 "lex.yy.c"
+#line 801 "lex.yy.c"
 
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
 		{
@@ -824,13 +826,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 >= 190 )
+				if ( yy_current_state >= 195 )
 					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] != 213 );
+		while ( yy_base[yy_current_state] != 217 );
 
 
 yy_find_action:
 yy_find_action:
 		yy_act = yy_accept[yy_current_state];
 		yy_act = yy_accept[yy_current_state];
@@ -1143,98 +1145,108 @@ YY_RULE_SETUP
 	YY_BREAK
 	YY_BREAK
 case 56:
 case 56:
 YY_RULE_SETUP
 YY_RULE_SETUP
+#line 81 "gwarf_lex.l"
+{return CLASS;}
+	YY_BREAK
+case 57:
+YY_RULE_SETUP
 #line 82 "gwarf_lex.l"
 #line 82 "gwarf_lex.l"
+{return POINT;}
+	YY_BREAK
+case 58:
+YY_RULE_SETUP
+#line 84 "gwarf_lex.l"
 {
 {
     yylval.double_value = atof(yytext);
     yylval.double_value = atof(yytext);
     return NUMBER;
     return NUMBER;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 57:
+case 59:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 86 "gwarf_lex.l"
+#line 88 "gwarf_lex.l"
 {
 {
     yylval.double_value = atof(yytext);
     yylval.double_value = atof(yytext);
     return INT;
     return INT;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 58:
+case 60:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 90 "gwarf_lex.l"
+#line 92 "gwarf_lex.l"
 {
 {
     yylval.string_value = yytext;
     yylval.string_value = yytext;
     return VAR;
     return VAR;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 59:
-/* rule 59 can match eol */
-YY_RULE_SETUP
-#line 94 "gwarf_lex.l"
-{return STOPN;}
-	YY_BREAK
-case 60:
-YY_RULE_SETUP
-#line 95 "gwarf_lex.l"
-{return STOPF;}
-	YY_BREAK
 case 61:
 case 61:
+/* rule 61 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 96 "gwarf_lex.l"
 #line 96 "gwarf_lex.l"
-;
+{return STOPN;}
 	YY_BREAK
 	YY_BREAK
 case 62:
 case 62:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 97 "gwarf_lex.l"
 #line 97 "gwarf_lex.l"
-{printf("other text = [%s];\n", yytext);}
+{return STOPF;}
 	YY_BREAK
 	YY_BREAK
 case 63:
 case 63:
-/* rule 63 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 99 "gwarf_lex.l"
-{BEGIN INITIAL;}
+#line 98 "gwarf_lex.l"
+;
 	YY_BREAK
 	YY_BREAK
 case 64:
 case 64:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 100 "gwarf_lex.l"
-{BEGIN INITIAL;}
+#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"
 #line 101 "gwarf_lex.l"
-;
+{BEGIN INITIAL;}
 	YY_BREAK
 	YY_BREAK
 case 66:
 case 66:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 103 "gwarf_lex.l"
+#line 102 "gwarf_lex.l"
 {BEGIN INITIAL;}
 {BEGIN INITIAL;}
 	YY_BREAK
 	YY_BREAK
 case 67:
 case 67:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 104 "gwarf_lex.l"
-{BEGIN INITIAL;}
+#line 103 "gwarf_lex.l"
+;
 	YY_BREAK
 	YY_BREAK
 case 68:
 case 68:
-/* rule 68 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 105 "gwarf_lex.l"
 #line 105 "gwarf_lex.l"
+{BEGIN INITIAL;}
+	YY_BREAK
+case 69:
+YY_RULE_SETUP
+#line 106 "gwarf_lex.l"
+{BEGIN INITIAL;}
+	YY_BREAK
+case 70:
+/* rule 70 can match eol */
+YY_RULE_SETUP
+#line 107 "gwarf_lex.l"
 {
 {
     yylval.string_value = yytext;
     yylval.string_value = yytext;
     return STRING;
     return STRING;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 69:
+case 71:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 109 "gwarf_lex.l"
+#line 111 "gwarf_lex.l"
 {
 {
     yylval.string_value = yytext;
     yylval.string_value = yytext;
     return STRING;
     return STRING;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 70:
+case 72:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 113 "gwarf_lex.l"
+#line 115 "gwarf_lex.l"
 ECHO;
 ECHO;
 	YY_BREAK
 	YY_BREAK
-#line 1237 "lex.yy.c"
+#line 1249 "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):
@@ -1535,7 +1547,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 >= 190 )
+			if ( yy_current_state >= 195 )
 				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];
@@ -1563,11 +1575,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 >= 190 )
+		if ( yy_current_state >= 195 )
 			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 == 189);
+	yy_is_jam = (yy_current_state == 194);
 
 
 		return yy_is_jam ? 0 : yy_current_state;
 		return yy_is_jam ? 0 : yy_current_state;
 }
 }
@@ -2245,7 +2257,7 @@ void yyfree (void * ptr )
 
 
 #define YYTABLES_NAME "yytables"
 #define YYTABLES_NAME "yytables"
 
 
-#line 113 "gwarf_lex.l"
+#line 115 "gwarf_lex.l"
 
 
 int yywrap(void) {
 int yywrap(void) {
     return 1;
     return 1;

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 306 - 300
paser/y.tab.c


+ 6 - 2
paser/y.tab.h

@@ -98,7 +98,9 @@ extern int yydebug;
     TRUE = 304,
     TRUE = 304,
     NULL_token = 305,
     NULL_token = 305,
     DEF = 306,
     DEF = 306,
-    RETURN = 307
+    RETURN = 307,
+    CLASS = 308,
+    POINT = 309
   };
   };
 #endif
 #endif
 /* Tokens.  */
 /* Tokens.  */
@@ -152,6 +154,8 @@ extern int yydebug;
 #define NULL_token 305
 #define NULL_token 305
 #define DEF 306
 #define DEF 306
 #define RETURN 307
 #define RETURN 307
+#define CLASS 308
+#define POINT 309
 
 
 /* Value type.  */
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@@ -166,7 +170,7 @@ union YYSTYPE
     struct if_list *if_list_base;
     struct if_list *if_list_base;
     struct parameter *parameter_list;
     struct parameter *parameter_list;
 
 
-#line 170 "y.tab.h"
+#line 174 "y.tab.h"
 
 
 };
 };
 typedef union YYSTYPE YYSTYPE;
 typedef union YYSTYPE YYSTYPE;

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác