SongZihuan 5 gadi atpakaļ
vecāks
revīzija
a12693c9da
9 mainītis faili ar 1323 papildinājumiem un 557 dzēšanām
  1. BIN
      gwarf
  2. 179 2
      inter/cfunc.c
  3. 420 0
      inter/interpreter.c
  4. 20 0
      inter/interpreter.h
  5. 4 5
      paser/gwarf_lex.l
  6. 75 10
      paser/gwarf_yacc.y
  7. 241 220
      paser/lex.yy.c
  8. 370 318
      paser/y.tab.c
  9. 14 2
      paser/y.tab.h

BIN
gwarf


+ 179 - 2
inter/cfunc.c

@@ -388,9 +388,10 @@ class_object *gobject_login_official(var_list *the_var, GWARF_result (*paser)(fu
     puts("----stop set class----");
 
     // 注册函数
-    int a[][2] = {{2,1}, {3,1}, {4,1}, {5,1}, {6,1}, {7,1}, {8,1}, {9,1}, {10,1}, {11,1}, {12,1}, {13,1}, {14,1}, {15,1}, {16,1}, {17,1}, {3,1}, {21,1}, {22,1}, {18,1}, {19,1}, {20,1}, {29,1}, {30,1}, {31,1}, {32,1}};
+    int a[][2] = {{2,1}, {3,1}, {4,1}, {5,1}, {6,1}, {7,1}, {8,1}, {9,1}, {10,1}, {11,1}, {12,1}, {13,1}, {14,1}, {15,1}, {16,1}, {17,1}, {3,1}, {21,1}, {22,1}, {18,1}, {19,1}, {20,1}, {29,1}, {30,1}, {31,1}, {32,1},
+                  {__bitand__func,1}, {__bitor__func,1}, {__bitnotor__func,1}, {__bitright__func,1}, {__bitrightr__func,1}, {__bitleft__func,1}, {__bitleftr__func,1}, {__bitnot__func,1}};
     char *name[] = {"__init__", "__value__", "__add__", "__sub__", "__mul__","__div__","__eq__", "__more__", "__less__", "__eqmore__", "__eqless__","__noteq__", "__pow__", "__log__","__sqrt__","__negative__","__bool__","__subr__",
-                    "__divr__", "__powr__", "__logr__","__sqrtr__", "__idiv__","__idivr__", "__mod__","__modr__"};
+                    "__divr__", "__powr__", "__logr__","__sqrtr__", "__idiv__","__idivr__", "__mod__", "__modr__", "__bitand__", "__bitor__", "__bitnotor__","__bitright__", "__bitrightr__","__bitleft__", "__bitleftr__","__bitnot__"};
 
     int lenth = sizeof(a)/sizeof(a[0]);
     for(int i = 0;i < lenth;i+=1){
@@ -953,6 +954,182 @@ GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *t
             return_value = mod_func(reight_tmp, left_tmp, out_var);
             break;
         }
+
+
+        case __bitand__func:{
+            GWARF_result reight_tmp, left_tmp, tmp_result = traverse(tmp_s->u.value, out_var, false);
+            if(is_error(&tmp_result)){  // Name Error错误
+                return_value = tmp_result;
+                goto return_result;
+            }
+            else if(is_space(&tmp_result)){
+                return_value = tmp_result;
+                goto return_result;
+            }
+            GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
+            reight_tmp = get__value__(&base_the_var, the_var);
+            var *tmp = find_var(login_var, 0, "value");
+            if(tmp != NULL){
+                left_tmp.value = tmp->value;
+            }
+            else{
+                left_tmp.value.type = NULL_value;
+                left_tmp.value.value.int_value = 0;
+            }
+            return_value = bit_and_func(left_tmp, reight_tmp, out_var);
+            break;
+        }
+        case __bitor__func:{
+            GWARF_result reight_tmp, left_tmp, tmp_result = traverse(tmp_s->u.value, out_var, false);
+            if(is_error(&tmp_result)){  // Name Error错误
+                return_value = tmp_result;
+                goto return_result;
+            }
+            else if(is_space(&tmp_result)){
+                return_value = tmp_result;
+                goto return_result;
+            }
+            GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
+            reight_tmp = get__value__(&base_the_var, the_var);
+            var *tmp = find_var(login_var, 0, "value");
+            if(tmp != NULL){
+                left_tmp.value = tmp->value;
+            }
+            else{
+                left_tmp.value.type = NULL_value;
+                left_tmp.value.value.int_value = 0;
+            }
+            return_value = bit_or_func(left_tmp, reight_tmp, out_var);
+            break;
+        }
+        case __bitnotor__func:{
+            GWARF_result reight_tmp, left_tmp, tmp_result = traverse(tmp_s->u.value, out_var, false);
+            if(is_error(&tmp_result)){  // Name Error错误
+                return_value = tmp_result;
+                goto return_result;
+            }
+            else if(is_space(&tmp_result)){
+                return_value = tmp_result;
+                goto return_result;
+            }
+            GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
+            reight_tmp = get__value__(&base_the_var, the_var);
+            var *tmp = find_var(login_var, 0, "value");
+            if(tmp != NULL){
+                left_tmp.value = tmp->value;
+            }
+            else{
+                left_tmp.value.type = NULL_value;
+                left_tmp.value.value.int_value = 0;
+            }
+            return_value = bit_notor_func(left_tmp, reight_tmp, out_var);
+            break;
+        }
+        case __bitleft__func:{
+            GWARF_result reight_tmp, left_tmp, tmp_result = traverse(tmp_s->u.value, out_var, false);
+            if(is_error(&tmp_result)){  // Name Error错误
+                return_value = tmp_result;
+                goto return_result;
+            }
+            else if(is_space(&tmp_result)){
+                return_value = tmp_result;
+                goto return_result;
+            }
+            GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
+            reight_tmp = get__value__(&base_the_var, the_var);
+            var *tmp = find_var(login_var, 0, "value");
+            if(tmp != NULL){
+                left_tmp.value = tmp->value;
+            }
+            else{
+                left_tmp.value.type = NULL_value;
+                left_tmp.value.value.int_value = 0;
+            }
+            return_value = bit_left_func(left_tmp, reight_tmp, out_var);
+            break;
+        }
+        case __bitleftr__func:{
+            GWARF_result reight_tmp, left_tmp, tmp_result = traverse(tmp_s->u.value, out_var, false);
+            if(is_error(&tmp_result)){  // Name Error错误
+                return_value = tmp_result;
+                goto return_result;
+            }
+            else if(is_space(&tmp_result)){
+                return_value = tmp_result;
+                goto return_result;
+            }
+            GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
+            reight_tmp = get__value__(&base_the_var, the_var);
+            var *tmp = find_var(login_var, 0, "value");
+            if(tmp != NULL){
+                left_tmp.value = tmp->value;
+            }
+            else{
+                left_tmp.value.type = NULL_value;
+                left_tmp.value.value.int_value = 0;
+            }
+            return_value = bit_left_func(reight_tmp, left_tmp, out_var);
+            break;
+        }
+        case __bitright__func:{
+            GWARF_result reight_tmp, left_tmp, tmp_result = traverse(tmp_s->u.value, out_var, false);
+            if(is_error(&tmp_result)){  // Name Error错误
+                return_value = tmp_result;
+                goto return_result;
+            }
+            else if(is_space(&tmp_result)){
+                return_value = tmp_result;
+                goto return_result;
+            }
+            GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
+            reight_tmp = get__value__(&base_the_var, the_var);
+            var *tmp = find_var(login_var, 0, "value");
+            if(tmp != NULL){
+                left_tmp.value = tmp->value;
+            }
+            else{
+                left_tmp.value.type = NULL_value;
+                left_tmp.value.value.int_value = 0;
+            }
+            return_value = bit_right_func(left_tmp, reight_tmp, out_var);
+            break;
+        }
+        case __bitrightr__func:{
+            GWARF_result reight_tmp, left_tmp, tmp_result = traverse(tmp_s->u.value, out_var, false);
+            if(is_error(&tmp_result)){  // Name Error错误
+                return_value = tmp_result;
+                goto return_result;
+            }
+            else if(is_space(&tmp_result)){
+                return_value = tmp_result;
+                goto return_result;
+            }
+            GWARF_value base_the_var = tmp_result.value;  // 只有一个参数
+            reight_tmp = get__value__(&base_the_var, the_var);
+            var *tmp = find_var(login_var, 0, "value");
+            if(tmp != NULL){
+                left_tmp.value = tmp->value;
+            }
+            else{
+                left_tmp.value.type = NULL_value;
+                left_tmp.value.value.int_value = 0;
+            }
+            return_value = bit_right_func(reight_tmp, left_tmp, out_var);
+            break;
+        }
+        case __bitnot__func:{
+            GWARF_result left_tmp;
+            var *tmp = find_var(login_var, 0, "value");
+            if(tmp != NULL){
+                left_tmp.value = tmp->value;
+            }
+            else{
+                left_tmp.value.type = NULL_value;
+                left_tmp.value.value.int_value = 0;
+            }
+            return_value = bit_not_func(left_tmp, out_var);
+            break;
+        }
         default:
             break;
     }

