浏览代码

完成了if和broken语句,break和broken支持层数

SongZihuan 5 年之前
父节点
当前提交
ffca67cf38
共有 8 个文件被更改,包括 653 次插入282 次删除
  1. 二进制
      gwarf
  2. 26 0
      gwarf_interpreter/interprete.h
  3. 117 9
      gwarf_interpreter/interpreter.c
  4. 4 0
      paser/gwarf_lex.l
  5. 81 7
      paser/gwarf_yacc.y
  6. 156 124
      paser/lex.yy.c
  7. 257 139
      paser/y.tab.c
  8. 12 3
      paser/y.tab.h

二进制
gwarf


+ 26 - 0
gwarf_interpreter/interprete.h

@@ -36,7 +36,9 @@ typedef struct statement{
         base_var,  // return var address
         base_var,  // return var address
         base_value,  // return an number or number
         base_value,  // return an number or number
         while_cycle,  // while
         while_cycle,  // while
+        if_branch,  // if
         break_cycle,  // break
         break_cycle,  // break
+        broken,  // break_cycle and other {}
     } type;  // the statement type
     } type;  // the statement type
 
 
     union
     union
@@ -64,6 +66,10 @@ typedef struct statement{
             struct statement *done;  // while to do
             struct statement *done;  // while to do
         } while_cycle;
         } while_cycle;
 
 
+        struct{
+            struct if_list *done;  // if_list
+        } if_branch;
+
         struct{
         struct{
             char *var_name;  // return var
             char *var_name;  // return var
         } base_var;
         } base_var;
@@ -73,8 +79,13 @@ typedef struct statement{
         } base_value;
         } base_value;
 
 
         struct{
         struct{
+            struct statement *times;  // while to do
         } break_cycle;
         } break_cycle;
 
 
+        struct{
+            struct statement *times;  // while to do
+        } broken;
+
     } code;
     } code;
     struct statement *next;
     struct statement *next;
 } statement;
 } statement;
@@ -87,6 +98,7 @@ typedef struct GWARF_result{
         return_def=1,
         return_def=1,
         statement_end,
         statement_end,
         cycle_break,
         cycle_break,
+        code_broken,
         name_no_found,
         name_no_found,
     } u;  // the result type[from where]
     } u;  // the result type[from where]
 } GWARF_result;
 } GWARF_result;
@@ -105,6 +117,15 @@ typedef struct statement_list{
     struct statement_list *next;
     struct statement_list *next;
 } statement_list;
 } statement_list;
 
 
