Browse Source

布尔运算

SongZihuan 5 years ago
parent
commit
7def45b096
8 changed files with 680 additions and 511 deletions
  1. BIN
      gwarf
  2. 76 6
      inter/interpreter.c
  3. 6 0
      inter/interpreter.h
  4. 3 4
      paser/gwarf_lex.l
  5. 36 4
      paser/gwarf_yacc.y
  6. 198 208
      paser/lex.yy.c
  7. 353 287
      paser/y.tab.c
  8. 8 2
      paser/y.tab.h

BIN
gwarf


+ 76 - 6
inter/interpreter.c

@@ -1410,18 +1410,19 @@ GWARF_result while_func(statement *the_statement, var_list *the_var){  // read t
 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;
     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]
-        left_result = traverse((*the_statement).code.operation.left_exp, the_var, false);
-        if(is_error(&left_result)){  // Name Error错误
-            // puts("STOP:: Name No Found!");
+    if(func_type != ASSIGMENT_func && func_type != AND_func && func_type != OR_func)
+    {
+        left_result = traverse(the_statement->code.operation.left_exp, the_var, false);  // NEGATIVE_func等的left为NULL相当与不执行
+        if(is_error(&left_result)){
             return left_result;
         }
         else if(is_space(&left_result)){
             return left_result;
         }
     }
-    right_result = traverse((*the_statement).code.operation.right_exp, the_var, false);
-    if(is_error(&right_result)){  // Name Error错误
+    right_result = traverse(the_statement->code.operation.right_exp, the_var, false);
+    if(is_error(&right_result))
+    {
         return right_result;
     }
     else if(right_result.u != return_def && is_space(&right_result)){
@@ -1476,6 +1477,15 @@ GWARF_result operation_func(statement *the_statement, var_list *the_var, var_lis
         case SQRT_func:
             value = sqrt_func(left_result, right_result, the_var);
             break;
+        case AND_func:
+            value = and_func(the_statement->code.operation.left_exp, the_statement->code.operation.right_exp, the_var);
+            break;
+        case OR_func:
+            value = or_func(the_statement->code.operation.left_exp, the_statement->code.operation.right_exp, the_var);
+            break;
+        case NOT_func:
+            value = not_func(right_result, the_var);
+            break;
         default:
             break;
     }
@@ -1871,6 +1881,66 @@ GWARF_result call_back_core(GWARF_result get, var_list *the_var, parameter *tmp_
     return result;
 }
 
+// ---------  AND
+GWARF_result and_func(statement *left_statement, statement *right_statement, 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 and
+    return_value.u = statement_end;
+    return_value.value.type = BOOL_value;
+
+    bool left = to_bool(traverse(left_statement, the_var, false).value), right;
+    if(left){
+        right = to_bool(traverse(right_statement, the_var, false).value);
+        if(right){
+            return_value.value.value.bool_value = true;
+        }
+        else{
+            return_value.value.value.bool_value = false;
+        }
+    }
+    else{
+        return_value.value.value.bool_value = false;
+    }
+    return_back: return return_value;
+}
+
+// ---------  OR
+GWARF_result or_func(statement *left_statement, statement *right_statement, 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 and
+    return_value.u = statement_end;
+    return_value.value.type = BOOL_value;
+
+    bool left = to_bool(traverse(left_statement, the_var, false).value), right;
+    if(left){
+        return_value.value.value.bool_value = true;
+    }
+    else{
+        right = to_bool(traverse(right_statement, the_var, false).value);
+        if(right){
+            return_value.value.value.bool_value = true;
+        }
+        else{
+            return_value.value.value.bool_value = false;
+        }
+    }
+    return_back: return return_value;
+}
+
+// ---------  NOT
+GWARF_result not_func(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 and
+    return_value.u = statement_end;
+    return_value.value.type = BOOL_value;
+    bool right = to_bool(right_result.value);
+    if(right)
+    {
+        return_value.value.value.bool_value = false;
+    }
+    else{
+        return_value.value.value.bool_value = true;
+    }
+    return_back: 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

+ 6 - 0
inter/interpreter.h

@@ -118,6 +118,9 @@ typedef struct statement{
                 LOG_func,  // <>
                 SQRT_func,  // <>
                 NEGATIVE_func,  // -a
+                AND_func,  // -a
+                OR_func,  // -a
+                NOT_func,  // -a
             } type;
             struct statement *right_exp;  // the right exp
             struct statement *left_exp;  // the left exp
@@ -424,6 +427,9 @@ GWARF_result assigment_func(char *, GWARF_result, var_list *, int);
 GWARF_result equal_func(GWARF_result, GWARF_result, var_list *, int);
 GWARF_result negative_func(GWARF_result, var_list *);
 GWARF_result assigment_statement(statement *, var_list *, var_list *, GWARF_result);
+GWARF_result not_func(GWARF_result, var_list *);
+GWARF_result or_func(statement *, statement *, var_list *);
+GWARF_result and_func(statement *, statement *, var_list *);
 
 double sqrt_(double, double);
 double log_(double, double);

+ 3 - 4
paser/gwarf_lex.l

@@ -79,16 +79,15 @@
 <INITIAL>"as" {return AS;}
 <INITIAL>"raise" {return RAISE;}
 <INITIAL>"throw" {return THROW;}
-<INITIAL>"true" {return TRUE;}
-<INITIAL>"false" {return FALSE;}
 <INITIAL>"True" {return TRUE;}
 <INITIAL>"False" {return FALSE;}
 <INITIAL>"None" {return NULL_token;}
-<INITIAL>"NULL" {return NULL_token;}
-<INITIAL>"null" {return NULL_token;}
 <INITIAL>"def" {return DEF;}
 <INITIAL>"return" {return RETURN;}
 <INITIAL>"class" {return CLASS;}
+<INITIAL>"&&" {return AND;}
+<INITIAL>"||" {return OR;}
+<INITIAL>"!" {return NOT;}
 <INITIAL>"." {return POINT;}
 
 <INITIAL>[1-9][0-9]*\.[0-9]+ {

+ 36 - 4
paser/gwarf_yacc.y

@@ -23,11 +23,11 @@
 %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 NULL_token DEF RETURN CLASS POINT COLON TRY EXCEPT AS RAISE THROW IMPORT INCLUDE IN
+%token NULL_token DEF RETURN CLASS POINT COLON TRY EXCEPT AS RAISE THROW IMPORT INCLUDE IN AND OR NOT
 
 %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
+%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 <parameter_list> formal_parameter arguments slice_arguments
 
@@ -163,8 +163,8 @@ top_exp
     ;
 
 eq_number
-    : third_number
-    | eq_number EQ third_number
+    : bool_number
+    | eq_number EQ bool_number
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -175,6 +175,38 @@ eq_number
     }
     ;
 
+bool_number
+    : third_number
+    | NOT third_number
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = operation;
+        code_tmp->code.operation.type = NOT_func;
+        code_tmp->code.operation.left_exp = NULL;
+        code_tmp->code.operation.right_exp = $2;
+        puts("NOT FUNC");
+        $$ = code_tmp;
+    }
+    | bool_number AND third_number
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = operation;
+        code_tmp->code.operation.type = AND_func;
+        code_tmp->code.operation.left_exp = $1;
+        code_tmp->code.operation.right_exp = $3;
+        $$ = code_tmp;
+    }
+    | bool_number OR third_number
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = operation;
+        code_tmp->code.operation.type = OR_func;
+        code_tmp->code.operation.left_exp = $1;
+        code_tmp->code.operation.right_exp = $3;
+        $$ = code_tmp;
+    }
+    ;
+
 third_number
     : second_number
     | third_number EQUAL second_number

+ 198 - 208
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 81
-#define YY_END_OF_BUFFER 82
+#define YY_NUM_RULES 80
+#define YY_END_OF_BUFFER 81
 /* This struct is not used in this scanner,
    but its presence is necessary. */
 struct yy_trans_info
@@ -360,33 +360,32 @@ struct yy_trans_info
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	};
-static const flex_int16_t yy_accept[228] =
+static const flex_int16_t yy_accept[220] =
     {   0,
-        0,    0,    0,    0,    0,    0,    0,    0,   82,   73,
-       70,   72,   73,   50,   48,   49,   26,   27,   44,   42,
-       17,   43,   66,   45,   68,   68,   18,   71,   34,   36,
-       33,   69,   69,   69,   69,   46,   47,   38,   69,   69,
-       69,   69,   69,   69,   69,   69,   69,   69,   69,   69,
-       69,   69,   28,   29,   39,   72,   76,   74,   75,   80,
-       79,   78,   77,   81,    0,    0,    0,   28,    0,   32,
-       37,    0,   68,   31,   35,   30,   69,   69,   69,   69,
-       69,   53,   69,   69,   69,   69,   69,   69,   69,   69,
-       69,   69,    5,   69,   23,   69,   69,   69,   69,   69,
-
-       69,   69,   69,   69,   28,    0,    0,    0,    0,    0,
-       67,   69,   69,   69,   69,   69,   69,   69,   69,   69,
-       63,   69,   69,   69,   69,   16,   69,   69,   69,   40,
-       69,   69,   69,   69,   69,   69,   69,   69,   69,   69,
-       51,   69,    0,    0,    0,    0,    0,    3,   69,   61,
-       60,   58,   69,   69,   69,   69,   69,   69,    6,    7,
-       69,   69,   69,   69,   69,   69,   62,   69,   14,   69,
-       69,   69,   41,   69,   56,   69,    1,    2,    6,    7,
-        0,   59,   22,    8,   69,   65,   69,   69,    0,   69,
-       57,   69,   69,   69,   69,   54,   69,   69,   69,   55,
-
-        4,    2,    0,    9,   69,   69,    7,   52,   20,   24,
-       69,   69,   69,   64,   15,   52,   69,   19,   25,   69,
-       11,   10,   21,   69,   13,   12,    0
+        0,    0,    0,    0,    0,    0,    0,    0,   81,   72,
+       69,   71,   64,   50,   48,   72,   49,   26,   27,   44,
+       42,   17,   43,   65,   45,   67,   67,   18,   70,   34,
+       36,   33,   68,   68,   68,   68,   46,   47,   38,   68,
+       68,   68,   68,   68,   68,   68,   68,   68,   68,   68,
+       68,   68,   68,   28,   72,   29,   39,   71,   75,   73,
+       74,   79,   78,   77,   76,   80,    0,    0,    0,   28,
+        0,   32,   62,   37,    0,   67,   31,   35,   30,   68,
+       68,   68,   68,   53,   68,   68,   68,   68,   68,   68,
+       68,   68,   68,    5,   68,   23,   68,   68,   68,   68,
+
+       68,   68,   68,   68,   28,   63,    0,    0,    0,    0,
+        0,   66,   68,   68,   68,   68,   68,   68,   68,   68,
+       59,   68,   68,   68,   16,   68,   68,   68,   40,   68,
+       68,   68,   68,   68,   68,   68,   68,   51,   68,    0,
+        0,    0,    0,    0,    3,   68,   58,   56,   68,   68,
+       68,   68,   68,   68,    6,    7,   68,   68,   68,   68,
+       68,   68,   14,   68,   68,   68,   41,   68,   68,    1,
+        2,    6,    7,    0,   57,   22,    8,   68,   61,   68,
+       68,    0,   68,   68,   68,   68,   68,   54,   68,   68,
+       68,   55,    4,    2,    0,    9,   68,   68,    7,   52,
+
+       20,   24,   68,   68,   68,   60,   15,   52,   68,   19,
+       25,   68,   11,   10,   21,   68,   13,   12,    0
     } ;
 
 static const YY_CHAR yy_ec[256] =
