Sfoglia il codice sorgente

修正了变量层级的问题, 加入default语句

SongZihuan 5 anni fa
parent
commit
5c5391eb68
8 ha cambiato i file con 485 aggiunte e 341 eliminazioni
  1. BIN
      gwarf
  2. 21 0
      gwarf_interpreter/interprete.h
  3. 65 4
      gwarf_interpreter/interpreter.c
  4. 1 0
      paser/gwarf_lex.l
  5. 22 2
      paser/gwarf_yacc.y
  6. 118 108
      paser/lex.yy.c
  7. 254 225
      paser/y.tab.c
  8. 4 2
      paser/y.tab.h

BIN
gwarf


+ 21 - 0
gwarf_interpreter/interprete.h

@@ -45,6 +45,7 @@ typedef struct statement{
         restarted,
         rego,
         rewent,
+        set_default,
     } type;  // the statement type
 
     union
@@ -115,6 +116,11 @@ typedef struct statement{
         struct{
         } rewent;
 
+        struct{
+            char *name;
+            struct statement *times;  // 层数
+        } set_default;
+
     } code;
     struct statement *next;
 } statement;
@@ -138,10 +144,18 @@ typedef struct GWARF_result{
     } u;  // the result type[from where]
 } GWARF_result;
 
+// ------------------------- default_var [记录默认变量[层]]
+typedef struct default_var{
+    char *name;
+    int from;
+    struct default_var *next;
+} default_var;
+
 // ------------------------- var base list [记录每一层变量base的链表]
 
 typedef struct var_list{
     var *var_base;
+    default_var *default_list;
     struct var_list *next;
 } var_list;
 
@@ -175,6 +189,13 @@ void free_var(var *);
 var *get_var(char *, var *);
 void del_var(char *, var *);
 
+
+default_var *make_default_var();
+default_var *make_default_var_base();
+void append_default_var_base(char * ,int , default_var *);
+int get_default(char *, default_var *);
+
+
 //------- statement func
 statement *make_statement();
 statement *append_statement(statement *, statement*);

+ 65 - 4
gwarf_interpreter/interpreter.c

@@ -93,6 +93,54 @@ void del_var(char *name, var *base_var){  // free an address
     }
 }
 