+
+// ------------------------- if list [记录着if...elif...else]
+
+typedef struct if_list{
+    struct statement *condition;  // when to while 
+    struct statement *done;  // while to do
+    struct if_list *next;
+} if_list;
+
 // ------------------------- inter
 // ------------------------- inter
 
 
 typedef struct{
 typedef struct{
@@ -129,6 +150,11 @@ statement_list *append_statement_list(statement *, statement_list *);
 statement *find_statement_list(int, statement_list *);
 statement *find_statement_list(int, statement_list *);
 statement_list *free_statement_list(statement_list *);
 statement_list *free_statement_list(statement_list *);
 
 
+//------- if func
+if_list *make_base_if();
+if_list *make_if(statement *, statement *);
+if_list *append_elif(if_list *, if_list *);
+
 //------- run func
 //------- run func
 GWARF_result traverse(statement *, var_list *, bool);
 GWARF_result traverse(statement *, var_list *, bool);
 
 

+ 117 - 9
gwarf_interpreter/interpreter.c

@@ -11,9 +11,10 @@ GWARF_result sub_func(GWARF_result, GWARF_result, var_list *);
 GWARF_result mul_func(GWARF_result, GWARF_result, var_list *);
 GWARF_result mul_func(GWARF_result, GWARF_result, var_list *);
 GWARF_result div_func(GWARF_result, GWARF_result, var_list *);
 GWARF_result div_func(GWARF_result, GWARF_result, var_list *);
 GWARF_result assigment_func(char *, GWARF_result, var_list *);
 GWARF_result assigment_func(char *, GWARF_result, var_list *);
-GWARF_result equal_func(GWARF_result, GWARF_result, var_list *, int type);
+GWARF_result equal_func(GWARF_result, GWARF_result, var_list *, int);
+GWARF_result if_func(if_list *, var_list *);
 
 
-// ------------------------- var func
+// ---- var func
 
 
 var *make_var(){  // make var with base
 var *make_var(){  // make var with base
     var *tmp;
     var *tmp;
@@ -92,7 +93,7 @@ void del_var(char *name, var *base_var){  // free an address
     }
     }
 }
 }
 
 
-// ------------------------- statement list
+// ---- statement list
 
 
 statement *make_statement(){  // make statement
 statement *make_statement(){  // make statement
     statement *tmp;
     statement *tmp;
@@ -114,7 +115,7 @@ statement *append_statement(statement *base_statement, statement *new_tmp){  //
     return new_tmp;
     return new_tmp;
 }
 }
 
 
-// ------------------------- var_list
+// ---- var_list
 
 
 var_list *make_var_list(){  // make a empty var_list node
 var_list *make_var_list(){  // make a empty var_list node
     var_list *tmp;
     var_list *tmp;
@@ -173,7 +174,7 @@ void add_var(var_list *var_base,int from, char *name, GWARF_value value){  // ad
     append_var(name, value, start->var_base);
     append_var(name, value, start->var_base);
 }
 }
 
 
-// ------------------------- statement_list
+// ---- statement_list
 statement_list *make_statement_list(){  // make a empty var_list node
 statement_list *make_statement_list(){  // make a empty var_list node
     statement_list *tmp;
     statement_list *tmp;
     tmp = malloc(sizeof(statement_list));  // get an address for base var
     tmp = malloc(sizeof(statement_list));  // get an address for base var
@@ -215,7 +216,36 @@ statement_list *free_statement_list(statement_list *statment_list_base){  // mak
     return statment_list_base;
     return statment_list_base;
 }
 }
 
 
-// ------------------------- run code
+// ---- if_list
+if_list *make_base_if(){  // make base if
+    if_list *tmp;
+    tmp = malloc(sizeof(if_list));  // get an address for base var
+    tmp->next = NULL;
+    tmp->done = NULL;
+    tmp->condition = NULL;
+    return tmp;
+}
+
+if_list *make_if(statement *condition, statement *done_base){  // if
+    if_list *tmp = make_base_if();
+    tmp->done = done_base;
+    tmp->condition = condition;
+    return tmp;
+}
+
+if_list *append_elif(if_list *tmp ,if_list *base_if_list){  // elif
+    if_list *start = base_if_list;
+    while(1){
+        if(start->next  == NULL){
+            break;
+        }
+        start = start->next;
+    }
+    start->next = tmp;
+    return tmp;
+}
+
+// ---- run code
 
 
 GWARF_result read_statement_list(statement *the_statement, var_list *the_var){  // read the statement list with case to run by func
 GWARF_result read_statement_list(statement *the_statement, var_list *the_var){  // read the statement list with case to run by func
     GWARF_result return_value;
     GWARF_result return_value;
@@ -225,12 +255,40 @@ GWARF_result read_statement_list(statement *the_statement, var_list *the_var){
     switch (the_statement->type)
     switch (the_statement->type)
     {
     {
         case operation:  // 表达式运算
         case operation:  // 表达式运算
+            puts("----code----");
             return_value = operation_func(the_statement, the_var);
             return_value = operation_func(the_statement, the_var);
             printf("operation value = %f\n", return_value.value.value.double_value);
             printf("operation value = %f\n", return_value.value.value.double_value);
+            puts("----stop code----");
             break;
             break;
         case while_cycle:
         case while_cycle:
+            puts("----while code----");
             return_value = while_func(the_statement, the_var);
             return_value = while_func(the_statement, the_var);
+            if((return_value.u == cycle_break) || (return_value.u == code_broken)){
+                printf("cycle_break(broken) %f\n", return_value.value.value.double_value);
+                return_value.value.value.double_value -= 1;
+                if(return_value.value.value.double_value < 0){
+                    return_value.u = statement_end;  // 正常设置[正常语句结束]
+                }
+            }
             printf("while operation value = %f\n", return_value.value.value.double_value);
             printf("while operation value = %f\n", return_value.value.value.double_value);
+            puts("----stop while code----");
+            break;
+        case if_branch:
+            puts("----if code----");
+            return_value = if_func(the_statement->code.if_branch.done, the_var);
+            if(return_value.u == cycle_break){
+                printf("cycle_break %f\n", return_value.value.value.double_value);
+            }
+            if(return_value.u == code_broken){
+                printf("broken %f\n", return_value.value.value.double_value);
+                return_value.value.value.double_value -= 1;
+                if(return_value.value.value.double_value < 0){
+                    return_value.u = statement_end;  // 正常设置[正常语句结束]
+                }
+            }
+            printf("if type = %d\n", return_value.u);
+            printf("if operation value = %f\n", return_value.value.value.double_value);
+            puts("----stop if code----");
             break;
             break;
         case base_value:  // get value[所有字面量均为这个表达式]
         case base_value:  // get value[所有字面量均为这个表达式]
             return_value.value = (the_statement->code).base_value.value;  // code
             return_value.value = (the_statement->code).base_value.value;  // code
@@ -250,6 +308,23 @@ GWARF_result read_statement_list(statement *the_statement, var_list *the_var){
         }
         }
         case break_cycle:
         case break_cycle:
             return_value.u = cycle_break;
             return_value.u = cycle_break;
+            if(the_statement->code.break_cycle.times == NULL){
+                return_value.value.value.double_value = 0;
+            }
+            else{
+                return_value.value.value.double_value = traverse(the_statement->code.break_cycle.times, the_var, false).value.value.double_value;  // 执行语句,获得弹出层
+            }
+            printf("break num = %f\n", return_value.value.value.double_value);
+            break;
+        case broken:
+            return_value.u = code_broken;
+            if(the_statement->code.broken.times == NULL){
+                return_value.value.value.double_value = 0;
+            }
+            else{
+                return_value.value.value.double_value = traverse(the_statement->code.broken.times, the_var, false).value.value.double_value;  // 执行语句,获得弹出层
+            }
+            printf("broken num = %f\n", return_value.value.value.double_value);
             break;
             break;
         default:
         default:
             puts("default");
             puts("default");
@@ -258,20 +333,50 @@ GWARF_result read_statement_list(statement *the_statement, var_list *the_var){
     return return_value;
     return return_value;
 }
 }
 
 
+// -----------------if func
+
+GWARF_result if_func(if_list *if_base, var_list *the_var){  // read the statement list with case to run by func
+    GWARF_result value;
+    if_list *start = if_base;
+    while(1){
+        if(start->condition  == NULL){  // else
+            puts("----else----");
+            value = traverse(start->done, the_var, false);
+            puts("----stop else----");
+            break;
+        }
+        else{  // not else
+            GWARF_result condition;
+            condition = traverse(start->condition, the_var, false);
+            if(condition.value.value.double_value){  // condition run success
+                puts("----if----");
+                value = traverse(start->done, the_var, false);
+                puts("----stop if----");
+                break;
+            }
+        }
+        if(start->next  == NULL){  // not next
+            break;
+        }
+        start = start->next;
+    }
+    return value;
+}
+
 // -----------------while func
 // -----------------while func
 
 
 GWARF_result while_func(statement *the_statement, var_list *the_var){  // read the statement list with case to run by func
 GWARF_result while_func(statement *the_statement, var_list *the_var){  // read the statement list with case to run by func
     GWARF_result value, condition;
     GWARF_result value, condition;
     while (1){
     while (1){
         condition = traverse((*the_statement).code.while_cycle.condition, the_var, false);
         condition = traverse((*the_statement).code.while_cycle.condition, the_var, false);
-        printf("condition = %f\n", condition.value.value.double_value);
+        printf("while condition = %f\n", condition.value.value.double_value);
         if(!condition.value.value.double_value){
         if(!condition.value.value.double_value){
             break;
             break;
         }
         }
         puts("----while----");
         puts("----while----");
         value = traverse((*the_statement).code.operation.right_exp, the_var, false);
         value = traverse((*the_statement).code.operation.right_exp, the_var, false);
         puts("----stop while----");
         puts("----stop while----");
-        if(value.u == cycle_break){  // break the while
+        if((value.u == cycle_break) || (value.u == code_broken)){  // break the while
             break;
             break;
         }
         }
     }
     }
@@ -282,6 +387,7 @@ GWARF_result while_func(statement *the_statement, var_list *the_var){  // read t
 
 
 GWARF_result operation_func(statement *the_statement, var_list *the_var){  // read the statement list with case to run by func
 GWARF_result operation_func(statement *the_statement, var_list *the_var){  // read the statement list with case to run by func
     GWARF_result value, left_result, right_result;
     GWARF_result value, left_result, right_result;
+
     left_result = traverse((*the_statement).code.operation.left_exp, the_var, false);
     left_result = traverse((*the_statement).code.operation.left_exp, the_var, false);
     right_result = traverse((*the_statement).code.operation.right_exp, the_var, false);
     right_result = traverse((*the_statement).code.operation.right_exp, the_var, false);
     switch (the_statement->code.operation.type)  // 获取运算类型
     switch (the_statement->code.operation.type)  // 获取运算类型
@@ -324,6 +430,7 @@ GWARF_result operation_func(statement *the_statement, var_list *the_var){  // re
         default:
         default:
             break;
             break;
     }
     }
+    value.u = statement_end;  // 正常设置[正常语句结束]
     return value;
     return value;
 }
 }
 
 
@@ -416,7 +523,8 @@ GWARF_result traverse(statement *the_statement, var_list *the_var, bool new){  /
             break;  // off
             break;  // off
         }
         }
         result = read_statement_list(tmp, the_var);
         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]
+        if((result.u == cycle_break) || (result.u == code_broken)){  // don't next the statement and return the result [the while_func[or for func] will get the result and stop cycle]
+            puts("----break or broken----");
             break;
             break;
         }
         }
         tmp = tmp->next;
         tmp = tmp->next;

+ 4 - 0
paser/gwarf_lex.l

@@ -5,7 +5,11 @@
 %s COMMENT STRING_TEXT
 %s COMMENT STRING_TEXT
 %%
 %%
 <INITIAL>"while" {return WHILE;}
 <INITIAL>"while" {return WHILE;}
+<INITIAL>"if" {return IF;}
+<INITIAL>[\n]*elif {return ELIF;}
+<INITIAL>[\n]*else(\(\))? {return ELSE;}
 <INITIAL>"break" {return BREAK;}
 <INITIAL>"break" {return BREAK;}
+<INITIAL>"broken" {return BROKEN;}
 
 
 <INITIAL>"(" {return LB;}
 <INITIAL>"(" {return LB;}
 <INITIAL>")" {return RB;}
 <INITIAL>")" {return RB;}

+ 81 - 7
paser/gwarf_yacc.y

@@ -9,13 +9,14 @@
     int int_value;
     int int_value;
     double double_value;
     double double_value;
     char *string_value;
     char *string_value;
-    void *statement_value;
+    struct statement *statement_value;
+    struct if_list *if_list_base;
 }
 }
 %token <double_value> NUMBER
 %token <double_value> NUMBER
 %token <string_value> STRING VAR
 %token <string_value> STRING VAR
-%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
-
+%token ADD SUB DIV MUL EQ LESS MORE RB LB RP LP WHILE STOP POW EQUAL MOREEQ LESSEQ NOTEQ BREAK IF ELSE ELIF BROKEN
+%type <statement_value> base_number base_var_ element second_number first_number top_exp command third_number while_block while_exp break_exp if_block if_exp broken_exp break_token broken_token
+%type <if_list_base> elif_exp
 %%
 %%
 command_block
 command_block
     : command_list
     : command_list
@@ -58,10 +59,18 @@ command
     {   
     {   
         $$ = $1;
         $$ = $1;
     }
     }
+    | if_block STOP
+    {
+        $$ = $1;
+    }
     | break_exp STOP
     | break_exp STOP
     {
     {
         $$ = $1;
         $$ = $1;
     }
     }
+    | broken_exp STOP
+    {
+        $$ = $1;
+    }
     ;
     ;
 
 
 top_exp
 top_exp
@@ -214,6 +223,46 @@ base_var_
     }
     }
     ;
     ;
 
 
+if_block
+    : if_exp block
+    {
+        statement_base = free_statement_list(statement_base);  // new statement_base (FILO)
+        $$ = $1;
+    }
+    | if_block elif_exp block
+    {
+        append_elif($2, $1->code.if_branch.done);
+        $$ = $1;
+        statement_base = free_statement_list(statement_base);  // new statement_base (FILO)
+    }
+    ;
+
+elif_exp
+    : ELIF LB top_exp RB
+    {
+        statement *done_tmp =  make_statement();
+        $$ = make_if($3, done_tmp);
+        statement_base = append_statement_list(done_tmp, statement_base);  // new statement_base (FILO)
+    }
+    | ELSE
+    {
+        statement *done_tmp =  make_statement();
+        $$ = make_if(NULL, done_tmp);
+        statement_base = append_statement_list(done_tmp, statement_base);  // new statement_base (FILO)
+    }
+    ;
+
+if_exp
+    : IF LB top_exp RB
+    {
+        statement *if_tmp =  make_statement(), *done_tmp =  make_statement();
+        if_tmp->type = if_branch;
+        if_tmp->code.if_branch.done = make_if($3, done_tmp);
+        statement_base = append_statement_list(done_tmp, statement_base);  // new statement_base (FILO)
+        $$ = if_tmp;
+    }
+    ;
+
 while_block
 while_block
     : while_exp block
     : while_exp block
     {
     {
@@ -235,16 +284,41 @@ while_exp
 
 
 block
 block
     : LP command_list RP
     : LP command_list RP
+    ;
+
+break_exp
+    : break_token
+    | break_token element
     {
     {
-        printf("start-0\n");
+        $1->code.break_cycle.times = $2;
+        $$ = $1;
     }
     }
     ;
     ;
 
 
-break_exp
+break_token
     : BREAK
     : BREAK
     {
     {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->type = break_cycle;
         code_tmp->type = break_cycle;
+        code_tmp->code.break_cycle.times = NULL;
+        $$ = code_tmp;
+    }
+    ;
+
+broken_exp
+    : broken_token
+    | broken_token element
+    {
+        $1->code.broken.times = $2;
+        $$ = $1;
+    }
+
+broken_token
+    : BROKEN
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = broken;
+        code_tmp->code.broken.times = NULL;
         $$ = code_tmp;
         $$ = code_tmp;
     }
     }
     ;
     ;
@@ -252,7 +326,7 @@ break_exp
 %%
 %%
 int yyerror(char const *str)
 int yyerror(char const *str)
 {
 {
-    fprintf(stderr, "parser error near %s ;\n", yytext, yytext);
+    fprintf(stderr, "parser error near [%s] ;\n", yytext, yytext);
     return 0;
     return 0;
 }
 }
 
 

+ 156 - 124
paser/lex.yy.c

@@ -351,8 +351,8 @@ static void yynoreturn yy_fatal_error ( const char* msg  );
 	(yy_hold_char) = *yy_cp; \
 	(yy_hold_char) = *yy_cp; \
 	*yy_cp = '\0'; \
 	*yy_cp = '\0'; \
 	(yy_c_buf_p) = yy_cp;
 	(yy_c_buf_p) = yy_cp;
-#define YY_NUM_RULES 35
-#define YY_END_OF_BUFFER 36
+#define YY_NUM_RULES 39
+#define YY_END_OF_BUFFER 40
 /* This struct is not used in this scanner,
 /* This struct is not used in this scanner,
    but its presence is necessary. */
    but its presence is necessary. */
 struct yy_trans_info
 struct yy_trans_info
@@ -360,14 +360,16 @@ struct yy_trans_info
 	flex_int32_t yy_verify;
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	flex_int32_t yy_nxt;
 	};
 	};
-static const flex_int16_t yy_accept[60] =
+static const flex_int16_t yy_accept[80] =
     {   0,
     {   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
+        0,    0,    0,    0,    0,    0,   40,   31,   29,   28,
+       31,   25,   23,   24,    7,    8,   20,   18,   19,   21,
+       26,   26,   30,   15,   17,   14,   27,   22,   27,   27,
+       27,   27,    9,   10,   34,   32,   33,   38,   37,   36,
+       35,    0,    0,    9,   13,    0,   26,   12,   16,   11,
+       27,   27,   27,    2,   27,    9,    0,   26,   27,   27,
+       27,   27,   27,    0,    0,   27,   27,    3,    4,   27,
+        3,    4,    5,   27,    0,    1,    6,    4,    0
     } ;
     } ;
 
 
 static const YY_CHAR yy_ec[256] =
 static const YY_CHAR yy_ec[256] =
@@ -383,9 +385,9 @@ static const YY_CHAR yy_ec[256] =
        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,   23,   24,   21,   21,
         1,    1,    1,   22,   21,    1,   23,   24,   21,   21,
 
 
-       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,
+       25,   26,   21,   27,   28,   21,   29,   30,   21,   31,
+       32,   21,   21,   33,   34,   21,   21,   21,   35,   21,
+       21,   21,   36,    1,   37,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -402,68 +404,76 @@ static const YY_CHAR yy_ec[256] =
         1,    1,    1,    1,    1
         1,    1,    1,    1,    1
     } ;
     } ;
 
 
