Răsfoiți Sursa

for循环和if分支

SongZihuan 5 ani în urmă
părinte
comite
a0ce10e8e1
6 a modificat fișierele cu 1047 adăugiri și 187 ștergeri
  1. 581 96
      debug.log
  2. BIN
      gwarf
  3. 5 0
      paser/lexical.c
  4. 304 32
      paser/syntax.c
  5. 17 1
      paser/token.h
  6. 140 58
      status.log

Fișier diff suprimat deoarece este prea mare
+ 581 - 96
debug.log



+ 5 - 0
paser/lexical.c

@@ -84,6 +84,11 @@ int paser(int *index){
         match_text(p, global_paser[WHILE_PASER], "while");
         match_text(p, global_paser[LP_PASER], "{");
         match_text(p, global_paser[RP_PASER], "}");
+        match_text(p, global_paser[IF_PASER], "if");
+        match_text(p, global_paser[ELIF_PASER], "elif");
+        match_text(p, global_paser[ELSE_PASER], "else");
+        match_text(p, global_paser[COMMA_PASER], ";");
+        match_text(p, global_paser[FOR_PASER], "for");
 
         *index = check_list(global_paser);  // 检查解析结果
 

+ 304 - 32
paser/syntax.c

@@ -4,10 +4,15 @@
 
 void factor(int *status, token_node *list);
 void number(int *status, token_node *list);
+void element(int *status, token_node *list);
 void polynomial(int *status, token_node *list);
 void command(int *status, token_node *list);
 void while_(int *status, token_node *list);
+void if_(int *status, token_node *list);
+void for_(int *status, token_node *list);
+void elif_(int *status, token_node *list);
 void block_(int *status, token_node *list);
+void top_exp(int *status, token_node *list);
 void paser_error(char *text);
 
 /*
@@ -15,7 +20,7 @@ command_list : command
              | command_list command
 */
 void command_list(int *status, token_node *list){  // 多项式
-    fprintf(status_log, "[info][grammar]  mode status: polynomial\n", text);
+    fprintf(status_log, "[info][grammar]  mode status: top_exp\n", text);
     token left, right, new_token;
 
     left = pop_node(list);  // 先弹出一个token   检查token的类型:区分是模式1,还是模式2/3
@@ -55,10 +60,10 @@ void command_list(int *status, token_node *list){  // 多项式
 }
 
 /*
-command : polynomial <ENTER>
+command : top_exp <ENTER>
 */
 void command(int *status, token_node *list){  // 多项式
-    fprintf(status_log, "[info][grammar]  mode status: polynomial\n", text);
+    fprintf(status_log, "[info][grammar]  mode status: command\n", text);
     token left, new_token;
 
     left = pop_node(list);  // 先弹出一个token   检查token
@@ -70,6 +75,22 @@ void command(int *status, token_node *list){  // 多项式
         get_stop_token();
         push_statement(statement_base, new_token);
     }
+    if(left.type == IF_PASER){  // 是while类型的数据
+        fprintf(status_log, "[info][grammar]  (command)back one token to (if)\n");
+        back_one_token(list, left);
+        get_base_token(status, list, if_, new_token);
+
+        get_stop_token();
+        push_statement(statement_base, new_token);
+    }
+    if(left.type == FOR_PASER){  // 是while类型的数据
+        fprintf(status_log, "[info][grammar]  (command)back one token to (for)\n");
+        back_one_token(list, left);
+        get_base_token(status, list, for_, new_token);
+
+        get_stop_token();
+        push_statement(statement_base, new_token);
+    }
     else if(left.type == ENTER_PASER){
         fprintf(status_log, "[info][grammar]  (command)back <ENTER>\n");
     }
@@ -79,10 +100,10 @@ void command(int *status, token_node *list){  // 多项式
         goto return_back;
     }
     else{  // 表达式
-        fprintf(status_log, "[info][grammar]  (command)back one token to (polynomial)\n");
+        fprintf(status_log, "[info][grammar]  (command)back one token to (top_exp)\n");
         back_one_token(list, left);
-        get_base_token(status, list, polynomial, new_token);
-        if(new_token.type != NON_polynomial){
+        get_base_token(status, list, top_exp, new_token);
+        if(new_token.type != NON_top_exp){
             back_one_token(list, new_token);  // 往回[不匹配类型]
             return;
         }
@@ -98,7 +119,213 @@ void command(int *status, token_node *list){  // 多项式
 }
 
 /*
-while_ : WHILE LB polynomial RB block  // TODO:把polynomial改为top_exp
+if_ : IF LB top_exp RB block
+*/
+void if_(int *status, token_node *list){
+    fprintf(status_log, "[info][grammar]  mode status: if_\n");
+    token if_t, lb_t, exp_t, rb_t, block_t, next_t, child_t, new_token;
+    if_t = pop_node(list);
+    if(if_t.type == IF_PASER){
+        get_pop_token(status, list, lb_t);
+        if(lb_t.type != LB_PASER){
+            paser_error("Don't get '('");
+        }
+        get_right_token(status,list,top_exp,exp_t);
+        if(exp_t.type != NON_top_exp){  // 不是表达式
+            paser_error("Don't get 'top_exp'");
+        }
+        get_pop_token(status, list, rb_t);
+        if(rb_t.type != RB_PASER){
+            paser_error("Don't get ')'");
+        }
+
+        get_right_token(status,list,block_,block_t);
+        if(block_t.type != NON_block){  // 不是表达式
+            paser_error("Don't get '{'");
+        }
+
+        statement *if_tmp =  make_statement();
+        if_tmp->type = if_branch;
+        if_tmp->code.if_branch.done = make_if(exp_t.data.statement_value, block_t.data.statement_value);
+
+        // 检查else和elseif
+        el_again: 
+        get_pop_token(status,list,next_t);
+        if(next_t.type == ENTER_PASER){  // 忽略Enter
+            goto el_again;
+        }
+        printf("next_t.type = %d\n", next_t.type);
+        if(next_t.type == ELIF_PASER || next_t.type == ELSE_PASER){  // elif
+            back_one_token(list, next_t);
+            get_base_token(status,list,elif_,child_t);
+            if(child_t.type == NON_elif){
+                append_elif(child_t.data.if_list_base, if_tmp->code.if_branch.done);
+                goto el_again;
+            }
+        }
+        else{
+            back_one_token(list, next_t);
+        }
+
+        new_token.type = NON_if;
+        new_token.data_type = statement_value;
+        new_token.data.statement_value = if_tmp;
+        add_node(list, new_token);  // 压入节点[弹出3个压入1个]
+        return;
+    }
+    else{
+        back_one_token(list, if_t);
+        return;
+    }
+}
+
+/*
+elif_ : ELIF LB top_exp RB block
+*/
+void elif_(int *status, token_node *list){
+    fprintf(status_log, "[info][grammar]  mode status: elif_\n");
+    token elif_t, lb_t, exp_t, rb_t, block_t, next_t, new_token;
+    elif_t = pop_node(list);
+    if(elif_t.type == ELIF_PASER){
+        get_pop_token(status, list, lb_t);
+        if(lb_t.type != LB_PASER){
+            paser_error("Don't get '('");
+        }
+        get_right_token(status,list,top_exp,exp_t);
+        if(exp_t.type != NON_top_exp){  // 不是表达式
+            paser_error("Don't get 'top_exp'");
+        }
+        get_pop_token(status, list, rb_t);
+        if(rb_t.type != RB_PASER){
+            paser_error("Don't get ')'");
+        }
+
+        get_right_token(status,list,block_,block_t);
+        if(block_t.type != NON_block){  // 不是表达式
+            paser_error("Don't get '{'");
+        }
+
+        if_list *if_tmp =  make_if(exp_t.data.statement_value, block_t.data.statement_value);
+
+        new_token.type = NON_elif;
+        new_token.data_type = if_list_base;
+        new_token.data.if_list_base = if_tmp;
+        add_node(list, new_token);  // 压入节点[弹出3个压入1个]
+        return;
+    }
+    if(elif_t.type == ELSE_PASER){  // else
+        get_right_token(status,list,block_,block_t);
+        if(block_t.type != NON_block){  // 不是表达式
+            paser_error("Don't get '{'");
+        }
+
+        if_list *if_tmp =  make_if(NULL, block_t.data.statement_value);
+
+        new_token.type = NON_elif;
+        new_token.data_type = if_list_base;
+        new_token.data.if_list_base = if_tmp;
+        add_node(list, new_token);  // 压入节点[弹出3个压入1个]
+        return;
+    }
+    else{
+        back_one_token(list, elif_t);
+        return;
+    }
+}
+
+/*
+for_ : FOR LB top_exp COMMA top_exp COMMA top_exp RB block
+*/
+void for_(int *status, token_node *list){
+    fprintf(status_log, "[info][grammar]  mode status: while_\n");
+    token for_t, exp_1, exp_2, exp_3, block_t, lb_t, rb_t, comma_t,new_token;
+    statement *exp_a, *exp_b, *exp_c;
+    for_t = pop_node(list);
+    if(for_t.type == FOR_PASER){
+        get_pop_token(status, list, lb_t);
+        if(lb_t.type != LB_PASER){
+            paser_error("Don't get '('");
+        }
+
+        get_pop_token(status, list, exp_1);
+        if(exp_1.type == COMMA_PASER){
+            exp_a = NULL;  // exp_1 = NULL;
+        }
+        else{
+            back_one_token(list, exp_1);
+            get_base_token(status,list,top_exp,exp_1);  // 不是使用right token,不需要执行safe_get_token
+            if(exp_1.type != NON_top_exp){  // 不是表达式
+                paser_error("Don't get 'top_exp'");
+            }
+            get_pop_token(status, list, comma_t);
+            if(comma_t.type != COMMA_PASER){
+                paser_error("Don't get ';' in for cycle");
+            }
+            exp_a = exp_1.data.statement_value;
+        }
+
+        get_pop_token(status, list, exp_2);
+        if(exp_2.type == COMMA_PASER){
+            exp_b = NULL;  // exp_1 = NULL;
+        }
+        else{
+            back_one_token(list, exp_2);
+            get_base_token(status,list,top_exp,exp_2);  // 不是使用right token,不需要执行safe_get_token
+            if(exp_2.type != NON_top_exp){  // 不是表达式
+                paser_error("Don't get 'top_exp'");
+            }
+            get_pop_token(status, list, comma_t);
+            if(comma_t.type != COMMA_PASER){
+                paser_error("Don't get ';' in for cycle");
+            }
+            exp_b = exp_2.data.statement_value;
+        }
+
+        get_pop_token(status, list, exp_3);
+        if(exp_3.type == RB_PASER){
+            exp_c = NULL;  // exp_1 = NULL;
+            back_one_token(list, exp_3);
+        }
+        else{
+            back_one_token(list, exp_3);
+            get_base_token(status,list,top_exp,exp_3);  // 不是使用right token,不需要执行safe_get_token
+            if(exp_3.type != NON_top_exp){  // 不是表达式
+                paser_error("Don't get 'top_exp'");
+            }
+            exp_c = exp_3.data.statement_value;
+        }
+
+        get_pop_token(status, list, rb_t);
+        if(rb_t.type != RB_PASER){
+            paser_error("Don't get ')'");
+        }
+
+        get_right_token(status,list,block_,block_t);
+        if(block_t.type != NON_block){  // 不是表达式
+            paser_error("Don't get '{'[s]");
+        }
+
+        statement *for_tmp =  make_statement();
+        for_tmp->type = for_cycle;
+        for_tmp->code.for_cycle.first = exp_a;
+        for_tmp->code.for_cycle.condition = exp_b;
+        for_tmp->code.for_cycle.after = exp_c;
+        for_tmp->code.for_cycle.done = block_t.data.statement_value;
+
+        new_token.type = NON_for;
+        new_token.data_type = statement_value;
+        new_token.data.statement_value = for_tmp;
+        add_node(list, new_token);  // 压入节点[弹出3个压入1个]
+        return;
+    }
+    else{
+        back_one_token(list, for_t);
+        return;
+    }
+}
+
+/*
+while_ : WHILE LB top_exp RB block
 */
 void while_(int *status, token_node *list){
     fprintf(status_log, "[info][grammar]  mode status: while_\n");
@@ -109,9 +336,9 @@ void while_(int *status, token_node *list){
         if(lb_t.type != LB_PASER){
             paser_error("Don't get '('");
         }
-        get_right_token(status,list,polynomial,exp_t);
-        if(exp_t.type != NON_polynomial){  // 不是表达式
-            paser_error("Don't get 'polynomial'");
+        get_right_token(status,list,top_exp,exp_t);
+        if(exp_t.type != NON_top_exp){  // 不是表达式
+            paser_error("Don't get 'top_exp'");
         }
         get_pop_token(status, list, rb_t);
         if(rb_t.type != RB_PASER){
@@ -151,18 +378,17 @@ void block_(int *status, token_node *list){
         statement *block_tmp =  make_statement();
         statement_base = append_statement_list(block_tmp, statement_base);
         
-        get_right_token(status,list,command_list,command_list_t);
+        get_right_token(status,list,command_list,command_list_t);  // 要把command_list也弹出来
 
         statement_base = free_statement_list(statement_base);  // 重新释放
         get_pop_token(status, list, rp_t);
         if(rp_t.type != RP_PASER){
-            printf("rp_t.type = %d\n", rp_t.type);
             paser_error("Don't get '}'");
         }
         new_token.type = NON_block;
         new_token.data_type = statement_value;
         new_token.data.statement_value = block_tmp;
-        add_node(list, new_token);  // 压入节点[弹出3个压入1个]
+        add_node(list, new_token);  // 压入节点
         return;
     }
     else{
@@ -171,6 +397,23 @@ void block_(int *status, token_node *list){
     }
 }
 
+/*
+top_exp : polynomial
+*/
+
+void top_exp(int *status, token_node *list){
+    fprintf(status_log, "[info][grammar]  mode status: top_exp\n");
+    token exp;
+    get_base_token(status,list,polynomial,exp);
+    if(exp.type != NON_polynomial){
+        back_one_token(list, exp);
+        return;
+    }
+    exp.type = NON_top_exp;
+    add_node(list, exp);  // 压入节点
+    return;
+}
+
 /*
 polynomial : factor
            | polynomial ADD factor
@@ -229,9 +472,9 @@ void polynomial(int *status, token_node *list){  // 多项式
 }
 
 /*
-factor : number
-       | factor MUL number
-       | factor DIV number
+factor : element
+       | factor MUL element
+       | factor DIV element
 */
 void factor(int *status, token_node *list){  // 因试分解
     fprintf(status_log, "[info][grammar]  mode status: factor\n");
@@ -243,8 +486,8 @@ void factor(int *status, token_node *list){  // 因试分解
         get_pop_token(status, list, symbol);
 
         if(symbol.type == MUL_PASER || symbol.type == DIV_PASER){  // 模式2/3
-            get_right_token(status, list, number, right);  // 回调右边
-            if(right.type != NON_base_value){
+            get_right_token(status, list, element, right);  // 回调右边
+            if(right.type != NON_element){
                 paser_error("Don't get a value");
             }
             // 逻辑操作
@@ -274,10 +517,10 @@ void factor(int *status, token_node *list){  // 因试分解
         }
     }
     else{  // 模式1
-        fprintf(status_log, "[info][grammar]  (factor)back one token to (number)\n");
+        fprintf(status_log, "[info][grammar]  (factor)back one token to (element)\n");
         back_one_token(list, left);
-        get_base_token(status, list, number, new_token);
-        if(new_token.type != NON_base_value){
+        get_base_token(status, list, element, new_token);
+        if(new_token.type != NON_element){
             back_one_token(list, new_token);  // 往回[不匹配类型]
             return;
         }
@@ -287,10 +530,49 @@ void factor(int *status, token_node *list){  // 因试分解
     }
 }
 
+/*
+element : number
+        | LB top_exp RB
+*/
+void element(int *status, token_node *list){  // 数字归约
+    fprintf(status_log, "[info][grammar]  mode status: element\n");
+    token gett, new_token;
+
+    gett = pop_node(list);  // 取得一个token
+    if(gett.type == LB_PASER){  // 模式3
+        fprintf(status_log, "[info][grammar]  (element)get LB\n");
+        get_right_token(status, list, top_exp, new_token);
+        if(new_token.type != NON_top_exp){
+            paser_error("Don't get 'top_exp'");            
+        }
+        new_token.type = NON_element;
+        token rb;
+        get_pop_token(status, list ,rb);
+        if(rb.type != RB_PASER){  // 匹配失败
+            paser_error("Don't get ')'");
+        }
+        add_node(list, new_token);  // 压入节点
+        return;
+    }
+    else{
+        fprintf(status_log, "[info][grammar]  (element)back one token to (number)\n");
+        back_one_token(list, gett);
+        get_base_token(status, list, number, new_token);
+        if(new_token.type != NON_base_value){
+            back_one_token(list, new_token);  // 往回[不匹配类型]
+            return;
+        }
+        new_token.type = NON_element;
+        add_node(list, new_token);
+        return;
+
+    }
+}
+
 /*
 number : INT_PASER
        | DOUBLE_PASER
-       | LB polynomial RB
+       | LB top_exp RB
 */
 void number(int *status, token_node *list){  // 数字归约
     fprintf(status_log, "[info][grammar]  mode status: number\n");
@@ -329,16 +611,6 @@ void number(int *status, token_node *list){  // 数字归约
 
         fprintf(status_log, "[info][grammar]  (number)get double number: %f\n", new_token.data.d_number);
     }
-    else if(gett.type == LB_PASER){  // 模式3
-        fprintf(status_log, "[info][grammar]  (number)get LB\n");
-        get_right_token(status, list, polynomial, new_token);
-        new_token.type = NON_base_value;
-        token rb;
-        get_pop_token(status, list ,rb);
-        if(rb.type != RB_PASER){  // 匹配失败
-            paser_error("Don't get ')'");
-        }
-    }
     else{  // 不是期望值
         fprintf(status_log, "[info][grammar]  (number)back one token\n");
         back_one_token(list, gett);

+ 17 - 1
paser/token.h

@@ -3,7 +3,7 @@
 
 #include "../inter/interpreter.h"
 
-#define MAX_PASER_SIZE 13
+#define MAX_PASER_SIZE 18
 #define INT_PASER 0
 #define DOUBLE_PASER 1
 #define ENTER_PASER 2
@@ -17,6 +17,11 @@
 #define WHILE_PASER 10
 #define LP_PASER 11
 #define RP_PASER 12
+#define IF_PASER 13
+#define ELIF_PASER 14
+#define ELSE_PASER 15
+#define COMMA_PASER 16
+#define FOR_PASER 17
 
 // 获取并返回一个token
 #define get_pop_token(status,list,new_token) \
@@ -53,6 +58,7 @@ back_token(list); \
 do{ \
 token stop; \
 get_pop_token(status, list, stop); \
+printf("stop.type = %d\n", stop.type); \
 if(stop.type != ENTER_PASER && stop.type != EOF_token){ \
     paser_error("Don't get stop token or EOF"); \
 } \
@@ -79,6 +85,10 @@ typedef enum token_type
     WHILE = WHILE_PASER,
     LP = LP_PASER,
     RP = RP_PASER,
+    IF = IF_PASER,
+    ELIF = ELIF_PASER,
+    ELSE = ELSE_PASER,
+    COMMA = COMMA_PASER,
 
     // 特殊符号
     BAD_token = -2,
@@ -92,6 +102,12 @@ typedef enum token_type
     NON_command_list = -9,
     NON_while = -10,
     NON_block = -11,
+    NON_top_exp = -12,
+    NON_if = -13,
+    NON_elif = -14,
+    NON_else = -15,
+    NON_for = -16,
+    NON_element = -17,
 } token_type;
 
 typedef union token_data

+ 140 - 58
status.log

@@ -1,14 +1,14 @@
-[debug][grammar]  get token type : 10; data type : 0
+[debug][grammar]  get token type : 17; data type : 0
 [debug][grammar]  add a token[seek : 0, index : 0, size : 1]
 [debug][grammar]  after add a token[seek : 1, index : 1]
-[info][grammar]  mode status: polynomial
+[info][grammar]  mode status: top_exp
 [debug][grammar]  pop a token[seek : 0, index : 0]
 [info][grammar]  (command_list)back one token to (command)
 [debug][grammar]  add a token[seek : 0, index : 0, size : 2]
 [debug][grammar]  after add a token[seek : 1, index : 1]
-[info][grammar]  mode status: polynomial
+[info][grammar]  mode status: command
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (command)back one token to (while)
+[info][grammar]  (command)back one token to (for)
 [debug][grammar]  add a token[seek : 0, index : 0, size : 2]
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [info][grammar]  mode status: while_
@@ -17,9 +17,17 @@
 [debug][grammar]  add a token[seek : 0, index : 0, size : 2]
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [debug][grammar]  pop a token[seek : 0, index : 0]
+[debug][grammar]  get token type : 16; data type : 0
+[debug][grammar]  add a token[seek : 0, index : 0, size : 2]
+[debug][grammar]  after add a token[seek : 1, index : 1]
+[debug][grammar]  pop a token[seek : 0, index : 0]
 [debug][grammar]  get token type : 0; data type : 0
 [debug][grammar]  add a token[seek : 0, index : 0, size : 2]
 [debug][grammar]  after add a token[seek : 1, index : 1]
+[debug][grammar]  pop a token[seek : 0, index : 0]
+[debug][grammar]  add a token[seek : 0, index : 0, size : 2]
+[debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: top_exp
 [info][grammar]  mode status: polynomial
 [debug][grammar]  pop a token[seek : 0, index : 0]
 [info][grammar]  (polynomial)back one token to (factor)
@@ -27,7 +35,12 @@
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [info][grammar]  mode status: factor
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (factor)back one token to (number)
+[info][grammar]  (factor)back one token to (element)
+[debug][grammar]  add a token[seek : 0, index : 0, size : 2]
+[debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: element
+[debug][grammar]  pop a token[seek : 0, index : 0]
+[info][grammar]  (element)back one token to (number)
 [debug][grammar]  add a token[seek : 0, index : 0, size : 2]
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [info][grammar]  mode status: number
@@ -39,10 +52,13 @@
 [debug][grammar]  pop a token[seek : 0, index : 0]
 [debug][grammar]  add a token[seek : 0, index : 0, size : 2]
 [debug][grammar]  after add a token[seek : 1, index : 1]
+[debug][grammar]  pop a token[seek : 0, index : 0]
+[debug][grammar]  add a token[seek : 0, index : 0, size : 2]
+[debug][grammar]  after add a token[seek : 1, index : 1]
 [info][grammar]  mode status: factor
 [debug][grammar]  pop a token[seek : 0, index : 0]
 [info][grammar]  (factor)reduce right
-[debug][grammar]  get token type : 5; data type : 0
+[debug][grammar]  get token type : 4; data type : 0
 [debug][grammar]  add a token[seek : 0, index : 0, size : 2]
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [debug][grammar]  pop a token[seek : 0, index : 0]
@@ -65,7 +81,12 @@
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [info][grammar]  mode status: factor
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (factor)back one token to (number)
+[info][grammar]  (factor)back one token to (element)
+[debug][grammar]  add a token[seek : 0, index : 0, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: element
+[debug][grammar]  pop a token[seek : 0, index : 0]
+[info][grammar]  (element)back one token to (number)
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [info][grammar]  mode status: number
@@ -77,10 +98,13 @@
 [debug][grammar]  pop a token[seek : 0, index : 0]
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
+[debug][grammar]  pop a token[seek : 0, index : 0]
+[debug][grammar]  add a token[seek : 0, index : 0, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 1]
 [info][grammar]  mode status: factor
 [debug][grammar]  pop a token[seek : 0, index : 0]
 [info][grammar]  (factor)reduce right
-[debug][grammar]  get token type : 9; data type : 0
+[debug][grammar]  get token type : 16; data type : 0
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [debug][grammar]  pop a token[seek : 0, index : 0]
@@ -105,54 +129,40 @@
 [debug][grammar]  after add a token[seek : 2, index : 2]
 [debug][grammar]  back a token[seek : 2, index : 2]
 [debug][grammar]  pop a token[seek : 0, index : 1]
+[debug][grammar]  add a token[seek : 0, index : 1, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 2]
+[debug][grammar]  pop a token[seek : 0, index : 1]
 [debug][grammar]  get token seek += 1 : 0, index : 1
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[debug][grammar]  get token type : 11; data type : 0
-[debug][grammar]  add a token[seek : 0, index : 0, size : 3]
-[debug][grammar]  after add a token[seek : 1, index : 1]
-[info][grammar]  mode status: block_
-[debug][grammar]  pop a token[seek : 0, index : 0]
-[debug][grammar]  get token type : 2; data type : 0
-[debug][grammar]  add a token[seek : 0, index : 0, size : 3]
-[debug][grammar]  after add a token[seek : 1, index : 1]
-[info][grammar]  mode status: polynomial
-[debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (command_list)back one token to (command)
-[debug][grammar]  add a token[seek : 0, index : 0, size : 3]
-[debug][grammar]  after add a token[seek : 1, index : 1]
-[info][grammar]  mode status: polynomial
-[debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (command)back <ENTER>
+[debug][grammar]  get token type : 0; data type : 0
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [debug][grammar]  pop a token[seek : 0, index : 0]
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: top_exp
 [info][grammar]  mode status: polynomial
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (command_list)reduce right
-[debug][grammar]  get token type : 0; data type : 0
+[info][grammar]  (polynomial)back one token to (factor)
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
-[info][grammar]  mode status: polynomial
+[info][grammar]  mode status: factor
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (command)back one token to (polynomial)
+[info][grammar]  (factor)back one token to (element)
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
-[info][grammar]  mode status: polynomial
+[info][grammar]  mode status: element
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (polynomial)back one token to (factor)
+[info][grammar]  (element)back one token to (number)
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
-[info][grammar]  mode status: factor
+[info][grammar]  mode status: number
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (factor)back one token to (number)
+[info][grammar]  (number)get int number: 1
+[info][grammar]  (number)add one token
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
-[info][grammar]  mode status: number
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (number)get int number: 10
-[info][grammar]  (number)add one token
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [debug][grammar]  pop a token[seek : 0, index : 0]
@@ -184,22 +194,30 @@
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [info][grammar]  mode status: factor
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (factor)back one token to (number)
+[info][grammar]  (factor)back one token to (element)
+[debug][grammar]  add a token[seek : 0, index : 0, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: element
+[debug][grammar]  pop a token[seek : 0, index : 0]
+[info][grammar]  (element)back one token to (number)
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [info][grammar]  mode status: number
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (number)get int number: 10
+[info][grammar]  (number)get int number: 1
 [info][grammar]  (number)add one token
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [debug][grammar]  pop a token[seek : 0, index : 0]
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
+[debug][grammar]  pop a token[seek : 0, index : 0]
+[debug][grammar]  add a token[seek : 0, index : 0, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 1]
 [info][grammar]  mode status: factor
 [debug][grammar]  pop a token[seek : 0, index : 0]
 [info][grammar]  (factor)reduce right
-[debug][grammar]  get token type : 2; data type : 0
+[debug][grammar]  get token type : 9; data type : 0
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [debug][grammar]  pop a token[seek : 0, index : 0]
@@ -224,24 +242,44 @@
 [debug][grammar]  after add a token[seek : 2, index : 2]
 [debug][grammar]  back a token[seek : 2, index : 2]
 [debug][grammar]  pop a token[seek : 0, index : 1]
+[debug][grammar]  add a token[seek : 0, index : 1, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 2]
+[debug][grammar]  pop a token[seek : 0, index : 1]
 [debug][grammar]  get token seek += 1 : 0, index : 1
 [debug][grammar]  pop a token[seek : 0, index : 0]
+[debug][grammar]  get token type : 11; data type : 0
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: block_
 [debug][grammar]  pop a token[seek : 0, index : 0]
+[debug][grammar]  get token type : 2; data type : 0
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
-[info][grammar]  mode status: polynomial
+[info][grammar]  mode status: top_exp
+[debug][grammar]  pop a token[seek : 0, index : 0]
+[info][grammar]  (command_list)back one token to (command)
+[debug][grammar]  add a token[seek : 0, index : 0, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: command
+[debug][grammar]  pop a token[seek : 0, index : 0]
+[info][grammar]  (command)back <ENTER>
+[debug][grammar]  add a token[seek : 0, index : 0, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 1]
+[debug][grammar]  pop a token[seek : 0, index : 0]
+[debug][grammar]  add a token[seek : 0, index : 0, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: top_exp
 [debug][grammar]  pop a token[seek : 0, index : 0]
 [info][grammar]  (command_list)reduce right
-[debug][grammar]  get token type : 12; data type : 0
+[debug][grammar]  get token type : 0; data type : 0
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
-[info][grammar]  mode status: polynomial
+[info][grammar]  mode status: command
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (command)back one token to (polynomial)
+[info][grammar]  (command)back one token to (top_exp)
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: top_exp
 [info][grammar]  mode status: polynomial
 [debug][grammar]  pop a token[seek : 0, index : 0]
 [info][grammar]  (polynomial)back one token to (factor)
@@ -249,15 +287,18 @@
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [info][grammar]  mode status: factor
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (factor)back one token to (number)
+[info][grammar]  (factor)back one token to (element)
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
-[info][grammar]  mode status: number
+[info][grammar]  mode status: element
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (number)back one token
+[info][grammar]  (element)back one token to (number)
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: number
 [debug][grammar]  pop a token[seek : 0, index : 0]
+[info][grammar]  (number)get int number: 100
+[info][grammar]  (number)add one token
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [debug][grammar]  pop a token[seek : 0, index : 0]
@@ -266,23 +307,25 @@
 [debug][grammar]  pop a token[seek : 0, index : 0]
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: factor
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (command_list)out
+[info][grammar]  (factor)reduce right
+[debug][grammar]  get token type : 6; data type : 0
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
-[debug][grammar]  add a token[seek : 1, index : 1, size : 3]
-[debug][grammar]  after add a token[seek : 2, index : 2]
-[debug][grammar]  back a token[seek : 2, index : 2]
-[debug][grammar]  pop a token[seek : 0, index : 1]
-[debug][grammar]  get token seek += 1 : 0, index : 1
 [debug][grammar]  pop a token[seek : 0, index : 0]
+[debug][grammar]  get token type : 0; data type : 0
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: element
 [debug][grammar]  pop a token[seek : 0, index : 0]
+[info][grammar]  (element)back one token to (number)
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: number
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[debug][grammar]  get token type : 2; data type : 0
+[info][grammar]  (number)get int number: 3
+[info][grammar]  (number)add one token
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [debug][grammar]  pop a token[seek : 0, index : 0]
@@ -291,21 +334,60 @@
 [debug][grammar]  pop a token[seek : 0, index : 0]
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
-[info][grammar]  mode status: polynomial
+[info][grammar]  mode status: factor
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (command_list)reduce right
-[debug][grammar]  get token type : -3; data type : 6
+[info][grammar]  (factor)reduce right
+[debug][grammar]  get token type : 2; data type : 0
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
-[info][grammar]  mode status: polynomial
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (command)back <EOF>
+[info][grammar]  (factor)out
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
+[debug][grammar]  add a token[seek : 1, index : 1, size : 3]
+[debug][grammar]  after add a token[seek : 2, index : 2]
+[debug][grammar]  back a token[seek : 2, index : 2]
+[debug][grammar]  pop a token[seek : 0, index : 1]
+[debug][grammar]  add a token[seek : 0, index : 1, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 2]
+[info][grammar]  mode status: polynomial
+[debug][grammar]  pop a token[seek : 0, index : 1]
+[info][grammar]  (polynomial)reduce right
+[debug][grammar]  get token seek += 1 : 0, index : 1
 [debug][grammar]  pop a token[seek : 0, index : 0]
-[info][grammar]  (command_list)out
+[info][grammar]  (polynomial)out
 [debug][grammar]  add a token[seek : 0, index : 0, size : 3]
 [debug][grammar]  after add a token[seek : 1, index : 1]
 [debug][grammar]  add a token[seek : 1, index : 1, size : 3]
 [debug][grammar]  after add a token[seek : 2, index : 2]
 [debug][grammar]  back a token[seek : 2, index : 2]
+[debug][grammar]  pop a token[seek : 0, index : 1]
+[debug][grammar]  add a token[seek : 0, index : 1, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 2]
+[debug][grammar]  pop a token[seek : 0, index : 1]
+[debug][grammar]  get token seek += 1 : 0, index : 1
+[debug][grammar]  pop a token[seek : 0, index : 0]
+[debug][grammar]  add a token[seek : 0, index : 0, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 1]
+[debug][grammar]  pop a token[seek : 0, index : 0]
+[debug][grammar]  add a token[seek : 0, index : 0, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: top_exp
+[debug][grammar]  pop a token[seek : 0, index : 0]
+[info][grammar]  (command_list)reduce right
+[debug][grammar]  get token type : 12; data type : 0
+[debug][grammar]  add a token[seek : 0, index : 0, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: command
+[debug][grammar]  pop a token[seek : 0, index : 0]
+[info][grammar]  (command)back one token to (top_exp)
+[debug][grammar]  add a token[seek : 0, index : 0, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: top_exp
+[info][grammar]  mode status: polynomial
+[debug][grammar]  pop a token[seek : 0, index : 0]
+[info][grammar]  (polynomial)back one token to (factor)
+[debug][grammar]  add a token[seek : 0, index : 0, size : 3]
+[debug][grammar]  after add a token[seek : 1, index : 1]
+[info][grammar]  mode status: factor
+[debug][grammar]  pop a token[seek : 

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff