Explorar el Código

Implemented brange operator

Andrea Gussoni hace 8 años
padre
commit
5de054abe6
Se han modificado 3 ficheros con 13 adiciones y 0 borrados
  1. 1 0
      acse/Acse.lex
  2. 5 0
      acse/Acse.y
  3. 7 0
      tests/brange/brange.src

+ 1 - 0
acse/Acse.lex

@@ -98,6 +98,7 @@ ID       [a-zA-Z_][a-zA-Z0-9_]*
 "return"          { return RETURN; }
 "read"            { return READ; }
 "write"           { return WRITE; }
+"brange"          { return BRANGE; }
 
 {ID}              { yylval.svalue=strdup(yytext); return IDENTIFIER; }
 {DIGIT}+          { yylval.intval = atoi( yytext );

+ 5 - 0
acse/Acse.y

@@ -121,6 +121,7 @@ t_io_infos *file_infos;    /* input and output files used by the compiler */
 %token RETURN
 %token READ
 %token WRITE
+%token BRANGE
 
 %token <label> DO
 %token <while_stmt> WHILE
@@ -565,6 +566,10 @@ exp: NUMBER      { $$ = create_expression ($1, IMMEDIATE); }
                                  (program, exp_r0, $2, SUB);
                         }
                      }
+   | BRANGE LPAR exp COMMA exp COMMA exp RPAR {
+        $$ = handle_brange_op(program, $3, $5, $7);
+     }
+   
 ;
 
 %%

+ 7 - 0
tests/brange/brange.src

@@ -0,0 +1,7 @@
+int a, v, r;
+
+
+v = 11584;
+r = 42 + brange(v, 2, 12);
+
+write(r);