-static const YY_CHAR yy_meta[34] =
+static const YY_CHAR yy_meta[38] =
     {   0,
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    2,    2,    1,    1,    1,    1,
         1,    1,    1,    1,    2,    2,    1,    1,    1,    1,
         2,    1,    2,    2,    2,    2,    2,    2,    2,    2,
         2,    1,    2,    2,    2,    2,    2,    2,    2,    2,
-        2,    1,    1
+        2,    2,    2,    2,    2,    1,    1
     } ;
     } ;
 
 
-static const flex_int16_t yy_base[63] =
+static const flex_int16_t yy_base[83] =
     {   0,
     {   0,
-        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
+        0,    0,   36,   37,   39,   43,  102,  103,   38,  103,
+       82,  103,  103,  103,  103,  103,  103,  103,  103,  103,
+      103,   36,  103,   81,   80,   79,    0,  103,   64,   66,
+       69,   67,   91,  103,  103,  103,  103,  103,  103,  103,
+      103,   45,   62,   89,  103,   38,   42,  103,  103,  103,
+        0,   34,   28,    0,   62,   87,   33,   49,   65,   58,
+       60,   55,   49,   52,   52,   47,   50,    0,   65,   47,
+      103,   63,    0,   38,   59,    0,    0,  103,  103,   81,
+       83,   58
     } ;
     } ;
 
 
-static const flex_int16_t yy_def[63] =
+static const flex_int16_t yy_def[83] =
     {   0,
     {   0,
-       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
+       79,    1,   80,   80,   81,   81,   79,   79,   79,   79,
+       79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
+       79,   79,   79,   79,   79,   79,   82,   79,   82,   82,
+       82,   82,   79,   79,   79,   79,   79,   79,   79,   79,
+       79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
+       82,   82,   82,   82,   82,   79,   79,   79,   82,   82,
+       82,   82,   82,   79,   79,   82,   82,   82,   82,   82,
+       79,   79,   82,   82,   79,   82,   82,   79,    0,   79,
+       79,   79
     } ;
     } ;
 
 
-static const flex_int16_t yy_nxt[113] =
+static const flex_int16_t yy_nxt[141] =
     {   0,
     {   0,
         8,    9,   10,   11,   12,   13,   14,   15,   16,   17,
         8,    9,   10,   11,   12,   13,   14,   15,   16,   17,
        18,   19,    8,   20,   21,   22,   23,   24,   25,   26,
        18,   19,    8,   20,   21,   22,   23,   24,   25,   26,
-       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
+       27,   28,   27,   29,   30,   27,   27,   31,   27,   27,
+       27,   27,   27,   27,   32,   33,   34,   36,   36,   42,
+       39,   37,   37,   40,   39,   41,   42,   40,   46,   41,
+       47,   47,   58,   58,   46,   61,   47,   47,   59,   51,
+       64,   62,   43,   58,   58,   60,   65,   78,   77,   43,
+       75,   76,   75,   44,   74,   73,   72,   71,   70,   69,
+       44,   35,   35,   38,   38,   68,   67,   66,   56,   63,
+       56,   57,   56,   55,   54,   53,   52,   50,   49,   48,
+
+       45,   79,    7,   79,   79,   79,   79,   79,   79,   79,
+       79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
+       79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
+       79,   79,   79,   79,   79,   79,   79,   79,   79,   79
     } ;
     } ;
 
 