+// --------------default_var
+
+default_var *make_default_var(){  // make_default_var
+    default_var *tmp;
+    tmp = malloc(sizeof(default_var));  // get an address for default_var
+    tmp->next = NULL;
+    return tmp;
+}
+
+default_var *make_default_var_base(){  // if
+    default_var *tmp = make_default_var();
+    tmp->name = "";
+    tmp->from = 0;
+    return tmp;
+}
+
+void append_default_var_base(char *name ,int from, default_var *base_default_var){  // elif
+    default_var *start = base_default_var;
+    while(1){
+        if (!strcmp(start->name, name)){  // if tmp->name == name , strcmp will return 0, if not strcmp return not 0
+            puts("SECOND");
+            return;  // 不可以二次设置
+        }
+        if (start->next == NULL){  // not var name *name
+            break;
+        }
+        start = start->next;  // get the next to iter
+    }
+    default_var *tmp = make_default_var();
+    tmp->name = name;
+    tmp->from = from;
+    start->next = tmp;
+    return;
+}
+
+int get_default(char *name, default_var *base_default_var){  // get the address
+    default_var *tmp = base_default_var;  // iter var
+    while(1){
+        if (!strcmp(tmp->name, name)){  // if tmp->name == name , strcmp will return 0, if not strcmp return not 0
+            return tmp->from;
+        }
+        if (tmp->next == NULL){  // not var name *name
+            return 0;
+        }
+        tmp = tmp->next;  // get the next to iter
+    }
+}
+
 // ---- statement list
 
 statement *make_statement(){  // make statement
@@ -122,6 +170,7 @@ var_list *make_var_list(){  // make a empty var_list node
     tmp = malloc(sizeof(var_list));  // get an address for base var
     tmp->next = NULL;
     tmp->var_base = NULL;
+    tmp->default_list = make_default_var_base();
     return tmp;
 }
 
@@ -151,6 +200,8 @@ var_list *free_var_list(var_list *var_list_base){  // free one var_list[FILO]
 var *find_var(var_list *var_base,int from, char *name){  // find var by func get_var in var_list[iter to find]
     var_list *start = var_base;
     var *return_var;
+    from += get_default(name, var_base->default_list);
+    printf("find from = %d\n", from);
     for(int i = 0;i < from;i+= 1){
         printf("the start = %d\n", start);
         if(start->next == NULL){
@@ -176,6 +227,9 @@ 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;
+    printf("base from = %d\n", from);
+    from += get_default(name, var_base->default_list);
+    printf("add from = %d\n", from);
     for(int i = 0;i < from;i+= 1){
         if(start->next == NULL){
             break;
@@ -382,6 +436,13 @@ GWARF_result read_statement_list(statement *the_statement, var_list *the_var){
         case rego:
             return_value.u = code_rego;  // rego now
             break;
+        case set_default:{
+            char *name = the_statement->code.set_default.name;
+            int base_from = (int)traverse(the_statement->code.set_default.times, the_var, false).value.value.double_value;
+            append_default_var_base(name, base_from, the_var->default_list);
+            printf("set_default for %s\n", name);
+            break;
+        }
         default:
             puts("default");
             break;
@@ -568,11 +629,11 @@ GWARF_result operation_func(statement *the_statement, var_list *the_var){  // re
         case ASSIGMENT_func:{  // because the var char, we should ues a {} to make a block[name space] for the tmp var;
             char *left = (the_statement->code.operation.left_exp)->code.base_var.var_name;  // get var name but not value
             int from = 0;
-            if((the_statement->code).base_var.from == NULL){
+            if((the_statement->code.operation.left_exp)->code.base_var.from == NULL){
                 from = 0;
             }
             else{
-                from = (int)traverse((the_statement->code).base_var.from, the_var, false).value.value.double_value;
+                from = (int)traverse((the_statement->code.operation.left_exp)->code.base_var.from, the_var, false).value.value.double_value;
             }
             value = assigment_func(left, right_result, the_var, from);
             break;
@@ -704,8 +765,8 @@ GWARF_result traverse(statement *the_statement, var_list *the_var, bool new){  /
             result = result2;
             break;
             }
-        if((result2.u == cycle_continue) || (result2.u == code_continued) || (result.u == cycle_restart) || (result.u == code_restarted)){
-            puts("----continue/continued or restart/restarted----");
+        if((result2.u == cycle_continue) || (result2.u == code_continued) || (result2.u == cycle_restart) || (result2.u == code_restarted)){
+            printf("----continue/continued or restart/restarted----[%d]", result2.u);
             result = result2;
             break;
         }

+ 1 - 0
paser/gwarf_lex.l

@@ -37,6 +37,7 @@
 <INITIAL>"^" {return POW;}
 <INITIAL>"[" {return LI;}
 <INITIAL>"]" {return RI;}
+<INITIAL>"default" {return DEFAULT;}
 
 <INITIAL>"#" {BEGIN COMMENT;}
 <INITIAL>' {BEGIN STRING_TEXT;}

+ 22 - 2
paser/gwarf_yacc.y

@@ -14,9 +14,9 @@
 }
 %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 BREAK IF ELSE ELIF BROKEN CONTINUE CONTINUED RESTART RESTARTED REGO REWENT RI LI
+%token ADD SUB DIV MUL EQ LESS MORE RB LB RP LP WHILE STOP POW EQUAL MOREEQ LESSEQ NOTEQ BREAK IF ELSE ELIF BROKEN CONTINUE CONTINUED RESTART RESTARTED REGO REWENT RI LI DEFAULT
 %type <statement_value> base_number base_var_token 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 continue_token continue_exp
-%type <statement_value> continued_exp continued_token restart_exp restart_token restarted_exp restarted_token
+%type <statement_value> continued_exp continued_token restart_exp restart_token restarted_exp restarted_token default_token
 %type <if_list_base> elif_exp
 %%
 command_block
@@ -100,6 +100,10 @@ command
         code_tmp->type = rewent;
         $$ = code_tmp;
     }
+    | default_token STOP
+    {
+        $$ = $1;
+    }
     ;
 
 top_exp
@@ -240,6 +244,21 @@ base_number
     }
     ;
 
+default_token
+    : DEFAULT base_var_token element
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = set_default;
+        code_tmp->code.set_default.times = $3;
+        code_tmp->code.set_default.name = malloc(sizeof($2->code.base_var.var_name));
+        char *name_tmp = code_tmp->code.set_default.name;
+        strcpy(name_tmp, $2->code.base_var.var_name);
+        free($2->code.base_var.var_name);
+        free($2);
+        $$ = code_tmp;
+    }
+    ;
+
 base_var_
     : base_var_token
     | LI element RI base_var_token
@@ -256,6 +275,7 @@ base_var_token
         code_tmp->code.base_var.var_name = malloc(sizeof($1));
         char *name_tmp = code_tmp->code.base_var.var_name;
         code_tmp->type = base_var;
+        code_tmp->code.base_var.from = NULL;
         strcpy(name_tmp, $1);
         $$ = code_tmp;
     }

+ 118 - 108
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 47
-#define YY_END_OF_BUFFER 48
+#define YY_NUM_RULES 48
+#define YY_END_OF_BUFFER 49
 /* This struct is not used in this scanner,
    but its presence is necessary. */
 struct yy_trans_info
@@ -360,20 +360,21 @@ struct yy_trans_info
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	};
-static const flex_int16_t yy_accept[107] =
+static const flex_int16_t yy_accept[114] =
     {   0,
-        0,    0,    0,    0,    0,    0,   48,   39,   37,   36,
-       39,   33,   31,   32,   13,   14,   26,   24,   25,   27,
-       34,   34,   38,   21,   23,   20,   35,   29,   30,   28,
-       35,   35,   35,   35,   35,   35,   15,   16,   42,   40,
-       41,   46,   45,   44,   43,    0,    0,   15,   19,    0,
-       34,   37,   18,   22,   17,   35,   35,   35,   35,    2,
-       35,   35,   15,    0,   34,   35,   35,   35,   35,   35,
-       35,   35,   35,   35,    0,    0,   35,   35,   35,    3,
-        4,   11,   35,   35,   35,    3,    4,    5,   35,   35,
-        0,   35,   35,    1,    6,   35,    4,   35,   12,   35,
-
-        8,    7,   35,   10,    9,    0
+        0,    0,    0,    0,    0,    0,   49,   40,   38,   37,
+       40,   34,   32,   33,   13,   14,   26,   24,   25,   27,
+       35,   35,   39,   21,   23,   20,   36,   29,   30,   28,
+       36,   36,   36,   36,   36,   36,   36,   15,   16,   43,
+       41,   42,   47,   46,   45,   44,    0,    0,   15,   19,
+        0,   35,   38,   18,   22,   17,   36,   36,   36,   36,
+       36,    2,   36,   36,   15,    0,   35,   36,   36,   36,
+       36,   36,   36,   36,   36,   36,   36,    0,    0,   36,
+       36,   36,   36,    3,    4,   11,   36,   36,   36,    3,
+        4,    5,   36,   36,   36,    0,   36,   36,    1,    6,
+
+       36,   36,    4,   36,   12,   36,   31,    8,    7,   36,
+       10,    9,    0
     } ;
 
 static const YY_CHAR yy_ec[256] =
@@ -417,82 +418,86 @@ static const YY_CHAR yy_meta[45] =
         2,    2,    1,    1
     } ;
 
-static const flex_int16_t yy_base[110] =
+static const flex_int16_t yy_base[117] =
     {   0,
-        0,    0,   43,   44,   46,   50,  132,  133,   45,  133,
-      112,  133,  133,  133,  133,  133,  133,  133,  133,  133,
-      133,   43,  128,  110,  109,  108,    0,  133,  133,  133,
-       88,   88,   89,   93,   93,   89,  118,  133,  133,  133,
-      133,  133,  133,  133,  133,   52,   84,  116,  133,   45,
-       49,  133,  133,  133,  133,    0,   34,   81,   33,    0,
-       36,   83,  113,   37,   53,   89,   79,   72,   81,   81,
-       72,   68,   78,   71,   75,   75,   69,   73,   68,    0,
-       92,    0,   69,   57,   63,  133,   83,    0,   54,   53,
-       78,   48,   45,    0,    0,   43,  133,   43,    0,   53,
-
-       51,   51,   49,    0,    0,  133,   95,   97,   71
+        0,    0,   43,   44,   46,   50,  138,  139,   45,  139,
+      118,  139,  139,  139,  139,  139,  139,  139,  139,  139,
+      139,   43,  134,  116,  115,  114,    0,  139,  139,  139,
+       94,   94,  101,   94,   98,   98,   94,  123,  139,  139,
+      139,  139,  139,  139,  139,  139,   52,   89,  121,  139,
+       45,   49,  139,  139,  139,  139,    0,   34,   86,   91,
+       33,    0,   36,   87,  117,   37,   53,   93,   83,   76,
+       90,   84,   84,   75,   71,   81,   74,   78,   78,   72,
+       76,   71,   62,    0,   94,    0,   76,   64,   65,  139,
+       85,    0,   56,   55,   55,   80,   49,   46,    0,    0,
+
+       44,   44,  139,   43,    0,   53,    0,   51,   51,   49,
+        0,    0,  139,   95,   97,   71
     } ;
 
-static const flex_int16_t yy_def[110] =
+static const flex_int16_t yy_def[117] =
     {   0,
-      106,    1,  107,  107,  108,  108,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  109,  106,  106,  106,
-      109,  109,  109,  109,  109,  109,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  109,  109,  109,  109,  109,
-      109,  109,  106,  106,  106,  109,  109,  109,  109,  109,
-      109,  109,  109,  109,  106,  106,  109,  109,  109,  109,
-      109,  109,  109,  109,  109,  106,  106,  109,  109,  109,
-      106,  109,  109,  109,  109,  109,  106,  109,  109,  109,
-
-      109,  109,  109,  109,  109,    0,  106,  106,  106
+      113,    1,  114,  114,  115,  115,  113,  113,  113,  113,
+      113,  113,  113,  113,  113,  113,  113,  113,  113,  113,
+      113,  113,  113,  113,  113,  113,  116,  113,  113,  113,
+      116,  116,  116,  116,  116,  116,  116,  113,  113,  113,
+      113,  113,  113,  113,  113,  113,  113,  113,  113,  113,
+      113,  113,  113,  113,  113,  113,  116,  116,  116,  116,
+      116,  116,  116,  116,  113,  113,  113,  116,  116,  116,
+      116,  116,  116,  116,  116,  116,  116,  113,  113,  116,
+      116,  116,  116,  116,  116,  116,  116,  116,  116,  113,
+      113,  116,  116,  116,  116,  113,  116,  116,  116,  116,
+
+      116,  116,  113,  116,  116,  116,  116,  116,  116,  116,
+      116,  116,    0,  113,  113,  113
     } ;
 
-static const flex_int16_t yy_nxt[178] =
+static const flex_int16_t yy_nxt[184] =
     {   0,
         8,    9,   10,   11,   12,   13,   14,   15,   16,   17,
        18,   19,    8,   20,   21,   22,   23,   24,   25,   26,
-       27,   28,   29,   30,   27,   31,   32,   27,   33,   27,
-       27,   27,   34,   27,   27,   27,   27,   35,   27,   27,
-       27,   36,   37,   38,   40,   40,   46,   43,   41,   41,
-       44,   43,   45,   46,   44,   50,   45,   51,   51,   65,
-       65,   50,   66,   51,   51,   69,   71,   65,   65,   75,
-       67,   70,   56,   47,   72,   76,  105,   73,  104,  103,
-       47,  102,  101,  100,   99,   98,   97,   48,   96,   95,
-       91,   94,   93,   92,   48,   39,   39,   42,   42,   91,
-
-       90,   89,   88,   87,   86,   85,   84,   83,   82,   81,
-       80,   79,   78,   77,   63,   74,   68,   63,   64,   63,
-       62,   61,   60,   59,   58,   57,   55,   54,   53,   52,
-       49,  106,    7,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106
+       27,   28,   29,   30,   27,   31,   32,   33,   34,   27,
+       27,   27,   35,   27,   27,   27,   27,   36,   27,   27,
+       27,   37,   38,   39,   41,   41,   47,   44,   42,   42,
+       45,   44,   46,   47,   45,   51,   46,   52,   52,   67,
+       67,   51,   68,   52,   52,   72,   74,   67,   67,   78,
+       69,   73,   57,   48,   75,   79,  112,   76,  111,  110,
+       48,  109,  108,  107,  106,  105,  104,   49,  103,  102,
+      101,  100,   96,   99,   49,   40,   40,   43,   43,   98,
+
+       97,   96,   95,   94,   93,   92,   91,   90,   89,   88,
+       87,   86,   85,   84,   83,   82,   81,   80,   65,   77,
+       71,   70,   65,   66,   65,   64,   63,   62,   61,   60,
+       59,   58,   56,   55,   54,   53,   50,  113,    7,  113,
+      113,  113,  113,  113,  113,  113,  113,  113,  113,  113,
+      113,  113,  113,  113,  113,  113,  113,  113,  113,  113,
+      113,  113,  113,  113,  113,  113,  113,  113,  113,  113,
+      113,  113,  113,  113,  113,  113,  113,  113,  113,  113,
+      113,  113,  113
     } ;
 
-static const flex_int16_t yy_chk[178] =
+static const flex_int16_t yy_chk[184] =
     {   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,    3,    4,    9,    5,    3,    4,
-        5,    6,    5,   46,    6,   22,    6,   22,   22,   50,
-       50,   51,   57,   51,   51,   59,   61,   65,   65,   64,
-       57,   59,  109,    9,   61,   64,  103,   61,  102,  101,
-       46,  100,   98,   96,   93,   92,   91,    9,   90,   89,
-       87,   85,   84,   83,   46,  107,  107,  108,  108,   81,
-
-       79,   78,   77,   76,   75,   74,   73,   72,   71,   70,
-       69,   68,   67,   66,   63,   62,   58,   48,   47,   37,
-       36,   35,   34,   33,   32,   31,   26,   25,   24,   23,
-       11,    7,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106,  106,  106,  106,
-      106,  106,  106,  106,  106,  106,  106
+        5,    6,    5,   47,    6,   22,    6,   22,   22,   51,
+       51,   52,   58,   52,   52,   61,   63,   67,   67,   66,
+       58,   61,  116,    9,   63,   66,  110,   63,  109,  108,
+       47,  106,  104,  102,  101,   98,   97,    9,   96,   95,
+       94,   93,   91,   89,   47,  114,  114,  115,  115,   88,
+
+       87,   85,   83,   82,   81,   80,   79,   78,   77,   76,
+       75,   74,   73,   72,   71,   70,   69,   68,   65,   64,
+       60,   59,   49,   48,   38,   37,   36,   35,   34,   33,
+       32,   31,   26,   25,   24,   23,   11,    7,  113,  113,
+      113,  113,  113,  113,  113,  113,  113,  113,  113,  113,
+      113,  113,  113,  113,  113,  113,  113,  113,  113,  113,
+      113,  113,  113,  113,  113,  113,  113,  113,  113,  113,
+      113,  113,  113,  113,  113,  113,  113,  113,  113,  113,
+      113,  113,  113
     } ;
 
 static yy_state_type yy_last_accepting_state;
@@ -513,9 +518,9 @@ char *yytext;
 #line 2 "gwarf_lex.l"
     #include<stdio.h>
     #include"y.tab.h"
-#line 516 "lex.yy.c"
+#line 521 "lex.yy.c"
 
-#line 518 "lex.yy.c"
+#line 523 "lex.yy.c"
 
 #define INITIAL 0
 #define COMMENT 1
@@ -736,7 +741,7 @@ YY_DECL
 	{
 #line 6 "gwarf_lex.l"
 
-#line 739 "lex.yy.c"
+#line 744 "lex.yy.c"
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
@@ -763,13 +768,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 >= 107 )
+				if ( yy_current_state >= 114 )
 					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] != 133 );
+		while ( yy_base[yy_current_state] != 139 );
 
 yy_find_action:
 		yy_act = yy_accept[yy_current_state];
@@ -948,13 +953,13 @@ YY_RULE_SETUP
 	YY_BREAK
 case 31:
 YY_RULE_SETUP
-#line 41 "gwarf_lex.l"
-{BEGIN COMMENT;}
+#line 40 "gwarf_lex.l"
+{return DEFAULT;}
 	YY_BREAK
 case 32:
 YY_RULE_SETUP
 #line 42 "gwarf_lex.l"
-{BEGIN STRING_TEXT;}
+{BEGIN COMMENT;}
 	YY_BREAK
 case 33:
 YY_RULE_SETUP
@@ -964,31 +969,31 @@ YY_RULE_SETUP
 case 34:
 YY_RULE_SETUP
 #line 44 "gwarf_lex.l"
+{BEGIN STRING_TEXT;}
+	YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 45 "gwarf_lex.l"
 {
     yylval.double_value = atof(yytext);
     return NUMBER;
     }
 	YY_BREAK
-case 35:
+case 36:
 YY_RULE_SETUP
-#line 48 "gwarf_lex.l"
+#line 49 "gwarf_lex.l"
 {
     yylval.string_value = yytext;
     return VAR;
     }
 	YY_BREAK
-case 36:
-YY_RULE_SETUP
-#line 53 "gwarf_lex.l"
-;
-	YY_BREAK
 case 37:
-/* rule 37 can match eol */
 YY_RULE_SETUP
 #line 54 "gwarf_lex.l"
-{return STOP;}
+;
 	YY_BREAK
 case 38:
+/* rule 38 can match eol */
 YY_RULE_SETUP
 #line 55 "gwarf_lex.l"
 {return STOP;}
@@ -996,15 +1001,15 @@ YY_RULE_SETUP
 case 39:
 YY_RULE_SETUP
 #line 56 "gwarf_lex.l"
-{printf("text = [%s];\n", yytext);}
+{return STOP;}
 	YY_BREAK
 case 40:
-/* rule 40 can match eol */
 YY_RULE_SETUP
-#line 58 "gwarf_lex.l"
-{BEGIN INITIAL;}
+#line 57 "gwarf_lex.l"
+{printf("text = [%s];\n", yytext);}
 	YY_BREAK
 case 41:
+/* rule 41 can match eol */
 YY_RULE_SETUP
 #line 59 "gwarf_lex.l"
 {BEGIN INITIAL;}
@@ -1012,12 +1017,12 @@ YY_RULE_SETUP
 case 42:
 YY_RULE_SETUP
 #line 60 "gwarf_lex.l"
-;
+{BEGIN INITIAL;}
 	YY_BREAK
 case 43:
 YY_RULE_SETUP
-#line 62 "gwarf_lex.l"
-{BEGIN INITIAL;}
+#line 61 "gwarf_lex.l"
+;
 	YY_BREAK
 case 44:
 YY_RULE_SETUP
@@ -1025,28 +1030,33 @@ YY_RULE_SETUP
 {BEGIN INITIAL;}
 	YY_BREAK
 case 45:
-/* rule 45 can match eol */
 YY_RULE_SETUP
 #line 64 "gwarf_lex.l"
+{BEGIN INITIAL;}
+	YY_BREAK
+case 46:
+/* rule 46 can match eol */
+YY_RULE_SETUP
+#line 65 "gwarf_lex.l"
 {
     yylval.string_value = yytext;
     return STRING;
     }
 	YY_BREAK
-case 46:
+case 47:
 YY_RULE_SETUP
-#line 68 "gwarf_lex.l"
+#line 69 "gwarf_lex.l"
 {
     yylval.string_value = yytext;
     return STRING;
     }
 	YY_BREAK
-case 47:
+case 48:
 YY_RULE_SETUP
-#line 72 "gwarf_lex.l"
+#line 73 "gwarf_lex.l"
 ECHO;
 	YY_BREAK
-#line 1049 "lex.yy.c"
+#line 1059 "lex.yy.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(COMMENT):
 case YY_STATE_EOF(STRING_TEXT):
@@ -1345,7 +1355,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 >= 107 )
+			if ( yy_current_state >= 114 )
 				yy_c = yy_meta[yy_c];
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -1373,11 +1383,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 >= 107 )
+		if ( yy_current_state >= 114 )
 			yy_c = yy_meta[yy_c];
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
-	yy_is_jam = (yy_current_state == 106);
+	yy_is_jam = (yy_current_state == 113);
 
 		return yy_is_jam ? 0 : yy_current_state;
 }