@@ -394,17 +393,17 @@ static const YY_CHAR yy_ec[256] =
         1,    1,    1,    1,    1,    1,    1,    1,    1,    2,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    3,    4,    5,    6,    1,    1,    1,    7,    8,
-        9,   10,   11,   12,   13,   14,   15,   16,   17,   17,
-       17,   17,   17,   17,   17,   17,   17,   18,   19,   20,
-       21,   22,    1,    1,   23,   23,   23,   23,   23,   24,
-       23,   23,   23,   23,   23,   25,   23,   26,   23,   23,
-       23,   23,   23,   27,   28,   23,   23,   23,   23,   23,
-       29,    1,   30,   31,   23,    1,   32,   33,   34,   35,
-
-       36,   37,   38,   39,   40,   23,   41,   42,   43,   44,
-       45,   46,   47,   48,   49,   50,   51,   23,   52,   53,
-       54,   23,   55,    1,   56,   57,    1,    1,    1,    1,
+        1,    3,    4,    5,    6,    1,    1,    7,    8,    9,
+       10,   11,   12,   13,   14,   15,   16,   17,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   19,   20,   21,
+       22,   23,    1,    1,   24,   24,   24,   24,   24,   25,
+       24,   24,   24,   24,   24,   24,   24,   26,   24,   24,
+       24,   24,   24,   27,   24,   24,   24,   24,   24,   24,
+       28,    1,   29,   30,   24,    1,   31,   32,   33,   34,
+
+       35,   36,   37,   38,   39,   24,   40,   41,   42,   43,
+       44,   45,   46,   47,   48,   49,   50,   24,   51,   52,
+       53,   24,   54,   55,   56,   57,    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,
@@ -424,147 +423,143 @@ static const YY_CHAR yy_ec[256] =
 static const YY_CHAR yy_meta[58] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    2,    2,    1,    1,    1,