-static const flex_int16_t yy_chk[113] =
+static const flex_int16_t yy_chk[141] =
     {   0,
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    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
+        1,    1,    1,    1,    1,    1,    1,    3,    4,    9,
+        5,    3,    4,    5,    6,    5,   42,    6,   22,    6,
+       22,   22,   46,   46,   47,   53,   47,   47,   52,   82,
+       57,   53,    9,   58,   58,   52,   57,   75,   74,   42,
+       72,   70,   69,    9,   67,   66,   65,   64,   63,   62,
+       42,   80,   80,   81,   81,   61,   60,   59,   56,   55,
+       44,   43,   33,   32,   31,   30,   29,   26,   25,   24,
+
+       11,    7,   79,   79,   79,   79,   79,   79,   79,   79,
+       79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
+       79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
+       79,   79,   79,   79,   79,   79,   79,   79,   79,   79
     } ;
     } ;
 
 
 static yy_state_type yy_last_accepting_state;
 static yy_state_type yy_last_accepting_state;
@@ -484,9 +494,9 @@ char *yytext;
 #line 2 "gwarf_lex.l"
 #line 2 "gwarf_lex.l"
     #include<stdio.h>
     #include<stdio.h>
     #include"y.tab.h"
     #include"y.tab.h"
-#line 487 "lex.yy.c"
+#line 497 "lex.yy.c"
 
 
-#line 489 "lex.yy.c"
+#line 499 "lex.yy.c"
 
 
 #define INITIAL 0
 #define INITIAL 0
 #define COMMENT 1
 #define COMMENT 1