+ 420 - 0
inter/interpreter.c

@@ -1539,6 +1539,24 @@ GWARF_result operation_func(statement *the_statement, var_list *the_var, var_lis
         case INTDIV_func:
             value = int_div_func(left_result, right_result, the_var);
             break;
+        case BITAND_func:
+            value = bit_and_func(left_result, right_result, the_var);
+            break;
+        case BITOR_func:
+            value = bit_or_func(left_result, right_result, the_var);
+            break;
+        case BITNOTOR_func:
+            value = bit_notor_func(left_result, right_result, the_var);
+            break;
+        case BITRIGHT_func:
+            value = bit_right_func(left_result, right_result, the_var);
+            break;
+        case BITLEFT_func:
+            value = bit_left_func(left_result, right_result, the_var);
+            break;
+        case BITNOT_func:
+            value = bit_not_func(right_result, the_var);
+            break;
         default:
             break;
     }
@@ -1994,6 +2012,408 @@ GWARF_result not_func(GWARF_result right_result, var_list *the_var){  // the fun
     return_back: return return_value;
 }
 
+// ---------  BITAND &
+GWARF_result bit_and_func(GWARF_result left_result, GWARF_result right_result, var_list *the_var){  // the func for add and call from read_statement_list
+    GWARF_result return_value, get;  // the result by call read_statement_list with left and right; value is the result for add
+    if(left_result.value.type == OBJECT_value){  // 调用左add方法
+        GWARF_result get;
+        GWARF_value base_the_var = left_result.value;  // 只有一个参数
+        var_list *call_var = base_the_var.value.object_value->the_var;
+
+        var *tmp = find_var(call_var, 0, "__bitand__");
+        if(tmp != NULL){
+            get.value = tmp->value;
+            get.father = &base_the_var;  // 设置father
+            return_value = call_back_core(get, the_var, pack_value_parameter(right_result.value));
+            goto return_back;
+        }
+        // goto next if
+    }
+    if(right_result.value.type == OBJECT_value){  // 调用右add方法
+        GWARF_result get;
+        GWARF_value base_the_var = right_result.value;  // 只有一个参数
+        var_list *call_var = base_the_var.value.object_value->the_var;
+
+        var *tmp = find_var(call_var, 0, "__bitand__");
+        if(tmp != NULL){
+            get.value = tmp->value;
+            get.father = &base_the_var;  // 设置father
+            return_value = call_back_core(get, the_var, pack_value_parameter(left_result.value));
+        }
+        else{
+            return_value.u = statement_end;
+            return_value.value = left_result.value;
+        }
+        goto return_back;
+    }
+
+    {
+        // 理论上用户是不可以直接调用下面的基类的,计算过程中万物皆类
+        if(left_result.value.type == NULL_value){
+            left_result.value.type = INT_value;  // NULL相当于0
+            left_result.value.value.int_value = 0;  // NULL相当于0
+        }
+        else if(right_result.value.type == NULL_value){
+            right_result.value.type = INT_value;  // NULL相当于0
+            right_result.value.value.int_value = 0;  // NULL相当于0
+        }
+
+        if((left_result.value.type == INT_value || left_result.value.type == BOOL_value) && (right_result.value.type == INT_value || right_result.value.type == BOOL_value)){  // all is INT
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = left_result.value.value.int_value & right_result.value.value.int_value;
+        }
+        else if((left_result.value.type == NUMBER_value) && (right_result.value.type == NUMBER_value)){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = (int)left_result.value.value.double_value & (int)right_result.value.value.double_value;
+        }
+        else if((left_result.value.type == INT_value || left_result.value.type == BOOL_value) && (right_result.value.type == NUMBER_value)){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = left_result.value.value.int_value & (int)right_result.value.value.double_value;
+        }
+        else if((left_result.value.type == NUMBER_value) && (right_result.value.type == INT_value || right_result.value.type == BOOL_value)){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = (int)left_result.value.value.double_value & right_result.value.value.int_value;
+        }
+    }
+    return_back: return return_value;
+}
+
+// ---------  BITOR |
+GWARF_result bit_or_func(GWARF_result left_result, GWARF_result right_result, var_list *the_var){  // the func for add and call from read_statement_list
+    GWARF_result return_value, get;  // the result by call read_statement_list with left and right; value is the result for add
+    if(left_result.value.type == OBJECT_value){  // 调用左add方法
+        GWARF_result get;
+        GWARF_value base_the_var = left_result.value;  // 只有一个参数
+        var_list *call_var = base_the_var.value.object_value->the_var;
+
+        var *tmp = find_var(call_var, 0, "__bitor__");
+        if(tmp != NULL){
+            get.value = tmp->value;
+            get.father = &base_the_var;  // 设置father
+            return_value = call_back_core(get, the_var, pack_value_parameter(right_result.value));
+            goto return_back;
+        }
+        // goto next if
+    }
+    if(right_result.value.type == OBJECT_value){  // 调用右add方法
+        GWARF_result get;
+        GWARF_value base_the_var = right_result.value;  // 只有一个参数
+        var_list *call_var = base_the_var.value.object_value->the_var;
+
+        var *tmp = find_var(call_var, 0, "__bitor__");
+        if(tmp != NULL){
+            get.value = tmp->value;
+            get.father = &base_the_var;  // 设置father
+            return_value = call_back_core(get, the_var, pack_value_parameter(left_result.value));
+        }
+        else{
+            return_value.u = statement_end;
+            return_value.value = left_result.value;
+        }
+        goto return_back;
+    }
+
+    {
+        // 理论上用户是不可以直接调用下面的基类的,计算过程中万物皆类
+        if(left_result.value.type == NULL_value){
+            left_result.value.type = INT_value;  // NULL相当于0
+            left_result.value.value.int_value = 0;  // NULL相当于0
+        }
+        else if(right_result.value.type == NULL_value){
+            right_result.value.type = INT_value;  // NULL相当于0
+            right_result.value.value.int_value = 0;  // NULL相当于0
+        }
+
+        if((left_result.value.type == INT_value || left_result.value.type == BOOL_value) && (right_result.value.type == INT_value || right_result.value.type == BOOL_value)){  // all is INT
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = left_result.value.value.int_value | right_result.value.value.int_value;
+        }
+        else if((left_result.value.type == NUMBER_value) && (right_result.value.type == NUMBER_value)){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = (int)left_result.value.value.double_value | (int)right_result.value.value.double_value;
+        }
+        else if((left_result.value.type == INT_value || left_result.value.type == BOOL_value) && (right_result.value.type == NUMBER_value)){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = left_result.value.value.int_value | (int)right_result.value.value.double_value;
+        }
+        else if((left_result.value.type == NUMBER_value) && (right_result.value.type == INT_value || right_result.value.type == BOOL_value)){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = (int)left_result.value.value.double_value | right_result.value.value.int_value;
+        }
+    }
+    return_back: return return_value;
+}
+
+
+// ---------  BITNOTOR ^
+GWARF_result bit_notor_func(GWARF_result left_result, GWARF_result right_result, var_list *the_var){  // the func for add and call from read_statement_list
+    GWARF_result return_value, get;  // the result by call read_statement_list with left and right; value is the result for add
+    if(left_result.value.type == OBJECT_value){  // 调用左add方法
+        GWARF_result get;
+        GWARF_value base_the_var = left_result.value;  // 只有一个参数
+        var_list *call_var = base_the_var.value.object_value->the_var;
+
+        var *tmp = find_var(call_var, 0, "__bitnotor__");
+        if(tmp != NULL){
+            get.value = tmp->value;
+            get.father = &base_the_var;  // 设置father
+            return_value = call_back_core(get, the_var, pack_value_parameter(right_result.value));
+            goto return_back;
+        }
+        // goto next if
+    }
+    if(right_result.value.type == OBJECT_value){  // 调用右add方法
+        GWARF_result get;
+        GWARF_value base_the_var = right_result.value;  // 只有一个参数
+        var_list *call_var = base_the_var.value.object_value->the_var;
+
+        var *tmp = find_var(call_var, 0, "__bitnotor__");
+        if(tmp != NULL){
+            get.value = tmp->value;
+            get.father = &base_the_var;  // 设置father
+            return_value = call_back_core(get, the_var, pack_value_parameter(left_result.value));
+        }
+        else{
+            return_value.u = statement_end;
+            return_value.value = left_result.value;
+        }
+        goto return_back;
+    }
+
+    {
+        // 理论上用户是不可以直接调用下面的基类的,计算过程中万物皆类
+        if(left_result.value.type == NULL_value){
+            left_result.value.type = INT_value;  // NULL相当于0
+            left_result.value.value.int_value = 0;  // NULL相当于0
+        }
+        else if(right_result.value.type == NULL_value){
+            right_result.value.type = INT_value;  // NULL相当于0
+            right_result.value.value.int_value = 0;  // NULL相当于0
+        }
+
+        if((left_result.value.type == INT_value || left_result.value.type == BOOL_value) && (right_result.value.type == INT_value || right_result.value.type == BOOL_value)){  // all is INT
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = left_result.value.value.int_value ^ right_result.value.value.int_value;
+        }
+        else if((left_result.value.type == NUMBER_value) && (right_result.value.type == NUMBER_value)){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = (int)left_result.value.value.double_value ^ (int)right_result.value.value.double_value;
+        }
+        else if((left_result.value.type == INT_value || left_result.value.type == BOOL_value) && (right_result.value.type == NUMBER_value)){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = left_result.value.value.int_value ^ (int)right_result.value.value.double_value;
+        }
+        else if((left_result.value.type == NUMBER_value) && (right_result.value.type == INT_value || right_result.value.type == BOOL_value)){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = (int)left_result.value.value.double_value ^ right_result.value.value.int_value;
+        }
+    }
+    return_back: return return_value;
+}
+
+// ---------  BITLEFT <<
+GWARF_result bit_left_func(GWARF_result left_result, GWARF_result right_result, var_list *the_var){  // the func for add and call from read_statement_list
+    GWARF_result return_value, get;  // the result by call read_statement_list with left and right; value is the result for add
+    if(left_result.value.type == OBJECT_value){  // 调用左add方法
+        GWARF_result get;
+        GWARF_value base_the_var = left_result.value;  // 只有一个参数
+        var_list *call_var = base_the_var.value.object_value->the_var;
+
+        var *tmp = find_var(call_var, 0, "__bitleft__");
+        if(tmp != NULL){
+            get.value = tmp->value;
+            get.father = &base_the_var;  // 设置father
+            return_value = call_back_core(get, the_var, pack_value_parameter(right_result.value));
+            goto return_back;
+        }
+        // goto next if
+    }
+    if(right_result.value.type == OBJECT_value){  // 调用右add方法
+        GWARF_result get;
+        GWARF_value base_the_var = right_result.value;  // 只有一个参数
+        var_list *call_var = base_the_var.value.object_value->the_var;
+
+        var *tmp = find_var(call_var, 0, "__bitleftr__");
+        if(tmp != NULL){
+            get.value = tmp->value;
+            get.father = &base_the_var;  // 设置father
+            return_value = call_back_core(get, the_var, pack_value_parameter(left_result.value));
+        }
+        else{
+            return_value.u = statement_end;
+            return_value.value = left_result.value;
+        }
+        goto return_back;
+    }
+
+    {
+        // 理论上用户是不可以直接调用下面的基类的,计算过程中万物皆类
+        if(left_result.value.type == NULL_value){
+            left_result.value.type = INT_value;  // NULL相当于0
+            left_result.value.value.int_value = 0;  // NULL相当于0
+        }
+        else if(right_result.value.type == NULL_value){
+            right_result.value.type = INT_value;  // NULL相当于0
+            right_result.value.value.int_value = 0;  // NULL相当于0
+        }
+
+        if((left_result.value.type == INT_value || left_result.value.type == BOOL_value) && (right_result.value.type == INT_value || right_result.value.type == BOOL_value)){  // all is INT
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = left_result.value.value.int_value << right_result.value.value.int_value;
+        }
+        else if((left_result.value.type == NUMBER_value) && (right_result.value.type == NUMBER_value)){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = (int)left_result.value.value.double_value << (int)right_result.value.value.double_value;
+        }
+        else if((left_result.value.type == INT_value || left_result.value.type == BOOL_value) && (right_result.value.type == NUMBER_value)){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = left_result.value.value.int_value << (int)right_result.value.value.double_value;
+        }
+        else if((left_result.value.type == NUMBER_value) && (right_result.value.type == INT_value || right_result.value.type == BOOL_value)){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = (int)left_result.value.value.double_value << right_result.value.value.int_value;
+        }
+    }
+    return_back: return return_value;
+}
+
+// ---------  BITRIGHT >>
+GWARF_result bit_right_func(GWARF_result left_result, GWARF_result right_result, var_list *the_var){  // the func for add and call from read_statement_list
+    GWARF_result return_value, get;  // the result by call read_statement_list with left and right; value is the result for add
+    if(left_result.value.type == OBJECT_value){  // 调用左add方法
+        GWARF_result get;
+        GWARF_value base_the_var = left_result.value;  // 只有一个参数
+        var_list *call_var = base_the_var.value.object_value->the_var;
+
+        var *tmp = find_var(call_var, 0, "__bitright__");
+        if(tmp != NULL){
+            get.value = tmp->value;
+            get.father = &base_the_var;  // 设置father
+            return_value = call_back_core(get, the_var, pack_value_parameter(right_result.value));
+            goto return_back;
+        }
+        // goto next if
+    }
+    if(right_result.value.type == OBJECT_value){  // 调用右add方法
+        GWARF_result get;
+        GWARF_value base_the_var = right_result.value;  // 只有一个参数
+        var_list *call_var = base_the_var.value.object_value->the_var;
+
+        var *tmp = find_var(call_var, 0, "__bitrightr__");
+        if(tmp != NULL){
+            get.value = tmp->value;
+            get.father = &base_the_var;  // 设置father
+            return_value = call_back_core(get, the_var, pack_value_parameter(left_result.value));
+        }
+        else{
+            return_value.u = statement_end;
+            return_value.value = left_result.value;
+        }
+        goto return_back;
+    }
+
+    {
+        // 理论上用户是不可以直接调用下面的基类的,计算过程中万物皆类
+        if(left_result.value.type == NULL_value){
+            left_result.value.type = INT_value;  // NULL相当于0
+            left_result.value.value.int_value = 0;  // NULL相当于0
+        }
+        else if(right_result.value.type == NULL_value){
+            right_result.value.type = INT_value;  // NULL相当于0
+            right_result.value.value.int_value = 0;  // NULL相当于0
+        }
+
+        if((left_result.value.type == INT_value || left_result.value.type == BOOL_value) && (right_result.value.type == INT_value || right_result.value.type == BOOL_value)){  // all is INT
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = left_result.value.value.int_value >> right_result.value.value.int_value;
+        }
+        else if((left_result.value.type == NUMBER_value) && (right_result.value.type == NUMBER_value)){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = (int)left_result.value.value.double_value >> (int)right_result.value.value.double_value;
+        }
+        else if((left_result.value.type == INT_value || left_result.value.type == BOOL_value) && (right_result.value.type == NUMBER_value)){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = left_result.value.value.int_value >> (int)right_result.value.value.double_value;
+        }
+        else if((left_result.value.type == NUMBER_value) && (right_result.value.type == INT_value || right_result.value.type == BOOL_value)){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = (int)left_result.value.value.double_value >> right_result.value.value.int_value;
+        }
+    }
+    return_back: return return_value;
+}
+
+// ---------  BITNOT ~
+GWARF_result bit_not_func(GWARF_result right_result, var_list *the_var){  // the func for negative and call from read_statement_list
+    GWARF_result return_value;  // the result by call read_statement_list with left and right; value is the result for negative
+    if(right_result.value.type == OBJECT_value){  // 调用右sub方法
+        GWARF_result get;
+        GWARF_value base_the_var = right_result.value;  // 只有一个参数
+        var_list *call_var = base_the_var.value.object_value->the_var;
+
+        var *tmp = find_var(call_var, 0, "__bitnot__");
+        if(tmp != NULL){
+            get.value = tmp->value;
+            get.father = &base_the_var;  // 设置father
+            return_value = call_back_core(get, the_var, pack_value_parameter(right_result.value));
+        }
+        else{
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.bool_value = 1;
+        }
+    }
+    else{
+        if(right_result.value.type == NULL_value){  // 返回bool true
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = 1;
+        }
+        else if(right_result.value.type == INT_value){  // all is INT
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = ~right_result.value.value.int_value;
+        }
+        else if(right_result.value.type == BOOL_value){
+            return_value.u = statement_end;
+            return_value.value.type = BOOL_value;
+            if(right_result.value.value.bool_value)
+            {
+                return_value.value.value.bool_value = false;
+            }
+            else{
+                return_value.value.value.bool_value = true;
+            }
+        }
+        else if(right_result.value.type == NUMBER_value){  // all is NUMBER
+            return_value.u = statement_end;
+            return_value.value.type = INT_value;
+            return_value.value.value.int_value = ~((int)right_result.value.value.double_value);
+        }
+    }
+    return return_value;
+}
+
 // ---------  ADD
 GWARF_result add_func(GWARF_result left_result, GWARF_result right_result, var_list *the_var){  // the func for add and call from read_statement_list
     GWARF_result return_value, get;  // the result by call read_statement_list with left and right; value is the result for add

+ 20 - 0
inter/interpreter.h

@@ -134,6 +134,12 @@ typedef struct statement{
                 FSUB_func,  // a--
                 LSUB_func,  // --a
                 APOW_func,  // ^=
+                BITAND_func,
+                BITOR_func,
+                BITNOTOR_func,
+                BITRIGHT_func,
+                BITLEFT_func,
+                BITNOT_func,
             } type;
             struct statement *right_exp;  // the right exp
             struct statement *left_exp;  // the left exp
@@ -391,6 +397,14 @@ typedef enum{
     __idivr__func = 30,
     __mod__func = 31,
     __modr__func = 32,
+    __bitand__func = 33,
+    __bitor__func = 34,
+    __bitnotor__func = 35,
+    __bitleft__func = 36,
+    __bitleftr__func = 37,
+    __bitright__func = 38,
+    __bitrightr__func = 39,
+    __bitnot__func = 40,
 } official_func_type;
 
 typedef struct func{
@@ -449,6 +463,12 @@ GWARF_result or_func(statement *, statement *, var_list *);
 GWARF_result and_func(statement *, statement *, var_list *);
 GWARF_result int_div_func(GWARF_result, GWARF_result, var_list *);
 GWARF_result mod_func(GWARF_result, GWARF_result, var_list *);
+GWARF_result bit_not_func(GWARF_result, var_list *);
+GWARF_result bit_right_func(GWARF_result, GWARF_result, var_list *);
+GWARF_result bit_left_func(GWARF_result, GWARF_result, var_list *);
+GWARF_result bit_notor_func(GWARF_result, GWARF_result, var_list *);
+GWARF_result bit_or_func(GWARF_result, GWARF_result, var_list *);
+GWARF_result bit_and_func(GWARF_result, GWARF_result, var_list *);
 
 double sqrt_(double, double);
 double log_(double, double);

+ 4 - 5
paser/gwarf_lex.l

@@ -51,7 +51,7 @@
 <INITIAL>[\n]*\{[\n]* {return LP;}
 <INITIAL>"}" {return RP;}
 
-<INITIAL>"^=" {return APOW;}
+<INITIAL>"**=" {return APOW;}
 <INITIAL>"++" {return FADD;}
 <INITIAL>"--" {return FSUB;}
 <INITIAL>"+=" {return AADD;}
@@ -68,7 +68,6 @@
 <INITIAL>"==" {return EQUAL;}
 <INITIAL>"=" {return EQ;}
 <INITIAL>"**" {return POW;}
-<INITIAL>"^" {return POW;}
 <INITIAL>"log" {return LOG;}
 <INITIAL>"sqrt" {return SQRT;}
 <INITIAL>"+" {return ADD;}
@@ -101,10 +100,10 @@
 
 <INITIAL>"&" {return BITAND;}
 <INITIAL>"|" {return BITOR;}
-<INITIAL>"|" {return BITNOTOR;}
+<INITIAL>"^" {return BITNOTOR;}
 <INITIAL>"~" {return BITNOT;}
-<INITIAL>"<<" {return BITRIGHT;}
-<INITIAL>">>" {return BITLEFT;}
+<INITIAL>"<<" {return BITLEFT;}
+<INITIAL>">>" {return BITRIGHT;}
 
 <INITIAL>"." {return POINT;}
 

+ 75 - 10
paser/gwarf_yacc.y

@@ -27,7 +27,7 @@
 
 %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> eq_number class_block class_exp slice_arguments_token try_block try_exp try_token raise_exp import_exp include_exp bool_number
+%type <statement_value> eq_number class_block class_exp slice_arguments_token try_block try_exp try_token raise_exp import_exp include_exp bool_number bit_number bit_move
 
 %type <parameter_list> formal_parameter arguments slice_arguments
 
@@ -163,8 +163,8 @@ top_exp
     ;
 
 eq_number
-    : bool_number
-    | eq_number EQ bool_number
+    : bit_number
+    | eq_number EQ bit_number
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -173,7 +173,7 @@ eq_number
         code_tmp->code.operation.right_exp = $3;
         $$ = code_tmp;
     }
-    | eq_number AADD bool_number
+    | eq_number AADD bit_number
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -182,7 +182,7 @@ eq_number
         code_tmp->code.operation.right_exp = $3;
         $$ = code_tmp;
     }
-    | eq_number ASUB bool_number
+    | eq_number ASUB bit_number
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -191,7 +191,7 @@ eq_number
         code_tmp->code.operation.right_exp = $3;
         $$ = code_tmp;
     }