-        1,    1,    2,    2,    2,    2,    2,    2,    1,    1,
-        1,    2,    2,    2,    2,    2,    2,    2,    2,    2,
+        1,    1,    1,    1,    1,    1,    2,    2,    1,    1,
+        1,    1,    1,    2,    2,    2,    2,    1,    1,    1,
         2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
-        2,    2,    2,    2,    1,    1,    1
+        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
+        2,    2,    2,    1,    1,    1,    1
     } ;
 
-static const flex_int16_t yy_base[232] =
+static const flex_int16_t yy_base[224] =
     {   0,
-        0,  249,   56,   57,   59,   63,    0,    0,  251,  253,
-       69,  247,  228,  253,  253,  253,  253,  253,  238,  253,
-      253,  253,  253,  253,  253,   59,  253,  253,  226,  225,
-      224,    0,  212,   32,  195,  253,  253,  253,  193,   32,
-       36,  205,   37,   37,  198,   48,  194,   38,   52,  191,
-       47,  198,  234,  253,  253,  232,  253,  253,  253,  253,
-      253,  253,  253,  253,   91,  231,   45,  231,  229,  253,
-      253,   80,   85,  253,  253,  253,    0,  189,  205,  185,
-      177,    0,  182,   64,  194,  181,  187,   63,  189,  180,
-      173,  175,    0,  173,  184,  179,  172,  173,  174,   66,
-
-      165,  164,   56,  171,  208,  206,  205,   68,  173,  203,
-       97,  156,  179,  167,  166,  167,  168,  158,  149,  147,
-      164,  158,  158,  157,  143,    0,  158,  145,  147,    0,
-      146,  145,  137,  140,  134,  132,  146,  131,  135,  143,
-        0,  136,  174,  173,  138,  138,  137,  253,  136,    0,
-        0,    0,  130,  129,  133,  119,  127,  115,    0,  157,
-      118,  127,  130,  113,  109,  114,    0,  122,    0,  125,
-      108,  111,    0,  102,    0,  117,  253,  143,  253,  136,
-       97,    0,    0,    0,   98,    0,   97,   98,  130,   88,
-        0,   95,   86,  100,  100,    0,   85,   88,   81,    0,
-
-        0,  128,   79,    0,   77,   76,  253,    0,    0,    0,
-       89,   91,   72,    0,    0,  253,   85,    0,    0,   78,
-       83,   76,    0,   71,    0,    0,  253,  146,  148,  150,
-       65
+        0,  239,   56,   57,   59,   63,    0,    0,  241,  243,
+       67,  237,  217,  243,  243,  231,  243,  243,  243,  226,
+      243,  243,  243,  243,  243,  243,   57,  243,  243,  214,
+      213,  212,    0,  202,  188,  184,  243,  243,  243,  182,
+       19,   32,  194,   36,  184,  186,   42,  182,  181,   48,
+      178,   42,  185,  220,  166,  243,  243,  217,  243,  243,
+      243,  243,  243,  243,  243,  243,   79,  216,   45,  216,
+      214,  243,  243,  243,   73,   77,  243,  243,  243,    0,
+      175,  172,  164,    0,  169,   52,  181,  168,  174,   59,
+      176,  161,  163,    0,  161,  172,  167,  160,  163,   62,
+
+      154,  153,  146,  159,  195,  243,  193,  192,   61,  161,
+      190,   86,  144,  156,  155,  156,  157,  147,  138,  136,
+      153,  147,  147,  146,    0,  148,  135,  137,    0,  136,
+      128,  131,  125,  123,  137,  122,  126,    0,  128,  165,
+      164,  130,  130,  129,  243,  128,    0,    0,  122,  121,
+      125,  111,  119,  107,    0,  147,  110,  123,  106,  102,
+      107,  115,    0,  118,  101,  104,    0,   95,  110,  243,
+      142,  243,  134,   97,    0,    0,    0,   98,    0,   97,
+       91,  121,   81,   88,   79,   93,   93,    0,   78,   81,
+       74,    0,    0,  120,   71,    0,   69,   69,  243,    0,
+
+        0,    0,   82,   85,   66,    0,    0,  243,   77,    0,
+        0,   67,   71,   71,    0,   67,    0,    0,  243,  133,
+      135,  137,   91
     } ;
 