@@ -707,7 +717,7 @@ YY_DECL
 	{
 	{
 #line 6 "gwarf_lex.l"
 #line 6 "gwarf_lex.l"
 
 
-#line 710 "lex.yy.c"
+#line 720 "lex.yy.c"
 
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
 		{
@@ -734,13 +744,13 @@ yy_match:
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 				{
 				{
 				yy_current_state = (int) yy_def[yy_current_state];
 				yy_current_state = (int) yy_def[yy_current_state];
-				if ( yy_current_state >= 60 )
+				if ( yy_current_state >= 80 )
 					yy_c = yy_meta[yy_c];
 					yy_c = yy_meta[yy_c];
 				}
 				}
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 			++yy_cp;
 			++yy_cp;
 			}
 			}
-		while ( yy_base[yy_current_state] != 79 );
+		while ( yy_base[yy_current_state] != 103 );
 
 
 yy_find_action:
 yy_find_action:
 		yy_act = yy_accept[yy_current_state];
 		yy_act = yy_accept[yy_current_state];
@@ -772,190 +782,212 @@ YY_RULE_SETUP
 case 2:
 case 2:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 8 "gwarf_lex.l"
 #line 8 "gwarf_lex.l"
-{return BREAK;}
+{return IF;}
 	YY_BREAK
 	YY_BREAK
 case 3:
 case 3:
+/* rule 3 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 10 "gwarf_lex.l"
-{return LB;}
+#line 9 "gwarf_lex.l"
+{return ELIF;}
 	YY_BREAK
 	YY_BREAK
 case 4:
 case 4:
+/* rule 4 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 11 "gwarf_lex.l"
-{return RB;}
+#line 10 "gwarf_lex.l"
+{return ELSE;}
 	YY_BREAK
 	YY_BREAK
 case 5:
 case 5:
-/* rule 5 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 12 "gwarf_lex.l"
-{return LP;}
+#line 11 "gwarf_lex.l"
+{return BREAK;}
 	YY_BREAK
 	YY_BREAK
 case 6:
 case 6:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 13 "gwarf_lex.l"
-{return RP;}
+#line 12 "gwarf_lex.l"
+{return BROKEN;}
 	YY_BREAK
 	YY_BREAK
 case 7:
 case 7:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 15 "gwarf_lex.l"
-{return MOREEQ;}
+#line 14 "gwarf_lex.l"
+{return LB;}
 	YY_BREAK
 	YY_BREAK
 case 8:
 case 8:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 16 "gwarf_lex.l"
-{return LESSEQ;}
+#line 15 "gwarf_lex.l"
+{return RB;}
 	YY_BREAK
 	YY_BREAK
 case 9:
 case 9:
+/* rule 9 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 17 "gwarf_lex.l"
-{return NOTEQ;}
+#line 16 "gwarf_lex.l"
+{return LP;}
 	YY_BREAK
 	YY_BREAK
 case 10:
 case 10:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 18 "gwarf_lex.l"
-{return MORE;}
+#line 17 "gwarf_lex.l"
+{return RP;}
 	YY_BREAK
 	YY_BREAK
 case 11:
 case 11:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 19 "gwarf_lex.l"
 #line 19 "gwarf_lex.l"
-{return LESS;}
+{return MOREEQ;}
 	YY_BREAK
 	YY_BREAK
 case 12:
 case 12:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 20 "gwarf_lex.l"
 #line 20 "gwarf_lex.l"
-{return EQUAL;}
+{return LESSEQ;}
 	YY_BREAK
 	YY_BREAK
 case 13:
 case 13:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 21 "gwarf_lex.l"
 #line 21 "gwarf_lex.l"
-{return EQ;}
+{return NOTEQ;}
 	YY_BREAK
 	YY_BREAK
 case 14:
 case 14:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 22 "gwarf_lex.l"
 #line 22 "gwarf_lex.l"
-{return ADD;}
+{return MORE;}
 	YY_BREAK
 	YY_BREAK
 case 15:
 case 15:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 23 "gwarf_lex.l"
 #line 23 "gwarf_lex.l"
-{return SUB;}
+{return LESS;}
 	YY_BREAK
 	YY_BREAK
 case 16:
 case 16:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 24 "gwarf_lex.l"
 #line 24 "gwarf_lex.l"
-{return MUL;}
+{return EQUAL;}
 	YY_BREAK
 	YY_BREAK
 case 17:
 case 17:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 25 "gwarf_lex.l"
 #line 25 "gwarf_lex.l"
-{return DIV;}
+{return EQ;}
 	YY_BREAK
 	YY_BREAK
 case 18:
 case 18:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 26 "gwarf_lex.l"
 #line 26 "gwarf_lex.l"
-{return POW;}
+{return ADD;}
 	YY_BREAK
 	YY_BREAK
 case 19:
 case 19:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 28 "gwarf_lex.l"
-{BEGIN COMMENT;}
+#line 27 "gwarf_lex.l"
+{return SUB;}
 	YY_BREAK
 	YY_BREAK
 case 20:
 case 20:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 29 "gwarf_lex.l"
-{BEGIN STRING_TEXT;}
+#line 28 "gwarf_lex.l"
+{return MUL;}
 	YY_BREAK
 	YY_BREAK
 case 21:
 case 21:
 YY_RULE_SETUP
 YY_RULE_SETUP
+#line 29 "gwarf_lex.l"
+{return DIV;}
+	YY_BREAK
+case 22:
+YY_RULE_SETUP
 #line 30 "gwarf_lex.l"
 #line 30 "gwarf_lex.l"
+{return POW;}
+	YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 32 "gwarf_lex.l"
+{BEGIN COMMENT;}
+	YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 33 "gwarf_lex.l"
 {BEGIN STRING_TEXT;}
 {BEGIN STRING_TEXT;}
 	YY_BREAK
 	YY_BREAK
-case 22:
+case 25:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 31 "gwarf_lex.l"
+#line 34 "gwarf_lex.l"
+{BEGIN STRING_TEXT;}
+	YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 35 "gwarf_lex.l"
 {
 {
     yylval.double_value = atof(yytext);
     yylval.double_value = atof(yytext);
     return NUMBER;
     return NUMBER;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 23:
+case 27:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 35 "gwarf_lex.l"
+#line 39 "gwarf_lex.l"
 {
 {
     yylval.string_value = yytext;
     yylval.string_value = yytext;
     return VAR;
     return VAR;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 24:
+case 28:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 40 "gwarf_lex.l"
+#line 44 "gwarf_lex.l"
 ;
 ;
 	YY_BREAK
 	YY_BREAK
-case 25:
-/* rule 25 can match eol */
+case 29:
+/* rule 29 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 41 "gwarf_lex.l"
+#line 45 "gwarf_lex.l"
 {return STOP;}
 {return STOP;}
 	YY_BREAK
 	YY_BREAK
-case 26:
+case 30:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 42 "gwarf_lex.l"
+#line 46 "gwarf_lex.l"
 {return STOP;}
 {return STOP;}
 	YY_BREAK
 	YY_BREAK
-case 27:
+case 31:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 43 "gwarf_lex.l"
+#line 47 "gwarf_lex.l"
 {printf("text = [%s];\n", yytext);}
 {printf("text = [%s];\n", yytext);}
 	YY_BREAK
 	YY_BREAK
-case 28:
-/* rule 28 can match eol */
+case 32:
+/* rule 32 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 45 "gwarf_lex.l"
+#line 49 "gwarf_lex.l"
 {BEGIN INITIAL;}
 {BEGIN INITIAL;}
 	YY_BREAK
 	YY_BREAK
-case 29:
+case 33:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 46 "gwarf_lex.l"
+#line 50 "gwarf_lex.l"
 {BEGIN INITIAL;}
 {BEGIN INITIAL;}
 	YY_BREAK
 	YY_BREAK
-case 30:
+case 34:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 47 "gwarf_lex.l"
+#line 51 "gwarf_lex.l"
 ;
 ;
 	YY_BREAK
 	YY_BREAK
-case 31:
+case 35:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 49 "gwarf_lex.l"
+#line 53 "gwarf_lex.l"
 {BEGIN INITIAL;}
 {BEGIN INITIAL;}
 	YY_BREAK
 	YY_BREAK
-case 32:
+case 36:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 50 "gwarf_lex.l"
+#line 54 "gwarf_lex.l"
 {BEGIN INITIAL;}
 {BEGIN INITIAL;}
 	YY_BREAK
 	YY_BREAK
-case 33:
-/* rule 33 can match eol */
+case 37:
+/* rule 37 can match eol */
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 51 "gwarf_lex.l"
+#line 55 "gwarf_lex.l"
 {
 {
     yylval.string_value = yytext;
     yylval.string_value = yytext;
     return STRING;
     return STRING;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 34:
+case 38:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 55 "gwarf_lex.l"
+#line 59 "gwarf_lex.l"
 {
 {
     yylval.string_value = yytext;
     yylval.string_value = yytext;
     return STRING;
     return STRING;
     }
     }
 	YY_BREAK
 	YY_BREAK
-case 35:
+case 39:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 59 "gwarf_lex.l"
+#line 63 "gwarf_lex.l"
 ECHO;
 ECHO;
 	YY_BREAK
 	YY_BREAK
-#line 958 "lex.yy.c"
+#line 990 "lex.yy.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(COMMENT):
 case YY_STATE_EOF(COMMENT):
 case YY_STATE_EOF(STRING_TEXT):
 case YY_STATE_EOF(STRING_TEXT):
@@ -1254,7 +1286,7 @@ static int yy_get_next_buffer (void)
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			{
 			{
 			yy_current_state = (int) yy_def[yy_current_state];
 			yy_current_state = (int) yy_def[yy_current_state];
-			if ( yy_current_state >= 60 )
+			if ( yy_current_state >= 80 )
 				yy_c = yy_meta[yy_c];
 				yy_c = yy_meta[yy_c];
 			}
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -1282,11 +1314,11 @@ static int yy_get_next_buffer (void)
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		{
 		{
 		yy_current_state = (int) yy_def[yy_current_state];
 		yy_current_state = (int) yy_def[yy_current_state];
-		if ( yy_current_state >= 60 )
+		if ( yy_current_state >= 80 )
 			yy_c = yy_meta[yy_c];
 			yy_c = yy_meta[yy_c];
 		}
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
-	yy_is_jam = (yy_current_state == 59);
+	yy_is_jam = (yy_current_state == 79);
 
 
 		return yy_is_jam ? 0 : yy_current_state;
 		return yy_is_jam ? 0 : yy_current_state;
 }
 }
@@ -1962,7 +1994,7 @@ void yyfree (void * ptr )
 
 
 #define YYTABLES_NAME "yytables"
 #define YYTABLES_NAME "yytables"
 
 
-#line 59 "gwarf_lex.l"
+#line 63 "gwarf_lex.l"
 
 
 int yywrap(void) {
 int yywrap(void) {
     return 1;
     return 1;

+ 257 - 139
paser/y.tab.c

@@ -142,7 +142,11 @@ extern int yydebug;
     MOREEQ = 276,
     MOREEQ = 276,
     LESSEQ = 277,
     LESSEQ = 277,
     NOTEQ = 278,
     NOTEQ = 278,
-    BREAK = 279
+    BREAK = 279,
+    IF = 280,
+    ELSE = 281,
+    ELIF = 282,
+    BROKEN = 283
   };
   };
 #endif
 #endif
 /* Tokens.  */
 /* Tokens.  */
@@ -168,6 +172,10 @@ extern int yydebug;
 #define LESSEQ 277
 #define LESSEQ 277
 #define NOTEQ 278
 #define NOTEQ 278
 #define BREAK 279
 #define BREAK 279
+#define IF 280
+#define ELSE 281
+#define ELIF 282
+#define BROKEN 283
 
 
 /* Value type.  */
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@@ -178,9 +186,10 @@ union YYSTYPE
     int int_value;
     int int_value;
     double double_value;
     double double_value;
     char *string_value;
     char *string_value;
-    void *statement_value;
+    struct statement *statement_value;
+    struct if_list *if_list_base;
 
 
-#line 184 "y.tab.c"
+#line 193 "y.tab.c"
 
 
 };
 };
 typedef union YYSTYPE YYSTYPE;
 typedef union YYSTYPE YYSTYPE;
@@ -497,21 +506,21 @@ union yyalloc
 #endif /* !YYCOPY_NEEDED */
 #endif /* !YYCOPY_NEEDED */
 
 
 /* YYFINAL -- State number of the termination state.  */
 /* YYFINAL -- State number of the termination state.  */
-#define YYFINAL  22
+#define YYFINAL  30
 /* YYLAST -- Last index in YYTABLE.  */
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   61
+#define YYLAST   91
 
 
 /* YYNTOKENS -- Number of terminals.  */
 /* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  25
+#define YYNTOKENS  29
 /* YYNNTS -- Number of nonterminals.  */
 /* YYNNTS -- Number of nonterminals.  */
-#define YYNNTS  15
+#define YYNNTS  21
 /* YYNRULES -- Number of rules.  */
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  33
+#define YYNRULES  45
 /* YYNSTATES -- Number of states.  */
 /* YYNSTATES -- Number of states.  */
-#define YYNSTATES  58
+#define YYNSTATES  80
 
 
 #define YYUNDEFTOK  2
 #define YYUNDEFTOK  2
-#define YYMAXUTOK   279
+#define YYMAXUTOK   283
 
 
 
 
 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
@@ -550,17 +559,19 @@ static const yytype_int8 yytranslate[] =
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
-      15,    16,    17,    18,    19,    20,    21,    22,    23,    24
+      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
+      25,    26,    27,    28
 };
 };
 
 
 #if YYDEBUG
 #if YYDEBUG
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
-static const yytype_uint8 yyrline[] =
+static const yytype_int16 yyrline[] =
 {
 {
-       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
+       0,    22,    22,    26,    33,    40,    50,    54,    58,    62,
+      66,    70,    77,    81,    93,    94,   103,   112,   121,   130,
+     139,   151,   152,   161,   173,   174,   183,   195,   196,   197,
+     204,   215,   227,   232,   241,   247,   256,   267,   274,   286,
+     290,   291,   299,   309,   310,   317
 };
 };
 #endif
 #endif
 
 