-    | eq_number AMUL bool_number
+    | eq_number AMUL bit_number
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -200,7 +200,7 @@ eq_number
         code_tmp->code.operation.right_exp = $3;
         $$ = code_tmp;
     }
-    | eq_number ADIV bool_number
+    | eq_number ADIV bit_number
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -209,7 +209,7 @@ eq_number
         code_tmp->code.operation.right_exp = $3;
         $$ = code_tmp;
     }
-    | eq_number AMOD bool_number
+    | eq_number AMOD bit_number
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -218,7 +218,7 @@ eq_number
         code_tmp->code.operation.right_exp = $3;
         $$ = code_tmp;
     }
-    | eq_number AINTDIV bool_number
+    | eq_number AINTDIV bit_number
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -227,7 +227,7 @@ eq_number
         code_tmp->code.operation.right_exp = $3;
         $$ = code_tmp;
     }
-    | eq_number APOW bool_number
+    | eq_number APOW bit_number
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -274,6 +274,71 @@ eq_number
     }
     ;
 
+bit_number
+    : bit_move
+    | bit_number BITAND bit_move
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = operation;
+        code_tmp->code.operation.type = BITAND_func;
+        code_tmp->code.operation.left_exp = $1;
+        code_tmp->code.operation.right_exp = $3;
+        puts("NOT FUNC");
+        $$ = code_tmp;
+    }
+    | bit_number BITOR bit_move
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = operation;
+        code_tmp->code.operation.type = BITOR_func;
+        code_tmp->code.operation.left_exp = $1;
+        code_tmp->code.operation.right_exp = $3;
+        $$ = code_tmp;
+    }
+    | bit_number BITNOTOR bit_move
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = operation;
+        code_tmp->code.operation.type = BITNOTOR_func;
+        code_tmp->code.operation.left_exp = $1;
+        code_tmp->code.operation.right_exp = $3;
+        puts("NOT FUNC");
+        $$ = code_tmp;
+    }
+    | BITNOT bit_move
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = operation;
+        code_tmp->code.operation.type = BITNOT_func;
+        code_tmp->code.operation.left_exp = NULL;
+        code_tmp->code.operation.right_exp = $2;
+        $$ = code_tmp;
+    }
+    ;
+
+bit_move
+    : bool_number
+    | bit_move BITRIGHT bool_number
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = operation;
+        code_tmp->code.operation.type = BITRIGHT_func;
+        code_tmp->code.operation.left_exp = $1;
+        code_tmp->code.operation.right_exp = $3;
+        puts("NOT FUNC");
+        $$ = code_tmp;
+    }
+    | bit_move BITLEFT bool_number
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = operation;
+        code_tmp->code.operation.type = BITLEFT_func;
+        code_tmp->code.operation.left_exp = $1;
+        code_tmp->code.operation.right_exp = $3;
+        $$ = code_tmp;
+    }
+    ;
+
 bool_number
     : third_number
     | NOT third_number