-static const flex_int16_t yy_def[232] =
+static const flex_int16_t yy_def[224] =
     {   0,
-      227,    1,  228,  228,  229,  229,  230,  230,  227,  227,
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
-      227,  231,  231,  231,  231,  227,  227,  227,  231,  231,
-      231,  231,  231,  231,  231,  231,  231,  231,  231,  231,
-      231,  231,  227,  227,  227,  227,  227,  227,  227,  227,
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
-      227,  227,  227,  227,  227,  227,  231,  231,  231,  231,
-      231,  231,  231,  231,  231,  231,  231,  231,  231,  231,
-      231,  231,  231,  231,  231,  231,  231,  231,  231,  231,
-
-      231,  231,  231,  231,  227,  227,  227,  227,  227,  227,
-      227,  231,  231,  231,  231,  231,  231,  231,  231,  231,
-      231,  231,  231,  231,  231,  231,  231,  231,  231,  231,
-      231,  231,  231,  231,  231,  231,  231,  231,  231,  231,
-      231,  231,  227,  227,  227,  227,  227,  227,  231,  231,
-      231,  231,  231,  231,  231,  231,  231,  231,  231,  231,
-      231,  231,  231,  231,  231,  231,  231,  231,  231,  231,
-      231,  231,  231,  231,  231,  231,  227,  227,  227,  227,
-      227,  231,  231,  231,  231,  231,  231,  231,  227,  231,
-      231,  231,  231,  231,  231,  231,  231,  231,  231,  231,
-
-      231,  227,  227,  231,  231,  231,  227,  231,  231,  231,
-      231,  231,  231,  231,  231,  227,  231,  231,  231,  231,
-      231,  231,  231,  231,  231,  231,    0,  227,  227,  227,
-      227
+      219,    1,  220,  220,  221,  221,  222,  222,  219,  219,
+      219,  219,  219,  219,  219,  219,  219,  219,  219,  219,
+      219,  219,  219,  219,  219,  219,  219,  219,  219,  219,
+      219,  219,  223,  223,  223,  223,  219,  219,  219,  223,
+      223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
+      223,  223,  223,  219,  219,  219,  219,  219,  219,  219,
+      219,  219,  219,  219,  219,  219,  219,  219,  219,  219,
+      219,  219,  219,  219,  219,  219,  219,  219,  219,  223,
+      223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
+      223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
+
+      223,  223,  223,  223,  219,  219,  219,  219,  219,  219,
+      219,  219,  223,  223,  223,  223,  223,  223,  223,  223,
+      223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
+      223,  223,  223,  223,  223,  223,  223,  223,  223,  219,
+      219,  219,  219,  219,  219,  223,  223,  223,  223,  223,
+      223,  223,  223,  223,  223,  223,  223,  223,  223,  223,
+      223,  223,  223,  223,  223,  223,  223,  223,  223,  219,
+      219,  219,  219,  219,  223,  223,  223,  223,  223,  223,
+      223,  219,  223,  223,  223,  223,  223,  223,  223,  223,
+      223,  223,  223,  219,  219,  223,  223,  223,  219,  223,
+
+      223,  223,  223,  223,  223,  223,  223,  219,  223,  223,
+      223,  223,  223,  223,  223,  223,  223,  223,    0,  219,
+      219,  219,  219
     } ;
 