@@ -2053,7 +2063,7 @@ void yyfree (void * ptr )
 
 #define YYTABLES_NAME "yytables"
 
-#line 72 "gwarf_lex.l"
+#line 73 "gwarf_lex.l"
 
 int yywrap(void) {
     return 1;

+ 254 - 225
paser/y.tab.c

@@ -154,7 +154,8 @@ extern int yydebug;
     REGO = 288,
     REWENT = 289,
     RI = 290,
-    LI = 291
+    LI = 291,
+    DEFAULT = 292
   };
 #endif
 /* Tokens.  */
@@ -192,6 +193,7 @@ extern int yydebug;
 #define REWENT 289
 #define RI 290
 #define LI 291
+#define DEFAULT 292
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@@ -205,7 +207,7 @@ union YYSTYPE
     struct statement *statement_value;
     struct if_list *if_list_base;
 
-#line 209 "y.tab.c"
+#line 211 "y.tab.c"
 
 };
 typedef union YYSTYPE YYSTYPE;
@@ -522,21 +524,21 @@ union yyalloc
 #endif /* !YYCOPY_NEEDED */
 
 /* YYFINAL -- State number of the termination state.  */
-#define YYFINAL  50
+#define YYFINAL  53
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   147
+#define YYLAST   127
 
 /* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  37
+#define YYNTOKENS  38
 /* YYNNTS -- Number of nonterminals.  */