@@ -571,10 +582,12 @@ static const char *const yytname[] =
 {
 {
   "$end", "error", "$undefined", "NUMBER", "STRING", "VAR", "ADD", "SUB",
   "$end", "error", "$undefined", "NUMBER", "STRING", "VAR", "ADD", "SUB",
   "DIV", "MUL", "EQ", "LESS", "MORE", "RB", "LB", "RP", "LP", "WHILE",
   "DIV", "MUL", "EQ", "LESS", "MORE", "RB", "LB", "RP", "LP", "WHILE",
-  "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", "break_exp", YY_NULLPTR
+  "STOP", "POW", "EQUAL", "MOREEQ", "LESSEQ", "NOTEQ", "BREAK", "IF",
+  "ELSE", "ELIF", "BROKEN", "$accept", "command_block", "command_list",
+  "command", "top_exp", "third_number", "second_number", "first_number",
+  "element", "base_number", "base_var_", "if_block", "elif_exp", "if_exp",
+  "while_block", "while_exp", "block", "break_exp", "break_token",
+  "broken_exp", "broken_token", YY_NULLPTR
 };
 };
 #endif
 #endif
 
 
@@ -585,11 +598,11 @@ static const yytype_int16 yytoknum[] =
 {
 {
        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
-     275,   276,   277,   278,   279
+     275,   276,   277,   278,   279,   280,   281,   282,   283
 };
 };
 # endif
 # endif
 
 
-#define YYPACT_NINF (-9)
+#define YYPACT_NINF (-23)
 
 
 #define yypact_value_is_default(Yyn) \
 #define yypact_value_is_default(Yyn) \
   ((Yyn) == YYPACT_NINF)
   ((Yyn) == YYPACT_NINF)
@@ -603,12 +616,14 @@ static const yytype_int16 yytoknum[] =
      STATE-NUM.  */
      STATE-NUM.  */
 static const yytype_int8 yypact[] =
 static const yytype_int8 yypact[] =
 {
 {
-      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
+      59,   -23,   -23,     4,     9,   -23,   -23,    16,   -23,    34,
+      59,   -23,    17,    68,    15,    24,   -23,   -23,    27,    -7,
+      25,    28,    25,    35,     4,    36,     4,    30,     4,     4,
+     -23,   -23,    28,   -23,     4,     4,     4,     4,     4,     4,
+       4,     4,     4,     4,     4,   -23,   -23,    31,    25,    59,
+     -23,   -23,   -23,   -23,   -23,   -23,   -23,   -23,   -23,    39,
+      42,    15,    15,    15,    15,    15,    15,    24,    24,   -23,
+     -23,   -23,     4,   -23,    33,   -23,   -23,    43,   -23,   -23
 };
 };
 
 
   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -616,26 +631,30 @@ static const yytype_int8 yypact[] =
      means the default is an error.  */
      means the default is an error.  */
 static const yytype_int8 yydefact[] =
 static const yytype_int8 yydefact[] =
 {
 {
-       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
+       0,    30,    31,     0,     0,     6,    42,     0,    45,     0,
+       2,     3,     0,    12,    14,    21,    24,    27,    28,     0,
+       0,     5,     0,     0,    40,     0,    43,     0,     0,     0,
+       1,     4,     0,     7,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     9,    35,     0,     0,     0,
+      32,     8,    37,    10,    41,    28,    11,    44,    29,     0,
+       0,    17,    16,    15,    18,    19,    20,    22,    23,    26,
+      25,    13,     0,    33,     0,    38,    36,     0,    39,    34
 };
 };
 
 
   /* YYPGOTO[NTERM-NUM].  */
   /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int8 yypgoto[] =
 static const yytype_int8 yypgoto[] =
 {
 {
-      -9,    -9,    14,    -7,     1,    -9,    30,    11,    12,    -9,
-       0,    -6,    -9,    -9,    -9
+     -23,   -23,    10,    -8,    -2,   -23,   -22,    -1,   -18,   -23,
+       0,   -23,   -23,   -23,    -6,   -23,   -17,   -23,   -23,   -23,
+     -23
 };
 };
 
 
   /* YYDEFGOTO[NTERM-NUM].  */
   /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int8 yydefgoto[] =
 static const yytype_int8 yydefgoto[] =
 {
 {
-      -1,     7,     8,     9,    10,    11,    12,    13,    14,    15,
-      44,    17,    18,    39,    19
+      -1,     9,    10,    11,    12,    13,    14,    15,    16,    17,
+      55,    19,    48,    20,    21,    22,    50,    23,    24,    25,
+      26
 };
 };
 
 
   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
@@ -643,54 +662,64 @@ static const yytype_int8 yydefgoto[] =
      number is the opposite.  If YYTABLE_NINF, syntax error.  */
      number is the opposite.  If YYTABLE_NINF, syntax error.  */
 static const yytype_int8 yytable[] =
 static const yytype_int8 yytable[] =
 {
 {
-      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
+      18,    27,    31,    18,    32,    52,    54,     1,    57,     2,
+      18,    45,    61,    62,    63,    64,    65,    66,     3,    46,
+      47,    40,    41,    28,    69,    70,    59,    60,    18,    18,
+      29,    73,    42,    43,    30,    33,     1,    44,     2,    67,
+      68,    49,    71,    58,    18,    72,    51,     3,    78,    18,
+       4,     5,    75,    53,    56,    76,    79,     6,     7,    74,
+       0,     8,     1,     0,     2,     0,    31,     0,    32,     0,
+      77,     0,    18,     3,    18,     0,     4,     5,     0,    34,
+      35,     0,     0,     6,     7,     0,     0,     8,    36,    37,
+      38,    39
 };
 };
 
 
 static const yytype_int8 yycheck[] =
 static const yytype_int8 yycheck[] =
 {
 {
-       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
+       0,     3,    10,     3,    10,    22,    24,     3,    26,     5,
+      10,    18,    34,    35,    36,    37,    38,    39,    14,    26,
+      27,     6,     7,    14,    42,    43,    28,    29,    28,    29,
+      14,    48,     8,     9,     0,    18,     3,    10,     5,    40,
+      41,    16,    44,    13,    44,    14,    18,    14,    15,    49,
+      17,    18,    13,    18,    18,    13,    13,    24,    25,    49,
+      -1,    28,     3,    -1,     5,    -1,    74,    -1,    74,    -1,
+      72,    -1,    72,    14,    74,    -1,    17,    18,    -1,    11,
+      12,    -1,    -1,    24,    25,    -1,    -1,    28,    20,    21,
+      22,    23
 };
 };
 
 
   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
      symbol of state STATE-NUM.  */
      symbol of state STATE-NUM.  */
 static const yytype_int8 yystos[] =
 static const yytype_int8 yystos[] =
 {
 {
-       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
+       0,     3,     5,    14,    17,    18,    24,    25,    28,    30,
+      31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
+      42,    43,    44,    46,    47,    48,    49,    33,    14,    14,
+       0,    32,    43,    18,    11,    12,    20,    21,    22,    23,
+       6,     7,     8,     9,    10,    18,    26,    27,    41,    16,
+      45,    18,    45,    18,    37,    39,    18,    37,    13,    33,
+      33,    35,    35,    35,    35,    35,    35,    36,    36,    37,
+      37,    33,    14,    45,    31,    13,    13,    33,    15,    13
 };
 };
 
 
   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 static const yytype_int8 yyr1[] =
 static const yytype_int8 yyr1[] =
 {
 {
-       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
+       0,    29,    30,    31,    31,    31,    32,    32,    32,    32,
+      32,    32,    33,    33,    34,    34,    34,    34,    34,    34,
+      34,    35,    35,    35,    36,    36,    36,    37,    37,    37,
+      38,    39,    40,    40,    41,    41,    42,    43,    44,    45,
+      46,    46,    47,    48,    48,    49
 };
 };
 
 
   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
 static const yytype_int8 yyr2[] =
 static const yytype_int8 yyr2[] =
 {
 {
        0,     2,     1,     1,     2,     1,     1,     2,     2,     2,
        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
+       2,     2,     1,     3,     1,     3,     3,     3,     3,     3,
+       3,     1,     3,     3,     1,     3,     3,     1,     1,     3,
+       1,     1,     2,     3,     4,     1,     4,     2,     4,     3,
+       1,     2,     1,     1,     2,     1
 };
 };
 
 
 
 