-static const flex_int16_t yy_nxt[311] =
+static const flex_int16_t yy_nxt[301] =
     {   0,
        10,   11,   12,   13,   14,   15,   16,   17,   18,   19,
        20,   21,   22,   23,   24,   25,   26,   27,   28,   29,
-       30,   31,   32,   33,   32,   34,   35,   32,   36,   37,
-       38,   39,   40,   41,   42,   43,   44,   45,   32,   46,
-       32,   47,   32,   48,   32,   32,   32,   49,   50,   51,
-       32,   52,   32,   32,   53,   54,   55,   58,   58,   79,
-       61,   59,   59,   62,   61,   63,   77,   62,   90,   63,
-       65,   66,   72,   83,   73,   73,   80,   85,   88,   84,
-       86,   91,   97,   99,   93,  102,  108,  100,   98,   89,
-       94,   95,   65,   66,  103,  111,  111,  109,   72,  117,
-
-       73,   73,  122,  134,   67,  226,  140,  145,  118,  141,
-      225,  123,  111,  111,  135,  136,  146,  137,  224,  223,
-      222,  221,  220,   68,  219,  218,   67,  217,  216,  202,
-      215,  214,  213,  212,  211,  210,  209,  208,  207,  206,
-      205,  204,  203,  189,  202,   68,   57,   57,   60,   60,
-       64,   64,  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,  154,
-
-      153,  152,  151,  150,  149,  148,  147,  144,  143,  105,
-      142,  139,  138,  133,  132,  131,  130,  129,  128,  127,
-      126,  125,  124,  121,  120,  119,  116,  115,  114,  113,
-      112,  110,  105,  107,  106,  105,  104,  101,   96,   92,
-       87,   82,   81,   78,   76,   75,   74,   71,   70,   69,
-      227,   56,    9,  227,  227,  227,  227,  227,  227,  227,
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
-
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227
+       30,   31,   32,   33,   34,   35,   36,   37,   38,   39,
+       40,   41,   42,   43,   44,   45,   46,   33,   47,   33,
+       48,   33,   49,   33,   33,   33,   50,   51,   52,   33,
+       53,   33,   33,   54,   55,   56,   57,   60,   60,   85,
+       63,   61,   61,   64,   63,   86,   65,   64,   67,   68,
+       65,   75,   87,   76,   76,   88,   90,   94,   99,  102,
+       67,   68,  100,   95,   96,  109,  117,   91,  103,  112,
+      112,   75,   80,   76,   76,  118,  110,  122,  132,  142,
+
+      218,   69,  112,  112,  217,  216,  123,  215,  143,  133,
+      134,  214,  135,   69,  213,  212,  211,  210,  209,  208,
+       70,  194,  207,  206,  205,  204,  203,  202,  201,  200,
+      199,  198,   70,   59,   59,   62,   62,   66,   66,  197,
+      196,  195,  182,  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,  154,  153,  152,  151,  150,  149,  148,
+      147,  146,  145,  144,  141,  140,  105,  139,  138,  137,
+
+      136,  131,  130,  129,  128,  127,  126,  125,  124,  121,
+      120,  119,  116,  115,  114,  113,  111,  105,  108,  107,
+      106,  105,  104,  101,   98,   97,   93,   92,   89,   84,
+       83,   82,   81,   79,   78,   77,   74,   73,   72,   71,
+      219,   58,    9,  219,  219,  219,  219,  219,  219,  219,
+      219,  219,  219,  219,  219,  219,  219,  219,  219,  219,
+      219,  219,  219,  219,  219,  219,  219,  219,  219,  219,
+      219,  219,  219,  219,  219,  219,  219,  219,  219,  219,
+      219,  219,  219,  219,  219,  219,  219,  219,  219,  219,
+      219,  219,  219,  219,  219,  219,  219,  219,  219,  219
+
     } ;
 