+ 241 - 220
paser/lex.yy.c

@@ -351,8 +351,8 @@ static void yynoreturn yy_fatal_error ( const char* msg  );
 	(yy_hold_char) = *yy_cp; \
 	*yy_cp = '\0'; \
 	(yy_c_buf_p) = yy_cp;
-#define YY_NUM_RULES 91
-#define YY_END_OF_BUFFER 92
+#define YY_NUM_RULES 95
+#define YY_END_OF_BUFFER 96
 /* This struct is not used in this scanner,
    but its presence is necessary. */
 struct yy_trans_info
@@ -360,33 +360,34 @@ struct yy_trans_info
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	};
-static const flex_int16_t yy_accept[231] =
+static const flex_int16_t yy_accept[233] =
     {   0,
-        0,    0,    0,    0,    0,    0,    0,    0,   92,   83,
-       80,   82,   75,   61,   59,   54,   83,   60,   26,   27,
-       53,   51,   17,   52,   76,   56,   78,   78,   18,   81,
-       43,   45,   42,   79,   79,   79,   79,   57,   58,   47,
-       79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
-       79,   79,   79,   79,   28,   83,   29,   48,   82,   86,
-       84,   85,   90,   89,   88,   87,   91,    0,    0,    0,
-       28,    0,   41,   38,   73,   46,   37,   31,   33,   32,
-       34,   55,   36,    0,   78,   40,   44,   39,   79,   79,
-       79,   79,   30,   64,   79,   79,   79,   79,   79,   79,
-
-       79,   79,   79,    5,   79,   23,   79,   79,   79,   79,
-       79,   79,   79,   79,   28,   74,    0,    0,    0,    0,
-        0,   35,   77,   79,   79,   79,   79,   79,   79,   79,
-       79,   70,   79,   79,   79,   16,   79,   79,   79,   49,
-       79,   79,   79,   79,   79,   79,   79,   79,   62,   79,
-        0,    0,    0,    0,    0,    3,   79,   69,   67,   79,
-       79,   79,   79,   79,   79,    6,    7,   79,   79,   79,
-       79,   79,   79,   14,   79,   79,   79,   50,   79,   79,
-        1,    2,    6,    7,    0,   68,   22,    8,   79,   72,
-       79,   79,    0,   79,   79,   79,   79,   79,   65,   79,
-
-       79,   79,   66,    4,    2,    0,    9,   79,   79,    7,
-       63,   20,   24,   79,   79,   79,   71,   15,   63,   79,
-       19,   25,   79,   11,   10,   21,   79,   13,   12,    0
+        0,    0,    0,    0,    0,    0,    0,    0,   96,   87,
+       84,   86,   73,   59,   57,   52,   74,   58,   26,   27,
+       51,   49,   17,   50,   80,   54,   82,   82,   18,   85,
+       43,   45,   42,   83,   83,   83,   83,   55,   56,   76,
+       83,   83,   83,   83,   83,   83,   83,   83,   83,   83,
+       83,   83,   83,   83,   28,   75,   29,   77,   86,   90,
+       88,   89,   94,   93,   92,   91,   95,    0,    0,    0,
+       28,    0,   41,   38,   71,   46,   37,   31,   33,   32,
+       34,   53,   36,    0,   82,   78,   40,   44,   39,   79,
+       83,   83,   83,   83,   62,   83,   83,   83,   83,   83,
+
+       83,   83,   83,   83,    5,   83,   23,   83,   83,   83,
+       83,   83,   83,   83,   83,   28,   72,    0,    0,    0,
+        0,    0,   30,   35,   81,   83,   83,   83,   83,   83,
+       83,   83,   83,   68,   83,   83,   83,   16,   83,   83,
+       83,   47,   83,   83,   83,   83,   83,   83,   83,   83,
+       60,   83,    0,    0,    0,    0,    0,    3,   83,   67,
+       65,   83,   83,   83,   83,   83,   83,    6,    7,   83,
+       83,   83,   83,   83,   83,   14,   83,   83,   83,   48,
+       83,   83,    1,    2,    6,    7,    0,   66,   22,    8,
+       83,   70,   83,   83,    0,   83,   83,   83,   83,   83,
+
+       63,   83,   83,   83,   64,    4,    2,    0,    9,   83,
+       83,    7,   61,   20,   24,   83,   83,   83,   69,   15,
+       61,   83,   19,   25,   83,   11,   10,   21,   83,   13,
+       12,    0
     } ;
 
 static const YY_CHAR yy_ec[256] =