-#define YYNNTS  30
+#define YYNNTS  31
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  65
+#define YYNRULES  67
 /* YYNSTATES -- Number of states.  */
-#define YYNSTATES  109
+#define YYNSTATES  114
 
 #define YYUNDEFTOK  2
-#define YYMAXUTOK   291
+#define YYMAXUTOK   292
 
 
 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
@@ -577,7 +579,7 @@ static const yytype_int8 yytranslate[] =
        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
       25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
-      35,    36
+      35,    36,    37
 };
 
 #if YYDEBUG
@@ -585,12 +587,12 @@ static const yytype_int8 yytranslate[] =
 static const yytype_int16 yyrline[] =
 {
        0,    23,    23,    27,    34,    41,    51,    55,    59,    63,
-      67,    71,    75,    79,    83,    87,    91,    97,   106,   110,
-     122,   123,   132,   141,   150,   159,   168,   180,   181,   190,
-     202,   203,   212,   224,   225,   226,   233,   244,   245,   253,
-     265,   270,   279,   285,   294,   305,   312,   324,   328,   329,
-     337,   347,   348,   356,   366,   367,   375,   385,   386,   394,
-     404,   405,   413,   423,   424,   431
+      67,    71,    75,    79,    83,    87,    91,    97,   103,   110,
+     114,   126,   127,   136,   145,   154,   163,   172,   184,   185,
+     194,   206,   207,   216,   228,   229,   230,   237,   248,   263,
+     264,   272,   285,   290,   299,   305,   314,   325,   332,   344,
+     348,   349,   357,   367,   368,   376,   386,   387,   395,   405,
+     406,   414,   424,   425,   433,   443,   444,   451
 };
 #endif
 
@@ -603,13 +605,14 @@ static const char *const yytname[] =
   "DIV", "MUL", "EQ", "LESS", "MORE", "RB", "LB", "RP", "LP", "WHILE",
   "STOP", "POW", "EQUAL", "MOREEQ", "LESSEQ", "NOTEQ", "BREAK", "IF",
   "ELSE", "ELIF", "BROKEN", "CONTINUE", "CONTINUED", "RESTART",
-  "RESTARTED", "REGO", "REWENT", "RI", "LI", "$accept", "command_block",
-  "command_list", "command", "top_exp", "third_number", "second_number",
-  "first_number", "element", "base_number", "base_var_", "base_var_token",
-  "if_block", "elif_exp", "if_exp", "while_block", "while_exp", "block",
-  "restarted_exp", "restarted_token", "restart_exp", "restart_token",
-  "continued_exp", "continued_token", "continue_exp", "continue_token",
-  "break_exp", "break_token", "broken_exp", "broken_token", YY_NULLPTR
+  "RESTARTED", "REGO", "REWENT", "RI", "LI", "DEFAULT", "$accept",
+  "command_block", "command_list", "command", "top_exp", "third_number",
+  "second_number", "first_number", "element", "base_number",
+  "default_token", "base_var_", "base_var_token", "if_block", "elif_exp",
+  "if_exp", "while_block", "while_exp", "block", "restarted_exp",
+  "restarted_token", "restart_exp", "restart_token", "continued_exp",
+  "continued_token", "continue_exp", "continue_token", "break_exp",
+  "break_token", "broken_exp", "broken_token", YY_NULLPTR
 };
 #endif
 
@@ -621,11 +624,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,   279,   280,   281,   282,   283,   284,
-     285,   286,   287,   288,   289,   290,   291
+     285,   286,   287,   288,   289,   290,   291,   292
 };
 # endif
 
-#define YYPACT_NINF (-28)
+#define YYPACT_NINF (-48)
 
 #define yypact_value_is_default(Yyn) \
   ((Yyn) == YYPACT_NINF)
@@ -639,17 +642,18 @@ static const yytype_int16 yytoknum[] =
      STATE-NUM.  */
 static const yytype_int8 yypact[] =
 {
-     111,   -28,   -28,     4,    -4,   -28,   -28,    -1,   -28,   -28,
-     -28,   -28,   -28,     3,     7,     4,    16,   111,   -28,     9,
-      27,     5,    11,   -28,   -28,    13,   -28,   -12,    15,    17,
-      15,    18,     4,    19,     4,    23,     4,    33,     4,    36,
-       4,    43,     4,    50,     4,     4,   -28,   -28,    -6,   -28,
-     -28,   -28,    17,   -28,     4,     4,     4,     4,     4,     4,
-       4,     4,     4,     4,     4,   -28,   -28,    51,    15,   111,
-     -28,   -28,   -28,   -28,   -28,   -28,   -28,   -28,   -28,   -28,
-     -28,   -28,   -28,   -28,   -28,   -28,    53,    54,    63,     5,
-       5,     5,     5,     5,     5,    11,    11,   -28,   -28,   -28,
-       4,   -28,    79,   -28,   -28,   -28,    57,   -28,   -28
+      84,   -48,   -48,     6,    -7,   -48,   -48,    -4,   -48,   -48,
+     -48,   -48,   -48,    12,    14,     6,    21,    19,    84,   -48,
+      16,     1,     8,    30,   -48,   -48,    22,    31,   -48,    10,
+      34,    35,    34,    36,     6,    37,     6,    40,     6,    41,
+       6,    44,     6,    47,     6,    39,     6,     6,   -48,   -48,
+      32,   -48,     6,   -48,   -48,    35,   -48,     6,     6,     6,
+       6,     6,     6,     6,     6,     6,     6,   -48,     6,   -48,
+     -48,    55,    34,    84,   -48,   -48,   -48,   -48,   -48,   -48,
+     -48,   -48,   -48,   -48,   -48,   -48,   -48,   -48,   -48,   -48,
+      59,    71,    21,   -48,     8,     8,     8,     8,     8,     8,
+      30,    30,   -48,   -48,   -48,     6,   -48,    46,   -48,   -48,
+     -48,    72,   -48,   -48
 };
 
   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -657,33 +661,36 @@ static const yytype_int8 yypact[] =
      means the default is an error.  */
 static const yytype_int8 yydefact[] =
 {
-       0,    36,    39,     0,     0,     6,    62,     0,    65,    59,
-      56,    53,    50,     0,     0,     0,     0,     2,     3,     0,
-      18,    20,    27,    30,    33,    34,    37,     0,     0,     5,
-       0,     0,    48,     0,    51,     0,    54,     0,    57,     0,
-      60,     0,    63,     0,     0,     0,    16,    17,     0,    34,
-       1,     4,     0,     7,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     9,    43,     0,     0,     0,
-      40,     8,    45,    15,    49,    14,    52,    13,    55,    12,
-      58,    10,    61,    11,    64,    35,     0,     0,     0,    23,
-      22,    21,    24,    25,    26,    28,    29,    32,    31,    19,
-       0,    41,     0,    46,    44,    38,     0,    47,    42
+       0,    37,    41,     0,     0,     6,    64,     0,    67,    61,
+      58,    55,    52,     0,     0,     0,     0,     0,     2,     3,
+       0,    19,    21,    28,    31,    34,     0,    35,    39,     0,
+       0,     5,     0,     0,    50,     0,    53,     0,    56,     0,
+      59,     0,    62,     0,    65,     0,     0,     0,    16,    17,
+       0,    35,     0,     1,     4,     0,     7,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,    18,     0,     9,
+      45,     0,     0,     0,    42,     8,    47,    15,    51,    14,
+      54,    13,    57,    12,    60,    10,    63,    11,    66,    36,
+       0,     0,     0,    38,    24,    23,    22,    25,    26,    27,
+      29,    30,    33,    32,    20,     0,    43,     0,    48,    46,
+      40,     0,    49,    44
 };
 
   /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int8 yypgoto[] =
 {
-     -28,   -28,     2,   -15,    -2,   -28,     1,   -27,   -10,   -28,
-       0,   -16,   -28,   -28,   -28,   -13,   -28,   -22,   -28,   -28,
-     -28,   -28,   -28,   -28,   -28,   -28,   -28,   -28,   -28,   -28
+     -48,   -48,    13,   -16,    -2,   -48,    65,   -47,    -9,   -48,
+     -48,     0,   -11,   -48,   -48,   -48,   -14,   -48,   -24,   -48,
+     -48,   -48,   -48,   -48,   -48,   -48,   -48,   -48,   -48,   -48,
+     -48
 };
 
   /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int8 yydefgoto[] =
 {
-      -1,    16,    17,    18,    19,    20,    21,    22,    23,    24,
-      49,    26,    27,    68,    28,    29,    30,    70,    31,    32,
-      33,    34,    35,    36,    37,    38,    39,    40,    41,    42
+      -1,    17,    18,    19,    20,    21,    22,    23,    24,    25,
+      26,    51,    28,    29,    72,    30,    31,    32,    74,    33,
+      34,    35,    36,    37,    38,    39,    40,    41,    42,    43,
+      44
 };
 
   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
