Browse Source

实现while循环和break语句

SongZihuan 5 years ago
parent
commit
25366f926f
9 changed files with 381 additions and 244 deletions
  1. BIN
      gwarf
  2. 13 2
      gwarf_interpreter/interprete.h
  3. BIN
      gwarf_interpreter/interpreter
  4. 40 6
      gwarf_interpreter/interpreter.c
  5. 1 0
      paser/gwarf_lex.l
  6. 37 6
      paser/gwarf_yacc.y
  7. 114 102
      paser/lex.yy.c
  8. 172 126
      paser/y.tab.c
  9. 4 2
      paser/y.tab.h

BIN
gwarf


+ 13 - 2
gwarf_interpreter/interprete.h

@@ -36,6 +36,7 @@ typedef struct statement{
         base_var,  // return var address
         base_value,  // return an number or number
         while_cycle,  // while
+        break_cycle,  // break
     } type;  // the statement type
 
     union
@@ -58,6 +59,11 @@ typedef struct statement{
             struct statement *left_exp;  // the left exp
         } operation;
 
+        struct{
+            struct statement *condition;  // when to while 
+            struct statement *done;  // while to do
+        } while_cycle;
+
         struct{
             char *var_name;  // return var
         } base_var;
@@ -65,6 +71,10 @@ typedef struct statement{
         struct{
             GWARF_value value;  // return value
         } base_value;
+
+        struct{
+        } break_cycle;
+
     } code;
     struct statement *next;
 } statement;
@@ -75,8 +85,9 @@ typedef struct GWARF_result{
     GWARF_value value;
     enum{
         return_def=1,
-        break_while,
-        wrong,
+        statement_end,
+        cycle_break,
+        name_no_found,
     } u;  // the result type[from where]
 } GWARF_result;
 

BIN
gwarf_interpreter/interpreter


+ 40 - 6
gwarf_interpreter/interpreter.c

@@ -4,6 +4,7 @@
 #include "../paser/y.tab.c"
 
 // running code
+GWARF_result while_func(statement *, var_list *);
 GWARF_result operation_func(statement *, var_list *);
 GWARF_result add_func(GWARF_result, GWARF_result, var_list *);
 GWARF_result sub_func(GWARF_result, GWARF_result, var_list *);