@@ -431,67 +432,67 @@ static const YY_CHAR yy_meta[59] =
         2,    2,    2,    2,    1,    1,    1,    1
     } ;
 
-static const flex_int16_t yy_base[235] =
+static const flex_int16_t yy_base[237] =
     {   0,
-        0,  250,   57,   58,   60,   65,    0,    0,  252,  254,
-       69,  248,  227,  254,  254,  226,  240,  254,  254,  254,
-       54,   55,  254,   58,  254,   59,  254,   67,  254,  254,
-      224,  223,  222,    0,  212,  198,  194,  254,  254,  218,
-      191,   42,   46,  203,   45,  193,  195,   52,  191,  190,
-       43,  187,   53,  194,  230,  175,  254,  254,  227,  254,
-      254,  254,  254,  254,  254,  254,  254,   91,  226,   55,
-      226,  224,  254,  254,  254,  254,  254,  254,  254,  254,
-      254,  203,  254,   81,   88,  254,  254,  254,    0,  183,
-      180,  172,  254,    0,  177,   66,  189,  176,  182,   63,
-
-      184,  169,  171,    0,  169,  180,  175,  168,  171,   71,
-      162,  161,  154,  167,  204,  254,  202,  201,   70,  169,
-      199,  254,   95,  152,  164,  163,  164,  165,  155,  146,
-      144,  161,  155,  155,  154,    0,  156,  143,  145,    0,
-      144,  136,  139,  133,  131,  145,  130,  134,    0,  136,
-      174,  173,  138,  138,  137,  254,  136,    0,    0,  130,
-      129,  133,  119,  127,  115,    0,  155,  118,  131,  114,
-      110,  115,  123,    0,  126,  109,  112,    0,  103,  118,
-      254,  151,  254,  135,   98,    0,    0,    0,   99,    0,
-       98,   99,  129,   89,   96,   87,  101,  101,    0,   86,
-
-       89,   82,    0,    0,  129,   80,    0,   78,   78,  254,
-        0,    0,    0,   90,   93,   72,    0,    0,  254,   82,
-        0,    0,   75,   80,   80,    0,   45,    0,    0,  254,
-      146,  148,  150,   59
+        0,  252,   57,   58,   60,   65,    0,    0,  254,  256,
+       69,  250,  229,  256,  256,  228,  242,  256,  256,  256,
+       54,   55,  256,   58,  256,   59,  256,   67,  256,  256,
+       57,  226,   64,    0,  216,  202,  198,  256,  256,  256,
+      196,   42,   47,  208,   49,  198,  200,   56,  196,  195,
+       62,  192,   56,  199,  235,  180,  256,  256,  232,  256,
+      256,  256,  256,  256,  256,  256,  256,   94,  231,   59,
+      231,  229,  256,  256,  256,  208,  256,  256,  256,  256,
+      256,  207,  256,   88,   92,  256,  256,  256,  256,  256,
+        0,  187,  184,  176,    0,  181,   73,  193,  180,  186,
+
+       73,  188,  173,  175,    0,  173,  184,  179,  172,  175,
+       65,  166,  165,  158,  171,  208,  256,  206,  205,   76,
+      173,  203,  256,  256,  101,  156,  168,  167,  168,  169,
+      159,  150,  148,  165,  159,  159,  158,    0,  160,  147,
+      149,    0,  148,  140,  143,  137,  135,  149,  134,  138,
+        0,  140,  178,  177,  142,  142,  141,  256,  140,    0,
+        0,  134,  133,  137,  123,  131,  119,    0,  159,  122,
+      135,  118,  114,  119,  127,    0,  130,  113,  116,    0,
+      107,  122,  256,  155,  256,  146,  102,    0,    0,    0,
+      103,    0,  102,  103,  133,   93,  100,   91,  105,  105,
+
+        0,   90,   93,   86,    0,    0,  133,   84,    0,   82,
+       82,  256,    0,    0,    0,   95,   97,   78,    0,    0,
+      256,   91,    0,    0,   84,   87,   86,    0,   40,    0,
+        0,  256,  149,  151,  153,   59
     } ;
 