-static const flex_int16_t yy_chk[311] =
+static const flex_int16_t yy_chk[301] =
     {   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,    3,    4,   34,
-        5,    3,    4,    5,    6,    5,  231,    6,   44,    6,
-       11,   11,   26,   40,   26,   26,   34,   41,   43,   40,
-       41,   44,   48,   49,   46,   51,   67,   49,   48,   43,
-       46,   46,   65,   65,   51,   72,   72,   67,   73,   84,
-
-       73,   73,   88,  100,   11,  224,  103,  108,   84,  103,
-      222,   88,  111,  111,  100,  100,  108,  100,  221,  220,
-      217,  213,  212,   11,  211,  206,   65,  205,  203,  202,
-      199,  198,  197,  195,  194,  193,  192,  190,  189,  188,
-      187,  185,  181,  180,  178,   65,  228,  228,  229,  229,
-      230,  230,  176,  174,  172,  171,  170,  168,  166,  165,
-      164,  163,  162,  161,  160,  158,  157,  156,  155,  154,
-      153,  149,  147,  146,  145,  144,  143,  142,  140,  139,
-      138,  137,  136,  135,  134,  133,  132,  131,  129,  128,
-      127,  125,  124,  123,  122,  121,  120,  119,  118,  117,
-
-      116,  115,  114,  113,  112,  110,  109,  107,  106,  105,
-      104,  102,  101,   99,   98,   97,   96,   95,   94,   92,
-       91,   90,   89,   87,   86,   85,   83,   81,   80,   79,
-       78,   69,   68,   66,   56,   53,   52,   50,   47,   45,
-       42,   39,   35,   33,   31,   30,   29,   19,   13,   12,
-        9,    2,  227,  227,  227,  227,  227,  227,  227,  227,
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
-
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227
+        1,    1,    1,    1,    1,    1,    1,    3,    4,   41,
+        5,    3,    4,    5,    6,   41,    5,    6,   11,   11,
+        6,   27,   42,   27,   27,   42,   44,   47,   50,   52,
+       67,   67,   50,   47,   47,   69,   86,   44,   52,   75,
+       75,   76,  223,   76,   76,   86,   69,   90,  100,  109,
+
+      216,   11,  112,  112,  214,  213,   90,  212,  109,  100,
+      100,  209,  100,   67,  205,  204,  203,  198,  197,  195,
+       11,  194,  191,  190,  189,  187,  186,  185,  184,  183,
+      182,  181,   67,  220,  220,  221,  221,  222,  222,  180,
+      178,  174,  173,  171,  169,  168,  166,  165,  164,  162,
+      161,  160,  159,  158,  157,  156,  154,  153,  152,  151,
+      150,  149,  146,  144,  143,  142,  141,  140,  139,  137,
+      136,  135,  134,  133,  132,  131,  130,  128,  127,  126,
+      124,  123,  122,  121,  120,  119,  118,  117,  116,  115,
+      114,  113,  111,  110,  108,  107,  105,  104,  103,  102,
+
+      101,   99,   98,   97,   96,   95,   93,   92,   91,   89,
+       88,   87,   85,   83,   82,   81,   71,   70,   68,   58,
+       55,   54,   53,   51,   49,   48,   46,   45,   43,   40,
+       36,   35,   34,   32,   31,   30,   20,   16,   13,   12,
+        9,    2,  219,  219,  219,  219,  219,  219,  219,  219,
+      219,  219,  219,  219,  219,  219,  219,  219,  219,  219,
+      219,  219,  219,  219,  219,  219,  219,  219,  219,  219,
+      219,  219,  219,  219,  219,  219,  219,  219,  219,  219,
+      219,  219,  219,  219,  219,  219,  219,  219,  219,  219,
+      219,  219,  219,  219,  219,  219,  219,  219,  219,  219
+
     } ;
 
 static yy_state_type yy_last_accepting_state;
