|
@@ -24,22 +24,26 @@ extern char* yytext;
|
|
|
|
|
|
%%
|
|
|
|
|
|
-EXPR_CALCS : EXPR_CALC
|
|
|
- | EXPR_CALCS EXPR_CALC
|
|
|
- ;
|
|
|
-
|
|
|
-EXPR_CALC : EXPR '=' { printf("%d\n", $1); }
|
|
|
- ;
|
|
|
-
|
|
|
-EXPR : TERM
|
|
|
- | EXPR '+' TERM {$$ = $1 + $3;}
|
|
|
- | EXPR '-' TERM {$$ = $1 - $3;}
|
|
|
- | EXPR '*' TERM {$$ = $1 * $3;}
|
|
|
- ;
|
|
|
-
|
|
|
-TERM : nombre {$$ = $1;}
|
|
|
- | '(' EXPR ')' {$$ = $2;}
|
|
|
- ;
|
|
|
+EXPR_CALCS : EXPR_CALC
|
|
|
+ | EXPR_CALCS EXPR_CALC
|
|
|
+ ;
|
|
|
+
|
|
|
+EXPR_CALC : EXPR '=' { printf("%d\n", $1); }
|
|
|
+ ;
|
|
|
+
|
|
|
+EXPR : TERM
|
|
|
+ | EXPR '+' TERM {$$ = $1 + $3;}
|
|
|
+ | EXPR '-' TERM {$$ = $1 - $3;}
|
|
|
+ ;
|
|
|
+
|
|
|
+TERM : FACTOR
|
|
|
+ ;
|
|
|
+
|
|
|
+FACTOR :
|
|
|
+ | nombre {$$ = $1;}
|
|
|
+ | EXPR '*' TERM {$$ = $1 * $3;}
|
|
|
+ | '(' EXPR ')' {$$ = $2;}
|
|
|
+ ;
|
|
|
|
|
|
%%
|
|
|
#include <stdio.h>
|