@@ -691,40 +698,36 @@ static const yytype_int8 yydefgoto[] =
      number is the opposite.  If YYTABLE_NINF, syntax error.  */
 static const yytype_int8 yytable[] =
 {
-      25,    43,    51,    25,    52,    48,    65,     1,    72,     2,
-      44,    60,    61,    45,    66,    67,    50,    25,     3,    62,
-      63,    46,    74,    64,    76,    47,    78,    53,    80,    88,
-      82,    69,    84,    95,    96,    71,    73,    75,    54,    55,
-      15,    77,    86,    87,    25,    25,   101,    56,    57,    58,
-      59,    79,    97,    98,    81,    89,    90,    91,    92,    93,
-      94,    83,    99,    85,    25,   100,   103,   104,     2,    25,
-     108,   102,   105,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     1,     0,     2,     0,     0,    51,     0,    52,
-       0,     0,     0,     3,   107,     0,     4,     5,   106,     0,
-      25,     0,    25,     6,     7,     0,     0,     8,     9,    10,
-      11,    12,    13,    14,     1,    15,     2,     0,     0,     0,
-       0,     0,     0,     0,     0,     3,     0,     0,     4,     5,
-       0,     0,     0,     0,     0,     6,     7,     0,     0,     8,
-       9,    10,    11,    12,    13,    14,     0,    15
+      27,    45,    54,    27,    55,    52,    50,    46,    76,     1,
+      47,     2,    57,    58,    63,    64,   100,   101,    27,    53,
+       3,    59,    60,    61,    62,    78,     2,    80,    69,    82,
+      48,    84,    49,    86,    56,    88,    70,    71,    65,    66,
+      67,    68,    15,    93,    90,    91,    27,    27,   106,     1,
+      73,     2,    89,    75,    77,    79,   102,   103,    81,    83,
+       3,   112,    85,     4,     5,    87,   104,    92,    27,   105,
+       6,     7,   108,    27,     8,     9,    10,    11,    12,    13,
+      14,   110,    15,    16,   109,   113,   107,     1,     0,     2,
+       0,    54,     0,    55,     0,     0,     0,     0,     3,     0,
+       0,     4,     5,   111,     0,    27,     0,    27,     6,     7,
+       0,     0,     8,     9,    10,    11,    12,    13,    14,     0,
+      15,    16,    94,    95,    96,    97,    98,    99
 };
 
 static const yytype_int8 yycheck[] =
 {
-       0,     3,    17,     3,    17,    15,    18,     3,    30,     5,
-      14,     6,     7,    14,    26,    27,     0,    17,    14,     8,
-       9,    18,    32,    10,    34,    18,    36,    18,    38,    35,
-      40,    16,    42,    60,    61,    18,    18,    18,    11,    12,
-      36,    18,    44,    45,    44,    45,    68,    20,    21,    22,
-      23,    18,    62,    63,    18,    54,    55,    56,    57,    58,
-      59,    18,    64,    13,    64,    14,    13,    13,     5,    69,
-      13,    69,    88,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,     3,    -1,     5,    -1,    -1,   102,    -1,   102,
-      -1,    -1,    -1,    14,    15,    -1,    17,    18,   100,    -1,
-     100,    -1,   102,    24,    25,    -1,    -1,    28,    29,    30,
-      31,    32,    33,    34,     3,    36,     5,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    14,    -1,    -1,    17,    18,
-      -1,    -1,    -1,    -1,    -1,    24,    25,    -1,    -1,    28,
-      29,    30,    31,    32,    33,    34,    -1,    36
+       0,     3,    18,     3,    18,    16,    15,    14,    32,     3,
+      14,     5,    11,    12,     6,     7,    63,    64,    18,     0,
+      14,    20,    21,    22,    23,    34,     5,    36,    18,    38,
+      18,    40,    18,    42,    18,    44,    26,    27,     8,     9,
+      18,    10,    36,    52,    46,    47,    46,    47,    72,     3,
+      16,     5,    13,    18,    18,    18,    65,    66,    18,    18,
+      14,    15,    18,    17,    18,    18,    68,    35,    68,    14,
+      24,    25,    13,    73,    28,    29,    30,    31,    32,    33,
+      34,    92,    36,    37,    13,    13,    73,     3,    -1,     5,
+      -1,   107,    -1,   107,    -1,    -1,    -1,    -1,    14,    -1,
+      -1,    17,    18,   105,    -1,   105,    -1,   107,    24,    25,
+      -1,    -1,    28,    29,    30,    31,    32,    33,    34,    -1,
+      36,    37,    57,    58,    59,    60,    61,    62
 };
 
   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -732,40 +735,41 @@ static const yytype_int8 yycheck[] =
 static const yytype_int8 yystos[] =
 {
        0,     3,     5,    14,    17,    18,    24,    25,    28,    29,
-      30,    31,    32,    33,    34,    36,    38,    39,    40,    41,
-      42,    43,    44,    45,    46,    47,    48,    49,    51,    52,
-      53,    55,    56,    57,    58,    59,    60,    61,    62,    63,
-      64,    65,    66,    41,    14,    14,    18,    18,    45,    47,
-       0,    40,    52,    18,    11,    12,    20,    21,    22,    23,
-       6,     7,     8,     9,    10,    18,    26,    27,    50,    16,
-      54,    18,    54,    18,    45,    18,    45,    18,    45,    18,
-      45,    18,    45,    18,    45,    13,    41,    41,    35,    43,
-      43,    43,    43,    43,    43,    44,    44,    45,    45,    41,
-      14,    54,    39,    13,    13,    48,    41,    15,    13
+      30,    31,    32,    33,    34,    36,    37,    39,    40,    41,
+      42,    43,    44,    45,    46,    47,    48,    49,    50,    51,
+      53,    54,    55,    57,    58,    59,    60,    61,    62,    63,
+      64,    65,    66,    67,    68,    42,    14,    14,    18,    18,
+      46,    49,    50,     0,    41,    54,    18,    11,    12,    20,
+      21,    22,    23,     6,     7,     8,     9,    18,    10,    18,
+      26,    27,    52,    16,    56,    18,    56,    18,    46,    18,
+      46,    18,    46,    18,    46,    18,    46,    18,    46,    13,
+      42,    42,    35,    46,    44,    44,    44,    44,    44,    44,
+      45,    45,    46,    46,    42,    14,    56,    40,    13,    13,
+      50,    42,    15,    13
 };
 
   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 static const yytype_int8 yyr1[] =
 {
-       0,    37,    38,    39,    39,    39,    40,    40,    40,    40,
-      40,    40,    40,    40,    40,    40,    40,    40,    41,    41,
-      42,    42,    42,    42,    42,    42,    42,    43,    43,    43,
-      44,    44,    44,    45,    45,    45,    46,    47,    47,    48,
-      49,    49,    50,    50,    51,    52,    53,    54,    55,    55,
-      56,    57,    57,    58,    59,    59,    60,    61,    61,    62,
-      63,    63,    64,    65,    65,    66
+       0,    38,    39,    40,    40,    40,    41,    41,    41,    41,
+      41,    41,    41,    41,    41,    41,    41,    41,    41,    42,
+      42,    43,    43,    43,    43,    43,    43,    43,    44,    44,
+      44,    45,    45,    45,    46,    46,    46,    47,    48,    49,
+      49,    50,    51,    51,    52,    52,    53,    54,    55,    56,
+      57,    57,    58,    59,    59,    60,    61,    61,    62,    63,
+      63,    64,    65,    65,    66,    67,    67,    68
 };
 
   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
 static const yytype_int8 yyr2[] =
 {
        0,     2,     1,     1,     2,     1,     1,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     1,     3,
-       1,     3,     3,     3,     3,     3,     3,     1,     3,     3,
-       1,     3,     3,     1,     1,     3,     1,     1,     4,     1,
-       2,     3,     4,     1,     4,     2,     4,     3,     1,     2,
-       1,     1,     2,     1,     1,     2,     1,     1,     2,     1,
-       1,     2,     1,     1,     2,     1
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     1,
+       3,     1,     3,     3,     3,     3,     3,     3,     1,     3,
+       3,     1,     3,     3,     1,     1,     3,     1,     3,     1,
+       4,     1,     2,     3,     4,     1,     4,     2,     4,     3,
+       1,     2,     1,     1,     2,     1,     1,     2,     1,     1,
+       2,     1,     1,     2,     1,     1,     2,     1
 };
 
 
@@ -1468,7 +1472,7 @@ yyreduce:
             append_statement(tmp, (yyvsp[0].statement_value));
         }
     }
-#line 1472 "y.tab.c"
+#line 1476 "y.tab.c"
     break;
 
   case 4:
@@ -1479,7 +1483,7 @@ yyreduce:
             append_statement(tmp, (yyvsp[0].statement_value));
         }
     }
-#line 1483 "y.tab.c"
+#line 1487 "y.tab.c"
     break;
 
   case 5:
@@ -1490,7 +1494,7 @@ yyreduce:
             append_statement(tmp, (yyvsp[0].statement_value));
         }
     }
-#line 1494 "y.tab.c"
+#line 1498 "y.tab.c"
     break;
 
   case 6:
@@ -1498,7 +1502,7 @@ yyreduce:
     {
         (yyval.statement_value) = NULL;
     }
-#line 1502 "y.tab.c"
+#line 1506 "y.tab.c"
     break;
 
   case 7:
@@ -1506,7 +1510,7 @@ yyreduce:
     {
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1510 "y.tab.c"
+#line 1514 "y.tab.c"
     break;
 
   case 8:
@@ -1514,7 +1518,7 @@ yyreduce:
     {   
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1518 "y.tab.c"
+#line 1522 "y.tab.c"
     break;
 
   case 9:
@@ -1522,7 +1526,7 @@ yyreduce:
     {
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1526 "y.tab.c"
+#line 1530 "y.tab.c"
     break;
 
   case 10:
@@ -1530,7 +1534,7 @@ yyreduce:
     {
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1534 "y.tab.c"
+#line 1538 "y.tab.c"
     break;
 
   case 11:
@@ -1538,7 +1542,7 @@ yyreduce:
     {
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1542 "y.tab.c"
+#line 1546 "y.tab.c"
     break;
 
   case 12:
@@ -1546,7 +1550,7 @@ yyreduce:
     {
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1550 "y.tab.c"
+#line 1554 "y.tab.c"
     break;
 
   case 13:
@@ -1554,7 +1558,7 @@ yyreduce:
     {
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1558 "y.tab.c"
+#line 1562 "y.tab.c"
     break;
 
   case 14:
@@ -1562,7 +1566,7 @@ yyreduce:
     {
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1566 "y.tab.c"
+#line 1570 "y.tab.c"
     break;
 
   case 15:
@@ -1570,7 +1574,7 @@ yyreduce:
     {
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1574 "y.tab.c"
+#line 1578 "y.tab.c"
     break;
 
   case 16:
@@ -1580,7 +1584,7 @@ yyreduce:
         code_tmp->type = rego;
         (yyval.statement_value) = code_tmp;
     }
-#line 1584 "y.tab.c"
+#line 1588 "y.tab.c"
     break;
 
   case 17:
@@ -1590,19 +1594,27 @@ yyreduce:
         code_tmp->type = rewent;
         (yyval.statement_value) = code_tmp;
     }
-#line 1594 "y.tab.c"
+#line 1598 "y.tab.c"
     break;
 
   case 18:
-#line 107 "gwarf_yacc.y"
+#line 104 "gwarf_yacc.y"
     {
-        (yyval.statement_value) = (yyvsp[0].statement_value);
+        (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1602 "y.tab.c"
+#line 1606 "y.tab.c"
     break;
 
   case 19:
 #line 111 "gwarf_yacc.y"
+    {
+        (yyval.statement_value) = (yyvsp[0].statement_value);
+    }
+#line 1614 "y.tab.c"
+    break;
+
+  case 20:
+#line 115 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1611,11 +1623,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1615 "y.tab.c"
+#line 1627 "y.tab.c"
     break;
 
-  case 21:
-#line 124 "gwarf_yacc.y"
+  case 22:
+#line 128 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1624,11 +1636,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1628 "y.tab.c"
+#line 1640 "y.tab.c"
     break;
 
-  case 22:
-#line 133 "gwarf_yacc.y"
+  case 23:
+#line 137 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1637,11 +1649,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1641 "y.tab.c"
+#line 1653 "y.tab.c"
     break;
 
-  case 23:
-#line 142 "gwarf_yacc.y"
+  case 24:
+#line 146 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1650,11 +1662,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1654 "y.tab.c"
+#line 1666 "y.tab.c"
     break;
 
-  case 24:
-#line 151 "gwarf_yacc.y"
+  case 25:
+#line 155 "gwarf_yacc.y"
         {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1663,11 +1675,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1667 "y.tab.c"
+#line 1679 "y.tab.c"
     break;
 
-  case 25:
-#line 160 "gwarf_yacc.y"
+  case 26:
+#line 164 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1676,11 +1688,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1680 "y.tab.c"
+#line 1692 "y.tab.c"
     break;
 
-  case 26:
-#line 169 "gwarf_yacc.y"
+  case 27:
+#line 173 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1689,11 +1701,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1693 "y.tab.c"
+#line 1705 "y.tab.c"
     break;
 
-  case 28:
-#line 182 "gwarf_yacc.y"
+  case 29:
+#line 186 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1702,11 +1714,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1706 "y.tab.c"
+#line 1718 "y.tab.c"
     break;
 
-  case 29:
-#line 191 "gwarf_yacc.y"
+  case 30:
+#line 195 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1715,11 +1727,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1719 "y.tab.c"
+#line 1731 "y.tab.c"
     break;
 
-  case 31:
-#line 204 "gwarf_yacc.y"
+  case 32:
+#line 208 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1728,11 +1740,11 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1732 "y.tab.c"
+#line 1744 "y.tab.c"
     break;
 
-  case 32:
-#line 213 "gwarf_yacc.y"
+  case 33:
+#line 217 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = operation;
@@ -1741,19 +1753,19 @@ yyreduce:
         code_tmp->code.operation.right_exp = (yyvsp[0].statement_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1745 "y.tab.c"
+#line 1757 "y.tab.c"
     break;
 
-  case 35:
-#line 227 "gwarf_yacc.y"
+  case 36:
+#line 231 "gwarf_yacc.y"
     {
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1753 "y.tab.c"
+#line 1765 "y.tab.c"
     break;
 
-  case 36:
-#line 234 "gwarf_yacc.y"
+  case 37:
+#line 238 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = base_value;
@@ -1761,72 +1773,89 @@ yyreduce:
         code_tmp->code.base_value.value.value.double_value = (yyvsp[0].double_value);
         (yyval.statement_value) = code_tmp;
     }
-#line 1765 "y.tab.c"
+#line 1777 "y.tab.c"
     break;
 
   case 38:
-#line 246 "gwarf_yacc.y"
+#line 249 "gwarf_yacc.y"
+    {
+        statement *code_tmp =  make_statement();
+        code_tmp->type = set_default;
+        code_tmp->code.set_default.times = (yyvsp[0].statement_value);
+        code_tmp->code.set_default.name = malloc(sizeof((yyvsp[-1].statement_value)->code.base_var.var_name));
+        char *name_tmp = code_tmp->code.set_default.name;
+        strcpy(name_tmp, (yyvsp[-1].statement_value)->code.base_var.var_name);
+        free((yyvsp[-1].statement_value)->code.base_var.var_name);
+        free((yyvsp[-1].statement_value));
+        (yyval.statement_value) = code_tmp;
+    }
+#line 1793 "y.tab.c"
+    break;
+
+  case 40:
+#line 265 "gwarf_yacc.y"
     {
         (yyvsp[0].statement_value)->code.base_var.from = (yyvsp[-2].statement_value);
         (yyval.statement_value) = (yyvsp[0].statement_value);
     }
-#line 1774 "y.tab.c"
+#line 1802 "y.tab.c"
     break;
 
-  case 39:
-#line 254 "gwarf_yacc.y"
+  case 41:
+#line 273 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->code.base_var.var_name = malloc(sizeof((yyvsp[0].string_value)));
         char *name_tmp = code_tmp->code.base_var.var_name;
         code_tmp->type = base_var;
+        code_tmp->code.base_var.from = NULL;
         strcpy(name_tmp, (yyvsp[0].string_value));
         (yyval.statement_value) = code_tmp;
     }
-#line 1787 "y.tab.c"
+#line 1816 "y.tab.c"
     break;
 
-  case 40:
-#line 266 "gwarf_yacc.y"
+  case 42:
+#line 286 "gwarf_yacc.y"
     {
         statement_base = free_statement_list(statement_base);  // new statement_base (FILO)
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1796 "y.tab.c"
+#line 1825 "y.tab.c"
     break;
 
-  case 41:
-#line 271 "gwarf_yacc.y"
+  case 43:
+#line 291 "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 1806 "y.tab.c"
+#line 1835 "y.tab.c"
     break;
 
-  case 42:
-#line 280 "gwarf_yacc.y"
+  case 44:
+#line 300 "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 1816 "y.tab.c"
+#line 1845 "y.tab.c"
     break;
 
-  case 43:
-#line 286 "gwarf_yacc.y"
+  case 45:
+#line 306 "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 1826 "y.tab.c"
+#line 1855 "y.tab.c"
     break;
 
-  case 44:
-#line 295 "gwarf_yacc.y"
+  case 46:
+#line 315 "gwarf_yacc.y"
     {
         statement *if_tmp =  make_statement(), *done_tmp =  make_statement();
         if_tmp->type = if_branch;
@@ -1834,19 +1863,19 @@ yyreduce:
         statement_base = append_statement_list(done_tmp, statement_base);  // new statement_base (FILO)
         (yyval.statement_value) = if_tmp;
     }
-#line 1838 "y.tab.c"
+#line 1867 "y.tab.c"
     break;
 
-  case 45:
-#line 306 "gwarf_yacc.y"
+  case 47:
+#line 326 "gwarf_yacc.y"
     {
         statement_base = free_statement_list(statement_base);  // new statement_base (FILO)
     }
-#line 1846 "y.tab.c"
+#line 1875 "y.tab.c"
     break;
 
-  case 46:
-#line 313 "gwarf_yacc.y"
+  case 48:
+#line 333 "gwarf_yacc.y"
     {
         statement *while_tmp =  make_statement();
         while_tmp->type = while_cycle;
@@ -1855,131 +1884,131 @@ yyreduce:
         statement_base = append_statement_list(while_tmp->code.while_cycle.done, statement_base);  // new statement_base (FILO)
         (yyval.statement_value) = while_tmp;
     }
-#line 1859 "y.tab.c"
+#line 1888 "y.tab.c"
     break;
 
-  case 49:
-#line 330 "gwarf_yacc.y"
+  case 51:
+#line 350 "gwarf_yacc.y"
     {
         (yyvsp[-1].statement_value)->code.restarted.times = (yyvsp[0].statement_value);
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1868 "y.tab.c"
+#line 1897 "y.tab.c"
     break;
 
-  case 50:
-#line 338 "gwarf_yacc.y"
+  case 52:
+#line 358 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = restarted;
         code_tmp->code.restarted.times = NULL;
         (yyval.statement_value) = code_tmp;
     }
-#line 1879 "y.tab.c"
+#line 1908 "y.tab.c"
     break;
 
-  case 52:
-#line 349 "gwarf_yacc.y"
+  case 54:
+#line 369 "gwarf_yacc.y"
     {
         (yyvsp[-1].statement_value)->code.restart.times = (yyvsp[0].statement_value);
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1888 "y.tab.c"
+#line 1917 "y.tab.c"
     break;
 
-  case 53:
-#line 357 "gwarf_yacc.y"
+  case 55:
+#line 377 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = restart;
         code_tmp->code.restart.times = NULL;
         (yyval.statement_value) = code_tmp;
     }
-#line 1899 "y.tab.c"
+#line 1928 "y.tab.c"
     break;
 
-  case 55:
-#line 368 "gwarf_yacc.y"
+  case 57:
+#line 388 "gwarf_yacc.y"
     {
         (yyvsp[-1].statement_value)->code.continued.times = (yyvsp[0].statement_value);
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1908 "y.tab.c"
+#line 1937 "y.tab.c"
     break;
 
-  case 56:
-#line 376 "gwarf_yacc.y"
+  case 58:
+#line 396 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = continued;
         code_tmp->code.continued.times = NULL;
         (yyval.statement_value) = code_tmp;
     }
-#line 1919 "y.tab.c"
+#line 1948 "y.tab.c"
     break;
 
-  case 58:
-#line 387 "gwarf_yacc.y"
+  case 60:
+#line 407 "gwarf_yacc.y"
     {
         (yyvsp[-1].statement_value)->code.continue_cycle.times = (yyvsp[0].statement_value);
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1928 "y.tab.c"
+#line 1957 "y.tab.c"
     break;
 
-  case 59:
-#line 395 "gwarf_yacc.y"
+  case 61:
+#line 415 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = continue_cycle;
         code_tmp->code.continue_cycle.times = NULL;
         (yyval.statement_value) = code_tmp;
     }
-#line 1939 "y.tab.c"
+#line 1968 "y.tab.c"
     break;
 
-  case 61:
-#line 406 "gwarf_yacc.y"
+  case 63:
+#line 426 "gwarf_yacc.y"
     {
         (yyvsp[-1].statement_value)->code.break_cycle.times = (yyvsp[0].statement_value);
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1948 "y.tab.c"
+#line 1977 "y.tab.c"
     break;
 
-  case 62:
-#line 414 "gwarf_yacc.y"
+  case 64:
+#line 434 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = break_cycle;
         code_tmp->code.break_cycle.times = NULL;
         (yyval.statement_value) = code_tmp;
     }
-#line 1959 "y.tab.c"
+#line 1988 "y.tab.c"
     break;
 
-  case 64:
-#line 425 "gwarf_yacc.y"
+  case 66:
+#line 445 "gwarf_yacc.y"
     {
         (yyvsp[-1].statement_value)->code.broken.times = (yyvsp[0].statement_value);
         (yyval.statement_value) = (yyvsp[-1].statement_value);
     }
-#line 1968 "y.tab.c"
+#line 1997 "y.tab.c"
     break;
 
-  case 65:
-#line 432 "gwarf_yacc.y"
+  case 67:
+#line 452 "gwarf_yacc.y"
     {
         statement *code_tmp =  make_statement();
         code_tmp->type = broken;
         code_tmp->code.broken.times = NULL;
         (yyval.statement_value) = code_tmp;
     }
-#line 1979 "y.tab.c"
+#line 2008 "y.tab.c"
     break;
 
 
-#line 1983 "y.tab.c"
+#line 2012 "y.tab.c"
 
       default: break;
     }
@@ -2211,7 +2240,7 @@ yyreturn:
 #endif
   return yyresult;
 }
-#line 440 "gwarf_yacc.y"
+#line 460 "gwarf_yacc.y"
 
 int yyerror(char const *str)
 {

+ 4 - 2
paser/y.tab.h

@@ -82,7 +82,8 @@ extern int yydebug;
     REGO = 288,
     REWENT = 289,
     RI = 290,
-    LI = 291
+    LI = 291,
+    DEFAULT = 292
   };
 #endif
 /* Tokens.  */
@@ -120,6 +121,7 @@ extern int yydebug;
 #define REWENT 289
 #define RI 290
 #define LI 291
+#define DEFAULT 292
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@@ -133,7 +135,7 @@ union YYSTYPE
     struct statement *statement_value;
     struct if_list *if_list_base;
 
-#line 137 "y.tab.h"
+#line 139 "y.tab.h"
 
 };
 typedef union YYSTYPE YYSTYPE;