@@ -592,9 +587,9 @@ char *yytext;
     int flat = 0;
     int is_last = 0;  // 是否\n
     int is_stop = 0;  // 针对}需要返回一个}的同时返回一个STOP
-#line 595 "lex.yy.c"
+#line 590 "lex.yy.c"
 
-#line 597 "lex.yy.c"
+#line 592 "lex.yy.c"
 
 #define INITIAL 0
 #define COMMENT 1
@@ -819,7 +814,7 @@ YY_DECL
 	{
 #line 13 "gwarf_lex.l"
 
-#line 822 "lex.yy.c"
+#line 817 "lex.yy.c"
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
@@ -847,13 +842,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 >= 228 )
+				if ( yy_current_state >= 220 )
 					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] != 253 );
+		while ( yy_base[yy_current_state] != 243 );
 
 yy_find_action:
 		yy_act = yy_accept[yy_current_state];
@@ -1178,95 +1173,95 @@ YY_RULE_SETUP
 case 58:
 YY_RULE_SETUP
 #line 84 "gwarf_lex.l"
-{return TRUE;}
+{return NULL_token;}
 	YY_BREAK
 case 59:
 YY_RULE_SETUP
 #line 85 "gwarf_lex.l"
-{return FALSE;}
+{return DEF;}
 	YY_BREAK
 case 60:
 YY_RULE_SETUP
 #line 86 "gwarf_lex.l"
-{return NULL_token;}
+{return RETURN;}
 	YY_BREAK
 case 61:
 YY_RULE_SETUP
 #line 87 "gwarf_lex.l"
-{return NULL_token;}
+{return CLASS;}
 	YY_BREAK
 case 62:
 YY_RULE_SETUP
 #line 88 "gwarf_lex.l"
-{return NULL_token;}
+{return AND;}
 	YY_BREAK
 case 63:
 YY_RULE_SETUP
 #line 89 "gwarf_lex.l"
-{return DEF;}
+{return OR;}
 	YY_BREAK
 case 64:
 YY_RULE_SETUP
 #line 90 "gwarf_lex.l"
-{return RETURN;}
+{return NOT;}
 	YY_BREAK
 case 65:
 YY_RULE_SETUP
 #line 91 "gwarf_lex.l"
-{return CLASS;}
-	YY_BREAK
-case 66:
-YY_RULE_SETUP
-#line 92 "gwarf_lex.l"
 {return POINT;}
 	YY_BREAK
-case 67:
+case 66:
 YY_RULE_SETUP
-#line 94 "gwarf_lex.l"
+#line 93 "gwarf_lex.l"
 {
     yylval.double_value = atof(yytext);
     return NUMBER;
     }
 	YY_BREAK
-case 68:
+case 67:
 YY_RULE_SETUP
-#line 98 "gwarf_lex.l"
+#line 97 "gwarf_lex.l"
 {
     yylval.double_value = atof(yytext);
     return INT;
     }
 	YY_BREAK
-case 69:
+case 68:
 YY_RULE_SETUP