-static const flex_int16_t yy_def[235] =
+static const flex_int16_t yy_def[237] =
     {   0,
-      230,    1,  231,  231,  232,  232,  233,  233,  230,  230,
-      230,  230,  230,  230,  230,  230,  230,  230,  230,  230,
-      230,  230,  230,  230,  230,  230,  230,  230,  230,  230,
-      230,  230,  230,  234,  234,  234,  234,  230,  230,  230,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-      234,  234,  234,  234,  230,  230,  230,  230,  230,  230,
-      230,  230,  230,  230,  230,  230,  230,  230,  230,  230,
-      230,  230,  230,  230,  230,  230,  230,  230,  230,  230,
-      230,  230,  230,  230,  230,  230,  230,  230,  234,  234,
-      234,  234,  230,  234,  234,  234,  234,  234,  234,  234,
-
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-      234,  234,  234,  234,  230,  230,  230,  230,  230,  230,
-      230,  230,  230,  234,  234,  234,  234,  234,  234,  234,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-      230,  230,  230,  230,  230,  230,  234,  234,  234,  234,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-      230,  230,  230,  230,  230,  234,  234,  234,  234,  234,
-      234,  234,  230,  234,  234,  234,  234,  234,  234,  234,
-
-      234,  234,  234,  234,  230,  230,  234,  234,  234,  230,
-      234,  234,  234,  234,  234,  234,  234,  234,  230,  234,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,    0,
-      230,  230,  230,  230
+      232,    1,  233,  233,  234,  234,  235,  235,  232,  232,
+      232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
+      232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
+      232,  232,  232,  236,  236,  236,  236,  232,  232,  232,
+      236,  236,  236,  236,  236,  236,  236,  236,  236,  236,
+      236,  236,  236,  236,  232,  232,  232,  232,  232,  232,
+      232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
+      232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
+      232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
+      236,  236,  236,  236,  236,  236,  236,  236,  236,  236,
+
+      236,  236,  236,  236,  236,  236,  236,  236,  236,  236,
+      236,  236,  236,  236,  236,  232,  232,  232,  232,  232,
+      232,  232,  232,  232,  232,  236,  236,  236,  236,  236,
+      236,  236,  236,  236,  236,  236,  236,  236,  236,  236,
+      236,  236,  236,  236,  236,  236,  236,  236,  236,  236,
+      236,  236,  232,  232,  232,  232,  232,  232,  236,  236,
+      236,  236,  236,  236,  236,  236,  236,  236,  236,  236,
+      236,  236,  236,  236,  236,  236,  236,  236,  236,  236,
+      236,  236,  232,  232,  232,  232,  232,  236,  236,  236,
+      236,  236,  236,  236,  232,  236,  236,  236,  236,  236,
+
+      236,  236,  236,  236,  236,  236,  232,  232,  236,  236,
+      236,  232,  236,  236,  236,  236,  236,  236,  236,  236,
+      232,  236,  236,  236,  236,  236,  236,  236,  236,  236,
+      236,    0,  232,  232,  232,  232
     } ;
 
-static const flex_int16_t yy_nxt[313] =
+static const flex_int16_t yy_nxt[315] =
     {   0,
        10,   11,   12,   13,   14,   15,   16,   17,   18,   19,
        20,   21,   22,   23,   24,   25,   26,   27,   28,   29,
@@ -499,38 +500,38 @@ static const flex_int16_t yy_nxt[313] =
        40,   41,   42,   43,   44,   45,   46,   47,   34,   48,
        34,   49,   34,   50,   34,   34,   34,   51,   52,   53,
        34,   54,   34,   34,   55,   56,   57,   58,   61,   61,
-       89,   64,   62,   62,   65,   76,   64,   78,   66,   65,
-       68,   69,   80,   66,  109,   82,   77,   79,  110,  229,
-       81,   83,   84,   95,   85,   85,  100,   97,  104,   96,
-       98,  112,   68,   69,  105,  106,  119,  101,  123,  123,
-
-      113,  128,  133,   84,   70,   85,   85,  120,  143,  153,
-      129,  134,  123,  123,  228,  227,  226,  225,  154,  144,
-      145,  224,  146,   71,  223,  222,   70,  221,  220,  219,
-      205,  218,  217,  216,  215,  214,  213,  212,  211,  210,
-      209,  208,  207,  206,  193,   71,   60,   60,   63,   63,
-       67,   67,  205,  204,  203,  202,  201,  200,  199,  198,
-      197,  196,  195,  194,  193,  192,  191,  190,  189,  188,
-      187,  186,  185,  184,  183,  182,  181,  180,  179,  178,
-      177,  176,  175,  174,  173,  172,  171,  170,  169,  168,
-      167,  166,  165,  164,  163,  162,  161,  160,  159,  158,
-
-      157,  156,  155,  152,  151,  115,  150,  149,  148,  147,
-      142,  141,  140,  139,  138,  137,  136,  135,  132,  131,
-      130,  127,  126,  125,  124,  122,  121,  115,  118,  117,
-      116,  115,  114,  111,  108,  107,  103,  102,   99,   94,
-       93,   92,   91,   90,   88,   87,   86,   75,   74,   73,
-       72,  230,   59,    9,  230,  230,  230,  230,  230,  230,
-      230,  230,  230,  230,  230,  230,  230,  230,  230,  230,
-      230,  230,  230,  230,  230,  230,  230,  230,  230,  230,
-      230,  230,  230,  230,  230,  230,  230,  230,  230,  230,
-      230,  230,  230,  230,  230,  230,  230,  230,  230,  230,
-
-      230,  230,  230,  230,  230,  230,  230,  230,  230,  230,
-      230,  230
+       91,   64,   62,   62,   65,   76,   64,   78,   66,   65,
+       68,   69,   80,   66,  231,   82,   77,   79,   86,   87,
+       81,   83,   84,   96,   85,   85,   89,   90,   98,   97,
+      101,   99,  105,  110,  113,   68,   69,  111,  106,  107,
+
+      120,  102,  145,  114,   70,  125,  125,   84,  130,   85,
+       85,  121,  135,  146,  147,  155,  148,  131,  125,  125,
+      230,  136,  229,   71,  156,  228,  227,  226,  225,   70,
+      224,  223,  222,  221,  207,  220,  219,  218,  217,  216,
+      215,  214,  213,  212,  211,  210,  209,  208,   71,   60,
+       60,   63,   63,   67,   67,  195,  207,  206,  205,  204,
+      203,  202,  201,  200,  199,  198,  197,  196,  195,  194,
+      193,  192,  191,  190,  189,  188,  187,  186,  185,  184,
+      183,  182,  181,  180,  179,  178,  177,  176,  175,  174,
+      173,  172,  171,  170,  169,  168,  167,  166,  165,  164,
+
+      163,  162,  161,  160,  159,  158,  157,  154,  153,  116,
+      152,  151,  150,  149,  144,  143,  142,  141,  140,  139,
+      138,  137,  134,  133,  132,  129,  128,  127,  126,  124,
+      123,  122,  116,  119,  118,  117,  116,  115,  112,  109,
+      108,  104,  103,  100,   95,   94,   93,   92,   88,   75,
+       74,   73,   72,  232,   59,    9,  232,  232,  232,  232,
+      232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
+      232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
+      232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
+      232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
+
+      232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
+      232,  232,  232,  232
     } ;
 
-static const flex_int16_t yy_chk[313] =
+static const flex_int16_t yy_chk[315] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -538,35 +539,35 @@ static const flex_int16_t yy_chk[313] =
         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,