@@ -26,7 +27,7 @@ void append_var(char *name, GWARF_value value, var *base_var){
     int break_ = 1;  // get var[2] or not[1]
     var *tmp = base_var;  // iter var
     while(1){
-        if (tmp->name == name){
+        if (!strcmp(tmp->name, name)){
             break_ = 2;
             break;
         }
@@ -163,8 +164,8 @@ var *find_var(var_list *var_base,int from, char *name){  // find var by func get
 void add_var(var_list *var_base,int from, char *name, GWARF_value value){  // add var by func append_var in var_list[iter to find]
     var_list *start = var_base;
     var *return_var;
-    for(int i = 0;i < from;i+= 1){
-        if(start->next = NULL){
+    for(int i = 0;i < 100;i+= 1){
+        if(start->next == NULL){
             break;
         }
         start = start->next;
@@ -197,7 +198,7 @@ statement_list *append_statement_list(statement *statement_base, statement_list
 statement *find_statement_list(int from, statement_list *statment_list_base){  // find var by func get_var in var_list[iter to find]
     statement_list *start = statment_list_base;
     for(int i = 0;i < from;i+= 1){
-        if(start->next = NULL){
+        if(start->next == NULL){
             break;
         }
         start = start->next;
@@ -218,20 +219,27 @@ statement_list *free_statement_list(statement_list *statment_list_base){  // mak
 
 GWARF_result read_statement_list(statement *the_statement, var_list *the_var){  // read the statement list with case to run by func
     GWARF_result return_value;
+    return_value.u = statement_end;  // 正常设置[正常语句结束]
+    return_value.value.type = NUMBER_value;  // 默认设置
+    return_value.value.value.double_value = 0;  // 默认设置
     switch (the_statement->type)
     {
         case operation:  // 表达式运算
             return_value = operation_func(the_statement, the_var);
             printf("operation value = %f\n", return_value.value.value.double_value);
             break;
-        case base_value:
+        case while_cycle:
+            return_value = while_func(the_statement, the_var);
+            printf("while operation value = %f\n", return_value.value.value.double_value);
+            break;
+        case base_value:  // get value[所有字面量均为这个表达式]
             return_value.value = (the_statement->code).base_value.value;  // code
             printf("get value = %f\n", return_value.value.value.double_value);
             break;
         case base_var:{    // because the var tmp, we should ues a {} to make a block[name space] for the tmp var;
             var *tmp = find_var(the_var, 0, (the_statement->code).base_var.var_name);
             if(tmp == NULL){
-                return_value.u = wrong;  // not var
+                return_value.u = name_no_found;  // nameerror
             }
             else
             {
@@ -240,6 +248,9 @@ GWARF_result read_statement_list(statement *the_statement, var_list *the_var){
             }
             break;
         }
+        case break_cycle:
+            return_value.u = cycle_break;
+            break;
         default:
             puts("default");
             break;
@@ -247,6 +258,26 @@ GWARF_result read_statement_list(statement *the_statement, var_list *the_var){
     return return_value;
 }
 
+// -----------------while func
+
+GWARF_result while_func(statement *the_statement, var_list *the_var){  // read the statement list with case to run by func
+    GWARF_result value, condition;
+    while (1){
+        condition = traverse((*the_statement).code.while_cycle.condition, the_var, false);
+        printf("condition = %f\n", condition.value.value.double_value);
+        if(!condition.value.value.double_value){
+            break;
+        }
+        puts("----while----");
+        value = traverse((*the_statement).code.operation.right_exp, the_var, false);
+        puts("----stop while----");
+        if(value.u == cycle_break){  // break the while
+            break;
+        }
+    }
+    return value;
+}
+
 // -----------------operation func
 
 GWARF_result operation_func(statement *the_statement, var_list *the_var){  // read the statement list with case to run by func
@@ -385,6 +416,9 @@ GWARF_result traverse(statement *the_statement, var_list *the_var, bool new){  /
             break;  // off
         }
         result = read_statement_list(tmp, the_var);
+        if(result.u == cycle_break){  // don't next the statement and return the result [the while_func[or for func] will get the result and stop cycle]
+            break;
+        }
         tmp = tmp->next;
     }
     return result;

+ 1 - 0
paser/gwarf_lex.l

@@ -5,6 +5,7 @@
 %s COMMENT STRING_TEXT
 %%
 <INITIAL>"while" {return WHILE;}
+<INITIAL>"break" {return BREAK;}
 
 <INITIAL>"(" {return LB;}
 <INITIAL>")" {return RB;}

+ 37 - 6
paser/gwarf_yacc.y

@@ -13,13 +13,12 @@
 }
 %token <double_value> NUMBER
 %token <string_value> STRING VAR
-%token ADD SUB DIV MUL EQ LESS MORE RB LB RP LP WHILE STOP POW EQUAL MOREEQ LESSEQ NOTEQ
-%type <statement_value> base_number base_var_ element second_number first_number top_exp command third_number
+%token ADD SUB DIV MUL EQ LESS MORE RB LB RP LP WHILE STOP POW EQUAL MOREEQ LESSEQ NOTEQ BREAK
+%type <statement_value> base_number base_var_ element second_number first_number top_exp command third_number while_block while_exp break_exp
 
 %%
 command_block
     : command_list
-    | while_block
     ;
 
 command_list
@@ -37,6 +36,13 @@ command_list
             append_statement(tmp, $2);
         }
     }
+    | while_block
+    {   
+        if($1 != NULL){
+            statement *tmp = find_statement_list(0, statement_base);
+            append_statement(tmp, $1);
+        }
+    }
     ;
 
 command
@@ -48,6 +54,14 @@ command
     {
         $$ = $1;
     }
+    | while_block STOP
+    {   
+        $$ = $1;
+    }
+    | break_exp STOP
+    {
+        $$ = $1;
+    }
     ;
 
 top_exp
@@ -203,20 +217,37 @@ base_var_
 while_block
     : while_exp block
     {
-        printf("start-1\n");
+        statement_base = free_statement_list(statement_base);  // new statement_base (FILO)
     }
+    ;
 
 while_exp
     : WHILE LB top_exp RB
     {
-        printf("start-2\n");
+        statement *while_tmp =  make_statement();
+        while_tmp->type = while_cycle;
+        while_tmp->code.while_cycle.condition = $3;
+        while_tmp->code.while_cycle.done = make_statement();
+        statement_base = append_statement_list(while_tmp->code.while_cycle.done, statement_base);  // new statement_base (FILO)
+        $$ = while_tmp;
     }
+    ;
 
 block
-    : LP command_list RP STOP
+    : LP command_list RP
     {
         printf("start-0\n");
     }
+    ;
+
+break_exp
+    : BREAK
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = break_cycle;
+        $$ = code_tmp;
+    }
+    ;
 
 %%
 int yyerror(char const *str)

+ 114 - 102
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 34
-#define YY_END_OF_BUFFER 35
+#define YY_NUM_RULES 35
+#define YY_END_OF_BUFFER 36
 /* This struct is not used in this scanner,
    but its presence is necessary. */
 struct yy_trans_info
@@ -360,14 +360,14 @@ struct yy_trans_info
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	};
-static const flex_int16_t yy_accept[55] =
+static const flex_int16_t yy_accept[60] =
     {   0,
-        0,    0,    0,    0,    0,    0,   35,   26,   24,   23,
-       26,   20,   18,   19,    2,    3,   15,   13,   14,   16,
-       21,   21,   25,   10,   12,    9,   22,   17,   22,    4,
-        5,   29,   27,   28,   33,   32,   31,   30,    0,    4,
-        8,    0,   21,    7,   11,    6,   22,   22,    4,   21,
-       22,   22,    1,    0
+        0,    0,    0,    0,    0,    0,   36,   27,   25,   24,
+       27,   21,   19,   20,    3,    4,   16,   14,   15,   17,
+       22,   22,   26,   11,   13,   10,   23,   18,   23,   23,
+        5,    6,   30,   28,   29,   34,   33,   32,   31,    0,
+        5,    9,    0,   22,    8,   12,    7,   23,   23,   23,
+        5,   22,   23,   23,   23,   23,    2,    1,    0
     } ;
 
 static const YY_CHAR yy_ec[256] =
@@ -381,11 +381,11 @@ static const YY_CHAR yy_ec[256] =
        19,   20,    1,    1,   21,   21,   21,   21,   21,   21,
        21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
        21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-        1,    1,    1,   22,   21,    1,   21,   21,   21,   21,
+        1,    1,    1,   22,   21,    1,   23,   24,   21,   21,
 
-       23,   21,   21,   24,   25,   21,   21,   26,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   27,   21,
-       21,   21,   28,    1,   29,    1,    1,    1,    1,    1,
+       25,   21,   21,   26,   27,   21,   28,   29,   21,   21,
+       21,   21,   21,   30,   21,   21,   21,   21,   31,   21,
+       21,   21,   32,    1,   33,    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,
@@ -402,61 +402,68 @@ static const YY_CHAR yy_ec[256] =
         1,    1,    1,    1,    1
     } ;
 
-static const YY_CHAR yy_meta[30] =
+static const YY_CHAR yy_meta[34] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    2,    2,    1,    1,    1,    1,
-        2,    1,    2,    2,    2,    2,    2,    1,    1
+        2,    1,    2,    2,    2,    2,    2,    2,    2,    2,
+        2,    1,    1
     } ;
 
-static const flex_int16_t yy_base[58] =
+static const flex_int16_t yy_base[63] =
     {   0,
-        0,    0,   28,   29,   31,   35,   70,   71,   30,   71,
-       45,   71,   71,   71,   71,   71,   71,   71,   71,   71,
-       71,   28,   71,   44,   43,   42,    0,   71,   36,   57,
-       71,   71,   71,   71,   71,   71,   71,   71,   37,   55,
-       71,   30,   34,   71,   71,   71,    0,   31,   53,   36,
-       28,   30,    0,   71,   65,   67,   46
+        0,    0,   32,   33,   35,   39,   78,   79,   34,   79,
+       53,   79,   79,   79,   79,   79,   79,   79,   79,   79,
+       79,   32,   79,   52,   51,   50,    0,   79,   38,   41,
+       63,   79,   79,   79,   79,   79,   79,   79,   79,   41,
+       62,   79,   34,   38,   79,   79,   79,    0,   38,   35,
+       59,   40,   37,   30,   30,   32,    0,    0,   79,   73,
+       75,   50
     } ;
 
-static const flex_int16_t yy_def[58] =
+static const flex_int16_t yy_def[63] =
     {   0,
-       54,    1,   55,   55,   56,   56,   54,   54,   54,   54,
-       54,   54,   54,   54,   54,   54,   54,   54,   54,   54,
-       54,   54,   54,   54,   54,   54,   57,   54,   57,   54,
-       54,   54,   54,   54,   54,   54,   54,   54,   54,   54,
-       54,   54,   54,   54,   54,   54,   57,   57,   54,   54,
-       57,   57,   57,    0,   54,   54,   54
+       59,    1,   60,   60,   61,   61,   59,   59,   59,   59,
+       59,   59,   59,   59,   59,   59,   59,   59,   59,   59,
+       59,   59,   59,   59,   59,   59,   62,   59,   62,   62,
+       59,   59,   59,   59,   59,   59,   59,   59,   59,   59,
+       59,   59,   59,   59,   59,   59,   59,   62,   62,   62,
+       59,   59,   62,   62,   62,   62,   62,   62,    0,   59,
+       59,   59
     } ;
 
-static const flex_int16_t yy_nxt[101] =
+static const flex_int16_t yy_nxt[113] =
     {   0,
         8,    9,   10,   11,   12,   13,   14,   15,   16,   17,
        18,   19,    8,   20,   21,   22,   23,   24,   25,   26,
-       27,   28,   27,   27,   27,   27,   29,   30,   31,   33,
-       33,   39,   36,   34,   34,   37,   36,   38,   39,   37,
-       42,   38,   43,   43,   50,   50,   42,   47,   43,   43,
-       50,   50,   53,   52,   49,   51,   49,   40,   49,   48,
-       46,   45,   44,   41,   40,   32,   32,   35,   35,   54,
-        7,   54,   54,   54,   54,   54,   54,   54,   54,   54,
-       54,   54,   54,   54,   54,   54,   54,   54,   54,   54,
-       54,   54,   54,   54,   54,   54,   54,   54,   54,   54
-
+       27,   28,   27,   29,   27,   27,   27,   27,   27,   27,
+       30,   31,   32,   34,   34,   40,   37,   35,   35,   38,
+       37,   39,   40,   38,   43,   39,   44,   44,   52,   52,
+       43,   48,   44,   44,   52,   52,   58,   57,   56,   55,
+       51,   54,   53,   51,   51,   41,   50,   49,   47,   46,
+       45,   42,   41,   33,   33,   36,   36,   59,    7,   59,
+       59,   59,   59,   59,   59,   59,   59,   59,   59,   59,
+       59,   59,   59,   59,   59,   59,   59,   59,   59,   59,
+
+       59,   59,   59,   59,   59,   59,   59,   59,   59,   59,
+       59,   59
     } ;
 
-static const flex_int16_t yy_chk[101] =
+static const flex_int16_t yy_chk[113] =
     {   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,    3,
-        4,    9,    5,    3,    4,    5,    6,    5,   39,    6,
-       22,    6,   22,   22,   42,   42,   43,   57,   43,   43,
-       50,   50,   52,   51,   49,   48,   40,    9,   30,   29,
-       26,   25,   24,   11,   39,   55,   55,   56,   56,    7,
-       54,   54,   54,   54,   54,   54,   54,   54,   54,   54,
-       54,   54,   54,   54,   54,   54,   54,   54,   54,   54,
-       54,   54,   54,   54,   54,   54,   54,   54,   54,   54
-
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    3,    4,    9,    5,    3,    4,    5,
+        6,    5,   40,    6,   22,    6,   22,   22,   43,   43,
+       44,   62,   44,   44,   52,   52,   56,   55,   54,   53,
+       51,   50,   49,   41,   31,    9,   30,   29,   26,   25,
+       24,   11,   40,   60,   60,   61,   61,    7,   59,   59,
+       59,   59,   59,   59,   59,   59,   59,   59,   59,   59,
+       59,   59,   59,   59,   59,   59,   59,   59,   59,   59,
+
+       59,   59,   59,   59,   59,   59,   59,   59,   59,   59,
+       59,   59
     } ;
 
 static yy_state_type yy_last_accepting_state;
@@ -477,9 +484,9 @@ char *yytext;
 #line 2 "gwarf_lex.l"
     #include<stdio.h>
     #include"y.tab.h"
-#line 480 "lex.yy.c"
+#line 487 "lex.yy.c"
 
-#line 482 "lex.yy.c"
+#line 489 "lex.yy.c"
 
 #define INITIAL 0
 #define COMMENT 1
@@ -700,7 +707,7 @@ YY_DECL
 	{
 #line 6 "gwarf_lex.l"
 
-#line 703 "lex.yy.c"
+#line 710 "lex.yy.c"
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
@@ -727,13 +734,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 >= 55 )
+				if ( yy_current_state >= 60 )
 					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] != 71 );
+		while ( yy_base[yy_current_state] != 79 );
 
 yy_find_action:
 		yy_act = yy_accept[yy_current_state];
@@ -764,94 +771,94 @@ YY_RULE_SETUP
 	YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 9 "gwarf_lex.l"
-{return LB;}
+#line 8 "gwarf_lex.l"
+{return BREAK;}
 	YY_BREAK
 case 3:
 YY_RULE_SETUP
 #line 10 "gwarf_lex.l"
-{return RB;}
+{return LB;}
 	YY_BREAK
 case 4:
-/* rule 4 can match eol */
 YY_RULE_SETUP
 #line 11 "gwarf_lex.l"
-{return LP;}
+{return RB;}
 	YY_BREAK
 case 5:
+/* rule 5 can match eol */
 YY_RULE_SETUP
 #line 12 "gwarf_lex.l"
-{return RP;}
+{return LP;}
 	YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 14 "gwarf_lex.l"
-{return MOREEQ;}
+#line 13 "gwarf_lex.l"
+{return RP;}
 	YY_BREAK
 case 7:
 YY_RULE_SETUP
 #line 15 "gwarf_lex.l"
-{return LESSEQ;}
+{return MOREEQ;}
 	YY_BREAK
 case 8:
 YY_RULE_SETUP
 #line 16 "gwarf_lex.l"
-{return NOTEQ;}
+{return LESSEQ;}
 	YY_BREAK
 case 9:
 YY_RULE_SETUP
 #line 17 "gwarf_lex.l"
-{return MORE;}
+{return NOTEQ;}
 	YY_BREAK
 case 10:
 YY_RULE_SETUP
 #line 18 "gwarf_lex.l"
-{return LESS;}
+{return MORE;}
 	YY_BREAK
 case 11:
 YY_RULE_SETUP
 #line 19 "gwarf_lex.l"
-{return EQUAL;}
+{return LESS;}
 	YY_BREAK
 case 12:
 YY_RULE_SETUP
 #line 20 "gwarf_lex.l"
-{return EQ;}
+{return EQUAL;}
 	YY_BREAK
 case 13:
 YY_RULE_SETUP
 #line 21 "gwarf_lex.l"
-{return ADD;}
+{return EQ;}
 	YY_BREAK
 case 14:
 YY_RULE_SETUP
 #line 22 "gwarf_lex.l"
-{return SUB;}
+{return ADD;}
 	YY_BREAK
 case 15:
 YY_RULE_SETUP
 #line 23 "gwarf_lex.l"
-{return MUL;}
+{return SUB;}
 	YY_BREAK
 case 16:
 YY_RULE_SETUP
 #line 24 "gwarf_lex.l"
-{return DIV;}
+{return MUL;}
 	YY_BREAK
 case 17:
 YY_RULE_SETUP
 #line 25 "gwarf_lex.l"
-{return POW;}
+{return DIV;}
 	YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 27 "gwarf_lex.l"
-{BEGIN COMMENT;}
+#line 26 "gwarf_lex.l"
+{return POW;}
 	YY_BREAK
 case 19:
 YY_RULE_SETUP
 #line 28 "gwarf_lex.l"
-{BEGIN STRING_TEXT;}
+{BEGIN COMMENT;}
 	YY_BREAK
 case 20:
 YY_RULE_SETUP
@@ -861,31 +868,31 @@ YY_RULE_SETUP
 case 21:
 YY_RULE_SETUP
 #line 30 "gwarf_lex.l"
+{BEGIN STRING_TEXT;}
+	YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 31 "gwarf_lex.l"
 {
     yylval.double_value = atof(yytext);
     return NUMBER;
     }
 	YY_BREAK
-case 22:
+case 23:
 YY_RULE_SETUP
-#line 34 "gwarf_lex.l"
+#line 35 "gwarf_lex.l"
 {
     yylval.string_value = yytext;
     return VAR;
     }
 	YY_BREAK
-case 23:
-YY_RULE_SETUP
-#line 39 "gwarf_lex.l"
-;
-	YY_BREAK
 case 24:
-/* rule 24 can match eol */
 YY_RULE_SETUP
 #line 40 "gwarf_lex.l"
-{return STOP;}
+;
 	YY_BREAK
 case 25:
+/* rule 25 can match eol */
 YY_RULE_SETUP
 #line 41 "gwarf_lex.l"
 {return STOP;}
@@ -893,15 +900,15 @@ YY_RULE_SETUP
 case 26:
 YY_RULE_SETUP
 #line 42 "gwarf_lex.l"
-{printf("text = [%s];\n", yytext);}
+{return STOP;}
 	YY_BREAK
 case 27:
-/* rule 27 can match eol */
 YY_RULE_SETUP
-#line 44 "gwarf_lex.l"
-{BEGIN INITIAL;}
+#line 43 "gwarf_lex.l"
+{printf("text = [%s];\n", yytext);}
 	YY_BREAK
 case 28:
+/* rule 28 can match eol */
 YY_RULE_SETUP
 #line 45 "gwarf_lex.l"
 {BEGIN INITIAL;}
@@ -909,12 +916,12 @@ YY_RULE_SETUP
 case 29:
 YY_RULE_SETUP
 #line 46 "gwarf_lex.l"
-;
+{BEGIN INITIAL;}
 	YY_BREAK
 case 30:
 YY_RULE_SETUP
-#line 48 "gwarf_lex.l"
-{BEGIN INITIAL;}
+#line 47 "gwarf_lex.l"
+;
 	YY_BREAK
 case 31:
 YY_RULE_SETUP
@@ -922,28 +929,33 @@ YY_RULE_SETUP
 {BEGIN INITIAL;}
 	YY_BREAK
 case 32:
-/* rule 32 can match eol */
 YY_RULE_SETUP
 #line 50 "gwarf_lex.l"
+{BEGIN INITIAL;}
+	YY_BREAK
+case 33:
+/* rule 33 can match eol */
+YY_RULE_SETUP
+#line 51 "gwarf_lex.l"
 {
     yylval.string_value = yytext;
     return STRING;
     }
 	YY_BREAK
-case 33:
+case 34:
 YY_RULE_SETUP
-#line 54 "gwarf_lex.l"
+#line 55 "gwarf_lex.l"
 {
     yylval.string_value = yytext;
     return STRING;
     }
 	YY_BREAK
-case 34:
+case 35:
 YY_RULE_SETUP
-#line 58 "gwarf_lex.l"
+#line 59 "gwarf_lex.l"
 ECHO;
 	YY_BREAK
-#line 946 "lex.yy.c"
+#line 958 "lex.yy.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(COMMENT):
 case YY_STATE_EOF(STRING_TEXT):
@@ -1242,7 +1254,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 >= 55 )
+			if ( yy_current_state >= 60 )
 				yy_c = yy_meta[yy_c];
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -1270,11 +1282,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 >= 55 )
+		if ( yy_current_state >= 60 )
 			yy_c = yy_meta[yy_c];
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
-	yy_is_jam = (yy_current_state == 54);
+	yy_is_jam = (yy_current_state == 59);
 
 		return yy_is_jam ? 0 : yy_current_state;
 }
@@ -1950,7 +1962,7 @@ void yyfree (void * ptr )
 
 #define YYTABLES_NAME "yytables"
 
-#line 58 "gwarf_lex.l"
+#line 59 "gwarf_lex.l"
 
 int yywrap(void) {
     return 1;

+ 172 - 126
paser/y.tab.c

@@ -141,7 +141,8 @@ extern int yydebug;
     EQUAL = 275,
     MOREEQ = 276,
     LESSEQ = 277,
-    NOTEQ = 278
+    NOTEQ = 278,
+    BREAK = 279
   };
 #endif
 /* Tokens.  */
@@ -166,6 +167,7 @@ extern int yydebug;
 #define MOREEQ 276
 #define LESSEQ 277
 #define NOTEQ 278
+#define BREAK 279
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@@ -178,7 +180,7 @@ union YYSTYPE
     char *string_value;
     void *statement_value;
 
-#line 182 "y.tab.c"
+#line 184 "y.tab.c"
 
 };
 typedef union YYSTYPE YYSTYPE;
@@ -495,21 +497,21 @@ union yyalloc
 #endif /* !YYCOPY_NEEDED */
 
 /* YYFINAL -- State number of the termination state.  */
-#define YYFINAL  20
+#define YYFINAL  22
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   59
+#define YYLAST   61
 
 /* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  24
+#define YYNTOKENS  25
 /* YYNNTS -- Number of nonterminals.  */
-#define YYNNTS  14
+#define YYNNTS  15
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  30
+#define YYNRULES  33
 /* YYNSTATES -- Number of states.  */
-#define YYNSTATES  54
+#define YYNSTATES  58
 
 #define YYUNDEFTOK  2
-#define YYMAXUTOK   278
+#define YYMAXUTOK   279
 
 
 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
@@ -548,17 +550,17 @@ static const yytype_int8 yytranslate[] =
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
-      15,    16,    17,    18,    19,    20,    21,    22,    23
+      15,    16,    17,    18,    19,    20,    21,    22,    23,    24
 };
 
 #if YYDEBUG
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
 static const yytype_uint8 yyrline[] =
 {
-       0,    21,    21,    22,    26,    33,    43,    47,    54,    58,
-      70,    71,    80,    89,    98,   107,   116,   128,   129,   138,
-     150,   151,   160,   172,   173,   174,   181,   192,   204,   210,
-     216
+       0,    21,    21,    25,    32,    39,    49,    53,    57,    61,
+      68,    72,    84,    85,    94,   103,   112,   121,   130,   142,
+     143,   152,   164,   165,   174,   186,   187,   188,   195,   206,
+     218,   225,   237,   244
 };
 #endif
 
@@ -569,10 +571,10 @@ static const char *const yytname[] =
 {
   "$end", "error", "$undefined", "NUMBER", "STRING", "VAR", "ADD", "SUB",
   "DIV", "MUL", "EQ", "LESS", "MORE", "RB", "LB", "RP", "LP", "WHILE",
-  "STOP", "POW", "EQUAL", "MOREEQ", "LESSEQ", "NOTEQ", "$accept",
+  "STOP", "POW", "EQUAL", "MOREEQ", "LESSEQ", "NOTEQ", "BREAK", "$accept",
   "command_block", "command_list", "command", "top_exp", "third_number",
   "second_number", "first_number", "element", "base_number", "base_var_",
-  "while_block", "while_exp", "block", YY_NULLPTR
+  "while_block", "while_exp", "block", "break_exp", YY_NULLPTR
 };
 #endif
 
@@ -583,11 +585,11 @@ static const yytype_int16 yytoknum[] =
 {
        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
-     275,   276,   277,   278
+     275,   276,   277,   278,   279
 };
 # endif
 
-#define YYPACT_NINF (-7)
+#define YYPACT_NINF (-9)
 
 #define yypact_value_is_default(Yyn) \
   ((Yyn) == YYPACT_NINF)
@@ -601,12 +603,12 @@ static const yytype_int16 yytoknum[] =
      STATE-NUM.  */
 static const yytype_int8 yypact[] =
 {
-       3,    -7,    -7,    37,    10,    -7,    12,    11,    -7,    -3,
-      16,    -2,     1,    -7,    -7,    20,    -7,    15,    22,    37,
-      -7,    -7,    -7,    37,    37,    37,    37,    37,    37,    37,
-      37,    37,    37,    37,    11,    -7,    -7,    28,    -2,    -7,
-      -2,    -2,    -2,    -2,    -2,     1,     1,    -7,    -7,    -7,
-       8,    -7,    25,    -7
+      10,    -9,    -9,     9,    -8,    -9,    -9,    18,    10,    -9,
+       7,    19,     3,    24,    -9,    -9,    25,    27,    -5,    32,
+      16,     9,    -9,    -9,    27,    -9,     9,     9,     9,     9,
+       9,     9,     9,     9,     9,     9,     9,    -9,    10,    -9,
+      -9,    -9,    38,     3,    -9,     3,     3,     3,     3,     3,
+      24,    24,    -9,    -9,    -9,     2,    -9,    -9
 };
 
   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -614,26 +616,26 @@ static const yytype_int8 yypact[] =
      means the default is an error.  */
 static const yytype_int8 yydefact[] =
 {
-       0,    26,    27,     0,     0,     6,     0,     2,     4,     0,
-       8,    10,    17,    20,    23,    24,     3,     0,     0,     0,
-       1,     5,     7,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,    28,    25,     0,    13,    24,
-      12,    11,    14,    15,    16,    18,    19,    22,    21,     9,
-       0,    29,     0,    30
+       0,    28,    29,     0,     0,     6,    33,     0,     2,     3,
+       0,    10,    12,    19,    22,    25,    26,     5,     0,     0,
+       0,     0,     1,     4,     0,     7,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     8,     0,    30,
+       9,    27,     0,    15,    26,    14,    13,    16,    17,    18,
+      20,    21,    24,    23,    11,     0,    31,    32
 };
 
   /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int8 yypgoto[] =
 {
-      -7,    -7,    14,    -6,    -1,    -7,    29,    17,    27,    -7,
-       0,    -7,    -7,    -7
+      -9,    -9,    14,    -7,     1,    -9,    30,    11,    12,    -9,
+       0,    -6,    -9,    -9,    -9
 };
 
   /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int8 yydefgoto[] =
 {
-      -1,     6,     7,     8,     9,    10,    11,    12,    13,    14,
-      39,    16,    17,    35
+      -1,     7,     8,     9,    10,    11,    12,    13,    14,    15,
+      44,    17,    18,    39,    19
 };
 
   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
@@ -641,52 +643,54 @@ static const yytype_int8 yydefgoto[] =
      number is the opposite.  If YYTABLE_NINF, syntax error.  */
 static const yytype_int8 yytable[] =
 {
-      15,    21,    18,    15,    29,    30,     1,    15,     2,    31,
-      32,     1,    20,     2,     1,    22,     2,     3,    37,    15,
-       4,     5,     3,    52,    19,     3,     5,    23,    24,     5,
-      33,    34,    49,    15,    15,    36,    25,    26,    27,    28,
-       1,    51,     2,    53,    21,     0,    45,    46,    50,     0,
-      15,     3,    38,    40,    41,    42,    43,    44,    47,    48
+      16,    23,    24,    16,    20,     1,    21,     2,    16,    32,
+      33,    38,     1,     1,     2,     2,     3,    57,    22,     4,
+       5,    16,    42,     3,     3,    25,     6,     4,     5,    41,
+      26,    27,    34,    35,     6,    36,    16,    54,    16,    28,
+      29,    30,    31,    50,    51,    37,    52,    53,    23,    24,
+      40,    56,    55,     0,     0,    16,    43,    45,    46,    47,
+      48,    49
 };
 
 static const yytype_int8 yycheck[] =
 {
-       0,     7,     3,     3,     6,     7,     3,     7,     5,     8,
-       9,     3,     0,     5,     3,    18,     5,    14,    19,    19,
-      17,    18,    14,    15,    14,    14,    18,    11,    12,    18,
-      10,    16,    33,    33,    34,    13,    20,    21,    22,    23,
-       3,    13,     5,    18,    50,    -1,    29,    30,    34,    -1,
-      50,    14,    23,    24,    25,    26,    27,    28,    31,    32
+       0,     8,     8,     3,     3,     3,    14,     5,     8,     6,
+       7,    16,     3,     3,     5,     5,    14,    15,     0,    17,
+      18,    21,    21,    14,    14,    18,    24,    17,    18,    13,
+      11,    12,     8,     9,    24,    10,    36,    36,    38,    20,
+      21,    22,    23,    32,    33,    18,    34,    35,    55,    55,
+      18,    13,    38,    -1,    -1,    55,    26,    27,    28,    29,
+      30,    31
 };
 
   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
      symbol of state STATE-NUM.  */
 static const yytype_int8 yystos[] =
 {
-       0,     3,     5,    14,    17,    18,    25,    26,    27,    28,
-      29,    30,    31,    32,    33,    34,    35,    36,    28,    14,
-       0,    27,    18,    11,    12,    20,    21,    22,    23,     6,
-       7,     8,     9,    10,    16,    37,    13,    28,    30,    34,
-      30,    30,    30,    30,    30,    31,    31,    32,    32,    28,
-      26,    13,    15,    18
+       0,     3,     5,    14,    17,    18,    24,    26,    27,    28,
+      29,    30,    31,    32,    33,    34,    35,    36,    37,    39,
+      29,    14,     0,    28,    36,    18,    11,    12,    20,    21,
+      22,    23,     6,     7,     8,     9,    10,    18,    16,    38,
+      18,    13,    29,    31,    35,    31,    31,    31,    31,    31,
+      32,    32,    33,    33,    29,    27,    13,    15
 };
 
   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 static const yytype_int8 yyr1[] =
 {
-       0,    24,    25,    25,    26,    26,    27,    27,    28,    28,
-      29,    29,    29,    29,    29,    29,    29,    30,    30,    30,
-      31,    31,    31,    32,    32,    32,    33,    34,    35,    36,
-      37
+       0,    25,    26,    27,    27,    27,    28,    28,    28,    28,
+      29,    29,    30,    30,    30,    30,    30,    30,    30,    31,
+      31,    31,    32,    32,    32,    33,    33,    33,    34,    35,
+      36,    37,    38,    39
 };
 
   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
 static const yytype_int8 yyr2[] =
 {
-       0,     2,     1,     1,     1,     2,     1,     2,     1,     3,
-       1,     3,     3,     3,     3,     3,     3,     1,     3,     3,
-       1,     3,     3,     1,     1,     3,     1,     1,     2,     4,
-       4
+       0,     2,     1,     1,     2,     1,     1,     2,     2,     2,
+       1,     3,     1,     3,     3,     3,     3,     3,     3,     1,
+       3,     3,     1,     3,     3,     1,     1,     3,     1,     1,
+       2,     4,     3,     1
 };
 
 
@@ -1381,54 +1385,81 @@ yyreduce:
   YY_REDUCE_PRINT (yyn);
   switch (yyn)
     {
-  case 4:
-#line 27 "gwarf_yacc.y"
+  case 3:
+#line 26 "gwarf_yacc.y"
     {
         if((yyvsp[0].statement_value) != NULL){
             statement *tmp = find_statement_list(0, statement_base);
             append_statement(tmp, (yyvsp[0].statement_value));
         }
     }
-#line 1393 "y.tab.c"
+#line 1397 "y.tab.c"
+    break;
+
+  case 4:
+#line 33 "gwarf_yacc.y"
+    {   
+        if((yyvsp[0].statement_value) != NULL){
+            statement *tmp = find_statement_list(0, statement_base);
+            append_statement(tmp, (yyvsp[0].statement_value));
+        }
+    }
+#line 1408 "y.tab.c"
     break;
 
   case 5:
-#line 34 "gwarf_yacc.y"
+#line 40 "gwarf_yacc.y"
     {   
         if((yyvsp[0].statement_value) != NULL){
             statement *tmp = find_statement_list(0, statement_base);
             append_statement(tmp, (yyvsp[0].statement_value));
         }
     }
-#line 1404 "y.tab.c"
+#line 1419 "y.tab.c"
     break;
 
   case 6:
-#line 44 "gwarf_yacc.y"
+#line 50 "gwarf_yacc.y"
     {
         (yyval.statement_value) = NULL;
     }
-#line 1412 "y.tab.c"
+#line 1427 "y.tab.c"
     break;
 
   case 7:
-#line 48 "gwarf_yacc.y"
+#line 54 "gwarf_yacc.y"
     {
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1420 "y.tab.c"
+#line 1435 "y.tab.c"
     break;
 
   case 8:
-#line 55 "gwarf_yacc.y"
+#line 58 "gwarf_yacc.y"
+    {   
+        (yyval.statement_value) = (yyvsp[-1].statement_value);
+    }
+#line 1443 "y.tab.c"
+    break;
+
+  case 9:
+#line 62 "gwarf_yacc.y"
+    {
+        (yyval.statement_value) = (yyvsp[-1].statement_value);
+    }
+#line 1451 "y.tab.c"
+    break;
+
+  case 10:
+#line 69 "gwarf_yacc.y"
     {
         (yyval.statement_value) = (yyvsp[0].statement_value);
     }
-#line 1428 "y.tab.c"
+#line 1459 "y.tab.c"
     break;
 
-  case 9:
-#line 59 "gwarf_yacc.y"
+  case 11:
+#line 73 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1437,11 +1468,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1441 "y.tab.c"
+#line 1472 "y.tab.c"
     break;
 
-  case 11:
-#line 72 "gwarf_yacc.y"
+  case 13:
+#line 86 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1450,11 +1481,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1454 "y.tab.c"
+#line 1485 "y.tab.c"
     break;
 
-  case 12:
-#line 81 "gwarf_yacc.y"
+  case 14:
+#line 95 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1463,11 +1494,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1467 "y.tab.c"
+#line 1498 "y.tab.c"
     break;
 
-  case 13:
-#line 90 "gwarf_yacc.y"
+  case 15:
+#line 104 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1476,11 +1507,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1480 "y.tab.c"
+#line 1511 "y.tab.c"
     break;
 
-  case 14:
-#line 99 "gwarf_yacc.y"
+  case 16:
+#line 113 "gwarf_yacc.y"
         {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1489,11 +1520,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1493 "y.tab.c"
+#line 1524 "y.tab.c"
     break;
 
-  case 15:
-#line 108 "gwarf_yacc.y"
+  case 17:
+#line 122 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1502,11 +1533,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1506 "y.tab.c"
+#line 1537 "y.tab.c"
     break;
 
-  case 16:
-#line 117 "gwarf_yacc.y"
+  case 18:
+#line 131 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1515,11 +1546,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1519 "y.tab.c"
+#line 1550 "y.tab.c"
     break;
 
-  case 18:
-#line 130 "gwarf_yacc.y"
+  case 20:
+#line 144 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1528,11 +1559,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1532 "y.tab.c"
+#line 1563 "y.tab.c"
     break;
 
-  case 19:
-#line 139 "gwarf_yacc.y"
+  case 21:
+#line 153 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1541,11 +1572,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1545 "y.tab.c"
+#line 1576 "y.tab.c"
     break;
 
-  case 21:
-#line 152 "gwarf_yacc.y"
+  case 23:
+#line 166 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1554,11 +1585,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1558 "y.tab.c"
+#line 1589 "y.tab.c"
     break;
 
-  case 22:
-#line 161 "gwarf_yacc.y"
+  case 24:
+#line 175 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1567,19 +1598,19 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1571 "y.tab.c"
+#line 1602 "y.tab.c"
     break;
 
-  case 25:
-#line 175 "gwarf_yacc.y"
+  case 27:
+#line 189 "gwarf_yacc.y"
     {
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1579 "y.tab.c"
+#line 1610 "y.tab.c"
     break;
 
-  case 26:
-#line 182 "gwarf_yacc.y"
+  case 28:
+#line 196 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = base_value;
@@ -1587,11 +1618,11 @@ yyreduce:
         code_tmp->code.base_value.value.value.double_value = (yyvsp[0].double_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1591 "y.tab.c"
+#line 1622 "y.tab.c"
     break;
 
-  case 27:
-#line 193 "gwarf_yacc.y"
+  case 29:
+#line 207 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->code.base_var.var_name = malloc(sizeof((yyvsp[0].string_value)));
@@ -1600,35 +1631,50 @@ yyreduce:
         strcpy(name_tmp, (yyvsp[0].string_value));
         (yyval.statement_value) = code_tmp;
     }
-#line 1604 "y.tab.c"
+#line 1635 "y.tab.c"
     break;
 
-  case 28:
-#line 205 "gwarf_yacc.y"
+  case 30:
+#line 219 "gwarf_yacc.y"
     {
-        printf("start-1\n");
+        statement_base = free_statement_list(statement_base);  // new statement_base (FILO)
     }
-#line 1612 "y.tab.c"
+#line 1643 "y.tab.c"
     break;
 
-  case 29:
-#line 211 "gwarf_yacc.y"
+  case 31:
+#line 226 "gwarf_yacc.y"
     {
-        printf("start-2\n");
+        statement *while_tmp =  make_statement();
+        while_tmp->type = while_cycle;
+        while_tmp->code.while_cycle.condition = (yyvsp[-1].statement_value);
+        while_tmp->code.while_cycle.done = make_statement();
+        statement_base = append_statement_list(while_tmp->code.while_cycle.done, statement_base);  // new statement_base (FILO)
+        (yyval.statement_value) = while_tmp;
     }
-#line 1620 "y.tab.c"
+#line 1656 "y.tab.c"
     break;
 
-  case 30:
-#line 217 "gwarf_yacc.y"
+  case 32:
+#line 238 "gwarf_yacc.y"
     {
         printf("start-0\n");
     }
-#line 1628 "y.tab.c"
+#line 1664 "y.tab.c"
+    break;
+
+  case 33:
+#line 245 "gwarf_yacc.y"
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = break_cycle;
+        (yyval.statement_value) = code_tmp;
+    }
+#line 1674 "y.tab.c"
     break;
 
 
-#line 1632 "y.tab.c"
+#line 1678 "y.tab.c"
 
       default: break;
     }
@@ -1860,7 +1906,7 @@ yyreturn:
 #endif
   return yyresult;
 }
-#line 221 "gwarf_yacc.y"
+#line 252 "gwarf_yacc.y"
 
 int yyerror(char const *str)
 {

+ 4 - 2
paser/y.tab.h

@@ -69,7 +69,8 @@ extern int yydebug;
     EQUAL = 275,
     MOREEQ = 276,
     LESSEQ = 277,
-    NOTEQ = 278
+    NOTEQ = 278,
+    BREAK = 279
   };
 #endif
 /* Tokens.  */
@@ -94,6 +95,7 @@ extern int yydebug;
 #define MOREEQ 276
 #define LESSEQ 277
 #define NOTEQ 278
+#define BREAK 279
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@@ -106,7 +108,7 @@ union YYSTYPE
     char *string_value;
     void *statement_value;
 
-#line 110 "y.tab.h"
+#line 112 "y.tab.h"
 
 };
 typedef union YYSTYPE YYSTYPE;