@@ -1386,80 +1415,96 @@ yyreduce:
   switch (yyn)
   switch (yyn)
     {
     {
   case 3:
   case 3:
-#line 26 "gwarf_yacc.y"
+#line 27 "gwarf_yacc.y"
     {
     {
         if((yyvsp[0].statement_value) != NULL){
         if((yyvsp[0].statement_value) != NULL){
             statement *tmp = find_statement_list(0, statement_base);
             statement *tmp = find_statement_list(0, statement_base);
             append_statement(tmp, (yyvsp[0].statement_value));
             append_statement(tmp, (yyvsp[0].statement_value));
         }
         }
     }
     }
-#line 1397 "y.tab.c"
+#line 1426 "y.tab.c"
     break;
     break;
 
 
   case 4:
   case 4:
-#line 33 "gwarf_yacc.y"
+#line 34 "gwarf_yacc.y"
     {   
     {   
         if((yyvsp[0].statement_value) != NULL){
         if((yyvsp[0].statement_value) != NULL){
             statement *tmp = find_statement_list(0, statement_base);
             statement *tmp = find_statement_list(0, statement_base);
             append_statement(tmp, (yyvsp[0].statement_value));
             append_statement(tmp, (yyvsp[0].statement_value));
         }
         }
     }
     }
-#line 1408 "y.tab.c"
+#line 1437 "y.tab.c"
     break;
     break;
 
 
   case 5:
   case 5:
-#line 40 "gwarf_yacc.y"
+#line 41 "gwarf_yacc.y"
     {   
     {   
         if((yyvsp[0].statement_value) != NULL){
         if((yyvsp[0].statement_value) != NULL){
             statement *tmp = find_statement_list(0, statement_base);
             statement *tmp = find_statement_list(0, statement_base);
             append_statement(tmp, (yyvsp[0].statement_value));
             append_statement(tmp, (yyvsp[0].statement_value));
         }
         }
     }
     }
-#line 1419 "y.tab.c"
+#line 1448 "y.tab.c"
     break;
     break;
 
 
   case 6:
   case 6:
-#line 50 "gwarf_yacc.y"
+#line 51 "gwarf_yacc.y"
     {
     {
         (yyval.statement_value) = NULL;
         (yyval.statement_value) = NULL;
     }
     }
-#line 1427 "y.tab.c"
+#line 1456 "y.tab.c"
     break;
     break;
 
 
   case 7:
   case 7:
-#line 54 "gwarf_yacc.y"
+#line 55 "gwarf_yacc.y"
     {
     {
         (yyval.statement_value) = (yyvsp[-1].statement_value);
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
     }
-#line 1435 "y.tab.c"
+#line 1464 "y.tab.c"
     break;
     break;
 
 
   case 8:
   case 8:
-#line 58 "gwarf_yacc.y"
+#line 59 "gwarf_yacc.y"
     {   
     {   
         (yyval.statement_value) = (yyvsp[-1].statement_value);
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
     }
-#line 1443 "y.tab.c"
+#line 1472 "y.tab.c"
     break;
     break;
 
 
   case 9:
   case 9:
-#line 62 "gwarf_yacc.y"
+#line 63 "gwarf_yacc.y"
     {
     {
         (yyval.statement_value) = (yyvsp[-1].statement_value);
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
     }
-#line 1451 "y.tab.c"
+#line 1480 "y.tab.c"
     break;
     break;
 
 
   case 10:
   case 10:
-#line 69 "gwarf_yacc.y"
+#line 67 "gwarf_yacc.y"
     {
     {
-        (yyval.statement_value) = (yyvsp[0].statement_value);
+        (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
     }
-#line 1459 "y.tab.c"
+#line 1488 "y.tab.c"
     break;
     break;
 
 
   case 11:
   case 11:
-#line 73 "gwarf_yacc.y"
+#line 71 "gwarf_yacc.y"
+    {
+        (yyval.statement_value) = (yyvsp[-1].statement_value);
+    }
+#line 1496 "y.tab.c"
+    break;
+
+  case 12:
+#line 78 "gwarf_yacc.y"
+    {
+        (yyval.statement_value) = (yyvsp[0].statement_value);
+    }
+#line 1504 "y.tab.c"
+    break;
+
+  case 13:
+#line 82 "gwarf_yacc.y"
     {
     {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
         code_tmp->type = operation;
@@ -1468,11 +1513,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
         (yyval.statement_value) = code_tmp;
     }
     }
-#line 1472 "y.tab.c"
+#line 1517 "y.tab.c"
     break;
     break;
 
 
-  case 13:
-#line 86 "gwarf_yacc.y"
+  case 15:
+#line 95 "gwarf_yacc.y"
     {
     {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
         code_tmp->type = operation;
@@ -1481,11 +1526,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
         (yyval.statement_value) = code_tmp;
     }
     }
-#line 1485 "y.tab.c"
+#line 1530 "y.tab.c"
     break;
     break;
 
 
-  case 14:
-#line 95 "gwarf_yacc.y"
+  case 16:
+#line 104 "gwarf_yacc.y"
     {
     {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
         code_tmp->type = operation;
@@ -1494,11 +1539,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
         (yyval.statement_value) = code_tmp;
     }
     }
-#line 1498 "y.tab.c"
+#line 1543 "y.tab.c"
     break;
     break;
 
 
-  case 15:
-#line 104 "gwarf_yacc.y"
+  case 17:
+#line 113 "gwarf_yacc.y"
     {
     {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
         code_tmp->type = operation;
@@ -1507,11 +1552,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
         (yyval.statement_value) = code_tmp;
     }
     }
-#line 1511 "y.tab.c"
+#line 1556 "y.tab.c"
     break;
     break;
 
 
-  case 16:
-#line 113 "gwarf_yacc.y"
+  case 18:
+#line 122 "gwarf_yacc.y"
         {
         {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
         code_tmp->type = operation;
@@ -1520,11 +1565,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
         (yyval.statement_value) = code_tmp;
     }
     }
-#line 1524 "y.tab.c"
+#line 1569 "y.tab.c"
     break;
     break;
 
 
-  case 17:
-#line 122 "gwarf_yacc.y"
+  case 19:
+#line 131 "gwarf_yacc.y"
     {
     {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
         code_tmp->type = operation;
@@ -1533,11 +1578,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
         (yyval.statement_value) = code_tmp;
     }
     }
-#line 1537 "y.tab.c"
+#line 1582 "y.tab.c"
     break;
     break;
 
 
-  case 18:
-#line 131 "gwarf_yacc.y"
+  case 20:
+#line 140 "gwarf_yacc.y"
     {
     {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
         code_tmp->type = operation;
@@ -1546,11 +1591,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
         (yyval.statement_value) = code_tmp;
     }
     }
-#line 1550 "y.tab.c"
+#line 1595 "y.tab.c"
     break;
     break;
 
 
-  case 20:
-#line 144 "gwarf_yacc.y"
+  case 22:
+#line 153 "gwarf_yacc.y"
     {
     {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
         code_tmp->type = operation;
@@ -1559,11 +1604,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
         (yyval.statement_value) = code_tmp;
     }
     }
-#line 1563 "y.tab.c"
+#line 1608 "y.tab.c"
     break;
     break;
 
 
-  case 21:
-#line 153 "gwarf_yacc.y"
+  case 23:
+#line 162 "gwarf_yacc.y"
     {
     {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
         code_tmp->type = operation;
@@ -1572,11 +1617,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
         (yyval.statement_value) = code_tmp;
     }
     }
-#line 1576 "y.tab.c"
+#line 1621 "y.tab.c"
     break;
     break;
 
 
-  case 23:
-#line 166 "gwarf_yacc.y"
+  case 25:
+#line 175 "gwarf_yacc.y"
     {
     {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
         code_tmp->type = operation;
@@ -1585,11 +1630,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
         (yyval.statement_value) = code_tmp;
     }
     }
-#line 1589 "y.tab.c"
+#line 1634 "y.tab.c"
     break;
     break;
 
 
-  case 24:
-#line 175 "gwarf_yacc.y"
+  case 26:
+#line 184 "gwarf_yacc.y"
     {
     {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
         code_tmp->type = operation;
@@ -1598,19 +1643,19 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
         (yyval.statement_value) = code_tmp;
     }
     }
-#line 1602 "y.tab.c"
+#line 1647 "y.tab.c"
     break;
     break;
 
 
-  case 27:
-#line 189 "gwarf_yacc.y"
+  case 29:
+#line 198 "gwarf_yacc.y"
     {
     {
         (yyval.statement_value) = (yyvsp[-1].statement_value);
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
     }
-#line 1610 "y.tab.c"
+#line 1655 "y.tab.c"
     break;
     break;
 
 
-  case 28:
-#line 196 "gwarf_yacc.y"
+  case 30:
+#line 205 "gwarf_yacc.y"
     {
     {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->type = base_value;
         code_tmp->type = base_value;
@@ -1618,11 +1663,11 @@ yyreduce:
         code_tmp->code.base_value.value.value.double_value = (yyvsp[0].double_value);
         code_tmp->code.base_value.value.value.double_value = (yyvsp[0].double_value);
         (yyval.statement_value) = code_tmp;
         (yyval.statement_value) = code_tmp;
     }
     }
-#line 1622 "y.tab.c"
+#line 1667 "y.tab.c"
     break;
     break;
 
 
-  case 29:
-#line 207 "gwarf_yacc.y"
+  case 31:
+#line 216 "gwarf_yacc.y"
     {
     {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->code.base_var.var_name = malloc(sizeof((yyvsp[0].string_value)));
         code_tmp->code.base_var.var_name = malloc(sizeof((yyvsp[0].string_value)));
@@ -1631,19 +1676,70 @@ yyreduce:
         strcpy(name_tmp, (yyvsp[0].string_value));
         strcpy(name_tmp, (yyvsp[0].string_value));
         (yyval.statement_value) = code_tmp;
         (yyval.statement_value) = code_tmp;
     }
     }
-#line 1635 "y.tab.c"
+#line 1680 "y.tab.c"
     break;
     break;
 
 
-  case 30:
-#line 219 "gwarf_yacc.y"
+  case 32:
+#line 228 "gwarf_yacc.y"
     {
     {
         statement_base = free_statement_list(statement_base);  // new statement_base (FILO)
         statement_base = free_statement_list(statement_base);  // new statement_base (FILO)
+        (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
     }
-#line 1643 "y.tab.c"
+#line 1689 "y.tab.c"
     break;
     break;
 
 
-  case 31:
-#line 226 "gwarf_yacc.y"
+  case 33:
+#line 233 "gwarf_yacc.y"
+    {
+        append_elif((yyvsp[-1].if_list_base), (yyvsp[-2].statement_value)->code.if_branch.done);
+        (yyval.statement_value) = (yyvsp[-2].statement_value);
+        statement_base = free_statement_list(statement_base);  // new statement_base (FILO)
+    }
+#line 1699 "y.tab.c"
+    break;
+
+  case 34:
+#line 242 "gwarf_yacc.y"
+    {
+        statement *done_tmp =  make_statement();
+        (yyval.if_list_base) = make_if((yyvsp[-1].statement_value), done_tmp);
+        statement_base = append_statement_list(done_tmp, statement_base);  // new statement_base (FILO)
+    }
+#line 1709 "y.tab.c"
+    break;
+
+  case 35:
+#line 248 "gwarf_yacc.y"
+    {
+        statement *done_tmp =  make_statement();
+        (yyval.if_list_base) = make_if(NULL, done_tmp);
+        statement_base = append_statement_list(done_tmp, statement_base);  // new statement_base (FILO)
+    }
+#line 1719 "y.tab.c"
+    break;
+
+  case 36:
+#line 257 "gwarf_yacc.y"
+    {
+        statement *if_tmp =  make_statement(), *done_tmp =  make_statement();
+        if_tmp->type = if_branch;
+        if_tmp->code.if_branch.done = make_if((yyvsp[-1].statement_value), done_tmp);
+        statement_base = append_statement_list(done_tmp, statement_base);  // new statement_base (FILO)
+        (yyval.statement_value) = if_tmp;
+    }
+#line 1731 "y.tab.c"
+    break;
+
+  case 37:
+#line 268 "gwarf_yacc.y"
+    {
+        statement_base = free_statement_list(statement_base);  // new statement_base (FILO)
+    }
+#line 1739 "y.tab.c"
+    break;
+
+  case 38:
+#line 275 "gwarf_yacc.y"
     {
     {
         statement *while_tmp =  make_statement();
         statement *while_tmp =  make_statement();
         while_tmp->type = while_cycle;
         while_tmp->type = while_cycle;
@@ -1652,29 +1748,51 @@ yyreduce:
         statement_base = append_statement_list(while_tmp->code.while_cycle.done, statement_base);  // new statement_base (FILO)
         statement_base = append_statement_list(while_tmp->code.while_cycle.done, statement_base);  // new statement_base (FILO)
         (yyval.statement_value) = while_tmp;
         (yyval.statement_value) = while_tmp;
     }
     }
-#line 1656 "y.tab.c"
+#line 1752 "y.tab.c"
     break;
     break;
 
 
-  case 32:
-#line 238 "gwarf_yacc.y"
+  case 41:
+#line 292 "gwarf_yacc.y"
     {
     {
-        printf("start-0\n");
+        (yyvsp[-1].statement_value)->code.break_cycle.times = (yyvsp[0].statement_value);
+        (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
     }
-#line 1664 "y.tab.c"
+#line 1761 "y.tab.c"
     break;
     break;
 
 
-  case 33:
-#line 245 "gwarf_yacc.y"
+  case 42:
+#line 300 "gwarf_yacc.y"
     {
     {
         statement *code_tmp =  make_statement();
         statement *code_tmp =  make_statement();
         code_tmp->type = break_cycle;
         code_tmp->type = break_cycle;
+        code_tmp->code.break_cycle.times = NULL;
+        (yyval.statement_value) = code_tmp;
+    }
+#line 1772 "y.tab.c"
+    break;
+
+  case 44:
+#line 311 "gwarf_yacc.y"
+    {
+        (yyvsp[-1].statement_value)->code.broken.times = (yyvsp[0].statement_value);
+        (yyval.statement_value) = (yyvsp[-1].statement_value);
+    }
+#line 1781 "y.tab.c"
+    break;
+
+  case 45:
+#line 318 "gwarf_yacc.y"
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = broken;
+        code_tmp->code.broken.times = NULL;
         (yyval.statement_value) = code_tmp;
         (yyval.statement_value) = code_tmp;
     }
     }
-#line 1674 "y.tab.c"
+#line 1792 "y.tab.c"
     break;
     break;
 
 
 
 
-#line 1678 "y.tab.c"
+#line 1796 "y.tab.c"
 
 
       default: break;
       default: break;
     }
     }
@@ -1906,11 +2024,11 @@ yyreturn:
 #endif
 #endif
   return yyresult;
   return yyresult;
 }
 }
-#line 252 "gwarf_yacc.y"
+#line 326 "gwarf_yacc.y"
 
 
 int yyerror(char const *str)
 int yyerror(char const *str)
 {
 {
-    fprintf(stderr, "parser error near %s ;\n", yytext, yytext);
+    fprintf(stderr, "parser error near [%s] ;\n", yytext, yytext);
     return 0;
     return 0;
 }
 }
 
 

+ 12 - 3
paser/y.tab.h

@@ -70,7 +70,11 @@ extern int yydebug;
     MOREEQ = 276,
     MOREEQ = 276,
     LESSEQ = 277,
     LESSEQ = 277,
     NOTEQ = 278,
     NOTEQ = 278,
-    BREAK = 279
+    BREAK = 279,
+    IF = 280,
+    ELSE = 281,
+    ELIF = 282,
+    BROKEN = 283
   };
   };
 #endif
 #endif
 /* Tokens.  */
 /* Tokens.  */
@@ -96,6 +100,10 @@ extern int yydebug;
 #define LESSEQ 277
 #define LESSEQ 277
 #define NOTEQ 278
 #define NOTEQ 278
 #define BREAK 279
 #define BREAK 279
+#define IF 280
+#define ELSE 281
+#define ELIF 282
+#define BROKEN 283
 
 
 /* Value type.  */
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@@ -106,9 +114,10 @@ union YYSTYPE
     int int_value;
     int int_value;
     double double_value;
     double double_value;
     char *string_value;
     char *string_value;
-    void *statement_value;
+    struct statement *statement_value;
+    struct if_list *if_list_base;
 
 
-#line 112 "y.tab.h"
+#line 121 "y.tab.h"
 
 
 };
 };
 typedef union YYSTYPE YYSTYPE;
 typedef union YYSTYPE YYSTYPE;