-      234,    5,    3,    4,    5,   21,    6,   22,    5,    6,
-       11,   11,   24,    6,   51,   26,   21,   22,   51,  227,
-       24,   26,   28,   42,   28,   28,   45,   43,   48,   42,
-       43,   53,   68,   68,   48,   48,   70,   45,   84,   84,
-
-       53,   96,  100,   85,   11,   85,   85,   70,  110,  119,
-       96,  100,  123,  123,  225,  224,  223,  220,  119,  110,
-      110,  216,  110,   11,  215,  214,   68,  209,  208,  206,
-      205,  202,  201,  200,  198,  197,  196,  195,  194,  193,
-      192,  191,  189,  185,  184,   68,  231,  231,  232,  232,
-      233,  233,  182,  180,  179,  177,  176,  175,  173,  172,
-      171,  170,  169,  168,  167,  165,  164,  163,  162,  161,
-      160,  157,  155,  154,  153,  152,  151,  150,  148,  147,
-      146,  145,  144,  143,  142,  141,  139,  138,  137,  135,
-      134,  133,  132,  131,  130,  129,  128,  127,  126,  125,
-
-      124,  121,  120,  118,  117,  115,  114,  113,  112,  111,
-      109,  108,  107,  106,  105,  103,  102,  101,   99,   98,
-       97,   95,   92,   91,   90,   82,   72,   71,   69,   59,
-       56,   55,   54,   52,   50,   49,   47,   46,   44,   41,
-       40,   37,   36,   35,   33,   32,   31,   17,   16,   13,
-       12,    9,    2,  230,  230,  230,  230,  230,  230,  230,
-      230,  230,  230,  230,  230,  230,  230,  230,  230,  230,
-      230,  230,  230,  230,  230,  230,  230,  230,  230,  230,
-      230,  230,  230,  230,  230,  230,  230,  230,  230,  230,
-      230,  230,  230,  230,  230,  230,  230,  230,  230,  230,
-
-      230,  230,  230,  230,  230,  230,  230,  230,  230,  230,
-      230,  230
+      236,    5,    3,    4,    5,   21,    6,   22,    5,    6,
+       11,   11,   24,    6,  229,   26,   21,   22,   31,   31,
+       24,   26,   28,   42,   28,   28,   33,   33,   43,   42,
+       45,   43,   48,   51,   53,   68,   68,   51,   48,   48,
+
+       70,   45,  111,   53,   11,   84,   84,   85,   97,   85,
+       85,   70,  101,  111,  111,  120,  111,   97,  125,  125,
+      227,  101,  226,   11,  120,  225,  222,  218,  217,   68,
+      216,  211,  210,  208,  207,  204,  203,  202,  200,  199,
+      198,  197,  196,  195,  194,  193,  191,  187,   68,  233,
+      233,  234,  234,  235,  235,  186,  184,  182,  181,  179,
+      178,  177,  175,  174,  173,  172,  171,  170,  169,  167,
+      166,  165,  164,  163,  162,  159,  157,  156,  155,  154,
+      153,  152,  150,  149,  148,  147,  146,  145,  144,  143,
+      141,  140,  139,  137,  136,  135,  134,  133,  132,  131,
+
+      130,  129,  128,  127,  126,  122,  121,  119,  118,  116,
+      115,  114,  113,  112,  110,  109,  108,  107,  106,  104,
+      103,  102,  100,   99,   98,   96,   94,   93,   92,   82,
+       76,   72,   71,   69,   59,   56,   55,   54,   52,   50,
+       49,   47,   46,   44,   41,   37,   36,   35,   32,   17,
+       16,   13,   12,    9,    2,  232,  232,  232,  232,  232,
+      232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
+      232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
+      232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
+      232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
+
+      232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
+      232,  232,  232,  232
     } ;
 
 static yy_state_type yy_last_accepting_state;
@@ -594,9 +595,9 @@ char *yytext;
     int flat = 0;
     int is_last = 0;  // 是否\n
     int is_stop = 0;  // 针对}需要返回一个}的同时返回一个STOP
-#line 597 "lex.yy.c"
+#line 598 "lex.yy.c"
 
-#line 599 "lex.yy.c"
+#line 600 "lex.yy.c"
 
 #define INITIAL 0
 #define COMMENT 1
@@ -821,7 +822,7 @@ YY_DECL
 	{
 #line 13 "gwarf_lex.l"
 
-#line 824 "lex.yy.c"
+#line 825 "lex.yy.c"
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
@@ -849,13 +850,13 @@ yy_match:
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 				{
 				yy_current_state = (int) yy_def[yy_current_state];
-				if ( yy_current_state >= 231 )
+				if ( yy_current_state >= 233 )
 					yy_c = yy_meta[yy_c];
 				}
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 			++yy_cp;
 			}
-		while ( yy_base[yy_current_state] != 254 );
+		while ( yy_base[yy_current_state] != 256 );
 
 yy_find_action:
 		yy_act = yy_accept[yy_current_state];
@@ -1124,7 +1125,7 @@ YY_RULE_SETUP
 case 47:
 YY_RULE_SETUP
 #line 71 "gwarf_lex.l"
-{return POW;}
+{return LOG;}
 	YY_BREAK
 case 48:
 YY_RULE_SETUP
@@ -1134,238 +1135,258 @@ YY_RULE_SETUP
 case 49:
 YY_RULE_SETUP
 #line 73 "gwarf_lex.l"
-{return LOG;}
+{return ADD;}
 	YY_BREAK
 case 50:
 YY_RULE_SETUP
 #line 74 "gwarf_lex.l"
-{return SQRT;}
+{return SUB;}
 	YY_BREAK
 case 51:
 YY_RULE_SETUP
 #line 75 "gwarf_lex.l"
-{return ADD;}
+{return MUL;}
 	YY_BREAK
 case 52:
 YY_RULE_SETUP
 #line 76 "gwarf_lex.l"
-{return SUB;}
+{return MOD;}
 	YY_BREAK
 case 53:
 YY_RULE_SETUP
 #line 77 "gwarf_lex.l"
-{return MUL;}
+{return INTDIV;}
 	YY_BREAK
 case 54:
 YY_RULE_SETUP
 #line 78 "gwarf_lex.l"
-{return MOD;}
+{return DIV;}
 	YY_BREAK
 case 55:
 YY_RULE_SETUP
 #line 79 "gwarf_lex.l"
-{return INTDIV;}
+{return LI;}
 	YY_BREAK
 case 56:
 YY_RULE_SETUP
 #line 80 "gwarf_lex.l"
-{return DIV;}
+{return RI;}
 	YY_BREAK
 case 57:
 YY_RULE_SETUP
-#line 81 "gwarf_lex.l"
-{return LI;}
+#line 82 "gwarf_lex.l"
+{BEGIN COMMENT;}
 	YY_BREAK
 case 58:
 YY_RULE_SETUP
-#line 82 "gwarf_lex.l"
-{return RI;}
+#line 83 "gwarf_lex.l"
+{BEGIN STRING_TEXT;}
 	YY_BREAK
 case 59:
 YY_RULE_SETUP
 #line 84 "gwarf_lex.l"
-{BEGIN COMMENT;}
+{BEGIN STRING_TEXT;}
 	YY_BREAK
 case 60:
 YY_RULE_SETUP
-#line 85 "gwarf_lex.l"
-{BEGIN STRING_TEXT;}
+#line 86 "gwarf_lex.l"
+{return TRY;}
 	YY_BREAK
 case 61:
+/* rule 61 can match eol */
 YY_RULE_SETUP
-#line 86 "gwarf_lex.l"
-{BEGIN STRING_TEXT;}
+#line 87 "gwarf_lex.l"
+{return EXCEPT;}
 	YY_BREAK
 case 62:
 YY_RULE_SETUP
 #line 88 "gwarf_lex.l"
-{return TRY;}
+{return AS;}
 	YY_BREAK
 case 63:
-/* rule 63 can match eol */
 YY_RULE_SETUP
 #line 89 "gwarf_lex.l"
-{return EXCEPT;}
+{return RAISE;}
 	YY_BREAK
 case 64:
 YY_RULE_SETUP
 #line 90 "gwarf_lex.l"
-{return AS;}
+{return THROW;}
 	YY_BREAK
 case 65:
 YY_RULE_SETUP
 #line 91 "gwarf_lex.l"