-#line 102 "gwarf_lex.l"
+#line 101 "gwarf_lex.l"
 {
     yylval.string_value = yytext;
     return VAR;
     }
 	YY_BREAK
+case 69:
+/* rule 69 can match eol */
+YY_RULE_SETUP
+#line 105 "gwarf_lex.l"
+{return STOPN;}
+	YY_BREAK
 case 70:
-/* rule 70 can match eol */
 YY_RULE_SETUP
 #line 106 "gwarf_lex.l"
-{return STOPN;}
+{return STOPF;}
 	YY_BREAK
 case 71:
 YY_RULE_SETUP
 #line 107 "gwarf_lex.l"
-{return STOPF;}
+;
 	YY_BREAK
 case 72:
 YY_RULE_SETUP
 #line 108 "gwarf_lex.l"
-;
+{printf("other text = [%s];\n", yytext);}
 	YY_BREAK
 case 73:
+/* rule 73 can match eol */
 YY_RULE_SETUP
-#line 109 "gwarf_lex.l"
-{printf("other text = [%s];\n", yytext);}
+#line 110 "gwarf_lex.l"
+{BEGIN INITIAL;}
 	YY_BREAK
 case 74:
-/* rule 74 can match eol */
 YY_RULE_SETUP
 #line 111 "gwarf_lex.l"
 {BEGIN INITIAL;}
@@ -1274,12 +1269,12 @@ YY_RULE_SETUP
 case 75:
 YY_RULE_SETUP
 #line 112 "gwarf_lex.l"
-{BEGIN INITIAL;}
+;
 	YY_BREAK
 case 76:
 YY_RULE_SETUP
-#line 113 "gwarf_lex.l"
-;
+#line 114 "gwarf_lex.l"
+{BEGIN INITIAL;}
 	YY_BREAK
 case 77:
 YY_RULE_SETUP
@@ -1287,33 +1282,28 @@ YY_RULE_SETUP
 {BEGIN INITIAL;}
 	YY_BREAK
 case 78:
+/* rule 78 can match eol */
 YY_RULE_SETUP
 #line 116 "gwarf_lex.l"
-{BEGIN INITIAL;}
-	YY_BREAK
-case 79:
-/* rule 79 can match eol */
-YY_RULE_SETUP
-#line 117 "gwarf_lex.l"
 {
     yylval.string_value = yytext;
     return STRING;
     }
 	YY_BREAK
-case 80:
+case 79:
 YY_RULE_SETUP
-#line 121 "gwarf_lex.l"
+#line 120 "gwarf_lex.l"
 {
     yylval.string_value = yytext;
     return STRING;
     }
 	YY_BREAK
-case 81:
+case 80:
 YY_RULE_SETUP
-#line 125 "gwarf_lex.l"
+#line 124 "gwarf_lex.l"
 ECHO;
 	YY_BREAK
-#line 1316 "lex.yy.c"
+#line 1306 "lex.yy.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(COMMENT):
 case YY_STATE_EOF(STRING_TEXT):
@@ -1614,7 +1604,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 >= 228 )
+			if ( yy_current_state >= 220 )
 				yy_c = yy_meta[yy_c];
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -1642,11 +1632,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 >= 228 )
+		if ( yy_current_state >= 220 )
 			yy_c = yy_meta[yy_c];
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
-	yy_is_jam = (yy_current_state == 227);
+	yy_is_jam = (yy_current_state == 219);
 
 		return yy_is_jam ? 0 : yy_current_state;
 }
@@ -2324,7 +2314,7 @@ void yyfree (void * ptr )
 
 #define YYTABLES_NAME "yytables"
 
-#line 125 "gwarf_lex.l"
+#line 124 "gwarf_lex.l"
 
 int yywrap(void) {
     return 1;

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


+ 8 - 2
paser/y.tab.h

@@ -109,7 +109,10 @@ extern int yydebug;
     THROW = 315,
     IMPORT = 316,
     INCLUDE = 317,
-    IN = 318
+    IN = 318,
+    AND = 319,
+    OR = 320,
+    NOT = 321
   };
 #endif
 /* Tokens.  */
@@ -174,6 +177,9 @@ extern int yydebug;
 #define IMPORT 316
 #define INCLUDE 317
 #define IN 318
+#define AND 319
+#define OR 320
+#define NOT 321
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@@ -188,7 +194,7 @@ union YYSTYPE
     struct if_list *if_list_base;
     struct parameter *parameter_list;
 
-#line 192 "y.tab.h"
+#line 198 "y.tab.h"
 
 };
 typedef union YYSTYPE YYSTYPE;

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