From 6db1a2cdd3b96731f2e092d55d8c2136eabc52d0 Mon Sep 17 00:00:00 2001 From: Julian T Date: Tue, 11 Feb 2020 12:24:56 +0100 Subject: Rename and cleanup --- sem1/osc/mm11/regn/regn.y | 54 ----------------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 sem1/osc/mm11/regn/regn.y (limited to 'sem1/osc/mm11/regn/regn.y') diff --git a/sem1/osc/mm11/regn/regn.y b/sem1/osc/mm11/regn/regn.y deleted file mode 100644 index d0f67eb..0000000 --- a/sem1/osc/mm11/regn/regn.y +++ /dev/null @@ -1,54 +0,0 @@ -%{ -#include -#include -#include "symtab.h" -#include -%} - -%union { - char *string; - double dval; -} - -%token VAR -%token TAL -%token LOG EXP SQRT VAR_BEGIN - -%left '-' '+' -%right LOG EXP SQRT -%left '*' '/' -%right UMINUS - -%type expression - -%% - -statement_list: statement '\n' - | statement_list statement '\n' ; - -statement: expression {printf("= %f\n",$1);} - | VAR_BEGIN VAR '=' expression {symnode_t *n = sym_lookup($2); - if( !n ) {n = sym_insert($2); } - n->value = $4;}; - -expression: expression '+' expression {$$ = $1 + $3;} - | expression '-' expression {$$ = $1 - $3;} - | expression '*' expression {$$ = $1 * $3;} - | expression '/' expression {if ($3 == 0.0) - yyerror("divide dy zero"); - else $$ = $1 / $3;} - | '-' expression %prec UMINUS {$$ = - $2;} - | '(' expression ')' {$$= $2;} - | LOG expression {$$ = log($2);} - | EXP expression {$$ = exp($2);} - | SQRT expression {$$ = sqrt($2);} - | TAL {$$ = $1;} - | VAR {symnode_t *n = sym_lookup($1); - if( !n ) { yyerror("Var not found"); } else { $$ = n->value;} }; -%% - -int main() -{ - yyparse(); -} - -- cgit v1.2.3