-{return RAISE;}
+{return TRUE;}
 	YY_BREAK
 case 66:
 YY_RULE_SETUP
 #line 92 "gwarf_lex.l"
-{return THROW;}
+{return FALSE;}
 	YY_BREAK
 case 67:
 YY_RULE_SETUP
 #line 93 "gwarf_lex.l"
-{return TRUE;}
+{return NULL_token;}
 	YY_BREAK
 case 68:
 YY_RULE_SETUP
 #line 94 "gwarf_lex.l"
-{return FALSE;}
+{return DEF;}
 	YY_BREAK
 case 69:
 YY_RULE_SETUP
 #line 95 "gwarf_lex.l"
-{return NULL_token;}
+{return RETURN;}
 	YY_BREAK
 case 70:
 YY_RULE_SETUP
 #line 96 "gwarf_lex.l"
-{return DEF;}
+{return CLASS;}
 	YY_BREAK
 case 71:
 YY_RULE_SETUP
 #line 97 "gwarf_lex.l"
-{return RETURN;}
+{return AND;}
 	YY_BREAK
 case 72:
 YY_RULE_SETUP
 #line 98 "gwarf_lex.l"
-{return CLASS;}
+{return OR;}
 	YY_BREAK
 case 73:
 YY_RULE_SETUP
 #line 99 "gwarf_lex.l"
-{return AND;}
+{return NOT;}
 	YY_BREAK
 case 74:
 YY_RULE_SETUP
-#line 100 "gwarf_lex.l"
-{return OR;}
+#line 101 "gwarf_lex.l"
+{return BITAND;}
 	YY_BREAK
 case 75:
 YY_RULE_SETUP
-#line 101 "gwarf_lex.l"
-{return NOT;}
+#line 102 "gwarf_lex.l"
+{return BITOR;}
 	YY_BREAK
 case 76:
 YY_RULE_SETUP
-#line 102 "gwarf_lex.l"
-{return POINT;}
+#line 103 "gwarf_lex.l"
+{return BITNOTOR;}
 	YY_BREAK
 case 77:
 YY_RULE_SETUP
 #line 104 "gwarf_lex.l"
+{return BITNOT;}
+	YY_BREAK
+case 78:
+YY_RULE_SETUP
+#line 105 "gwarf_lex.l"
+{return BITLEFT;}
+	YY_BREAK
+case 79:
+YY_RULE_SETUP
+#line 106 "gwarf_lex.l"
+{return BITRIGHT;}
+	YY_BREAK
+case 80:
+YY_RULE_SETUP
+#line 108 "gwarf_lex.l"
+{return POINT;}
+	YY_BREAK
+case 81:
+YY_RULE_SETUP
+#line 110 "gwarf_lex.l"
 {
     yylval.double_value = atof(yytext);
     return NUMBER;
     }
 	YY_BREAK
-case 78:
+case 82:
 YY_RULE_SETUP
-#line 108 "gwarf_lex.l"
+#line 114 "gwarf_lex.l"
 {
     yylval.double_value = atof(yytext);
     return INT;
     }
 	YY_BREAK
-case 79:
+case 83:
 YY_RULE_SETUP
-#line 112 "gwarf_lex.l"
+#line 118 "gwarf_lex.l"
 {
     yylval.string_value = yytext;
     return VAR;
     }
 	YY_BREAK
-case 80:
-/* rule 80 can match eol */
+case 84:
+/* rule 84 can match eol */
 YY_RULE_SETUP
-#line 116 "gwarf_lex.l"
+#line 122 "gwarf_lex.l"
 {return STOPN;}
 	YY_BREAK
-case 81:
+case 85:
 YY_RULE_SETUP
-#line 117 "gwarf_lex.l"
+#line 123 "gwarf_lex.l"
 {return STOPF;}
 	YY_BREAK
-case 82:
+case 86:
 YY_RULE_SETUP
-#line 118 "gwarf_lex.l"
+#line 124 "gwarf_lex.l"
 ;
 	YY_BREAK
-case 83:
+case 87:
 YY_RULE_SETUP
-#line 119 "gwarf_lex.l"
+#line 125 "gwarf_lex.l"
 {printf("other text = [%s];\n", yytext);}
 	YY_BREAK
-case 84:
-/* rule 84 can match eol */
+case 88:
+/* rule 88 can match eol */
 YY_RULE_SETUP
-#line 121 "gwarf_lex.l"
+#line 127 "gwarf_lex.l"
 {BEGIN INITIAL;}
 	YY_BREAK
-case 85:
+case 89:
 YY_RULE_SETUP
-#line 122 "gwarf_lex.l"
+#line 128 "gwarf_lex.l"
 {BEGIN INITIAL;}
 	YY_BREAK
-case 86:
+case 90:
 YY_RULE_SETUP
-#line 123 "gwarf_lex.l"
+#line 129 "gwarf_lex.l"
 ;
 	YY_BREAK
-case 87:
+case 91:
 YY_RULE_SETUP
-#line 125 "gwarf_lex.l"
+#line 131 "gwarf_lex.l"
 {BEGIN INITIAL;}
 	YY_BREAK
-case 88:
+case 92:
 YY_RULE_SETUP
-#line 126 "gwarf_lex.l"
+#line 132 "gwarf_lex.l"
 {BEGIN INITIAL;}
 	YY_BREAK
-case 89:
-/* rule 89 can match eol */
+case 93:
+/* rule 93 can match eol */
 YY_RULE_SETUP
-#line 127 "gwarf_lex.l"
+#line 133 "gwarf_lex.l"
 {
     yylval.string_value = yytext;
     return STRING;
     }
 	YY_BREAK
-case 90:
+case 94:
 YY_RULE_SETUP
-#line 131 "gwarf_lex.l"
+#line 137 "gwarf_lex.l"
 {
     yylval.string_value = yytext;
     return STRING;
     }
 	YY_BREAK
-case 91:
+case 95:
 YY_RULE_SETUP
-#line 135 "gwarf_lex.l"
+#line 141 "gwarf_lex.l"
 ECHO;
 	YY_BREAK
-#line 1368 "lex.yy.c"
+#line 1389 "lex.yy.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(COMMENT):
 case YY_STATE_EOF(STRING_TEXT):
@@ -1666,7 +1687,7 @@ static int yy_get_next_buffer (void)
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			{
 			yy_current_state = (int) yy_def[yy_current_state];
-			if ( yy_current_state >= 231 )
+			if ( yy_current_state >= 233 )
 				yy_c = yy_meta[yy_c];
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -1694,11 +1715,11 @@ static int yy_get_next_buffer (void)
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		{
 		yy_current_state = (int) yy_def[yy_current_state];
-		if ( yy_current_state >= 231 )
+		if ( yy_current_state >= 233 )
 			yy_c = yy_meta[yy_c];
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
-	yy_is_jam = (yy_current_state == 230);
+	yy_is_jam = (yy_current_state == 232);
 
 		return yy_is_jam ? 0 : yy_current_state;
 }
@@ -2376,7 +2397,7 @@ void yyfree (void * ptr )
 
 #define YYTABLES_NAME "yytables"
 
-#line 135 "gwarf_lex.l"
+#line 141 "gwarf_lex.l"
 
 int yywrap(void) {
     return 1;

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 370 - 318
paser/y.tab.c


+ 14 - 2
paser/y.tab.h

@@ -123,7 +123,13 @@ extern int yydebug;
     AINTDIV = 329,
     FADD = 330,
     FSUB = 331,
-    APOW = 332
+    APOW = 332,
+    BITAND = 333,
+    BITOR = 334,
+    BITNOT = 335,
+    BITNOTOR = 336,
+    BITRIGHT = 337,
+    BITLEFT = 338
   };
 #endif
 /* Tokens.  */
@@ -202,6 +208,12 @@ extern int yydebug;
 #define FADD 330
 #define FSUB 331
 #define APOW 332
+#define BITAND 333
+#define BITOR 334
+#define BITNOT 335
+#define BITNOTOR 336
+#define BITRIGHT 337
+#define BITLEFT 338
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@@ -216,7 +228,7 @@ union YYSTYPE
     struct if_list *if_list_base;
     struct parameter *parameter_list;
 
-#line 220 "y.tab.h"
+#line 232 "y.tab.h"
 
 };
 typedef union YYSTYPE YYSTYPE;

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels