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/miniproject/cnasm/regn.y | 81 --------------------------------------- 1 file changed, 81 deletions(-) delete mode 100644 sem1/osc/miniproject/cnasm/regn.y (limited to 'sem1/osc/miniproject/cnasm/regn.y') diff --git a/sem1/osc/miniproject/cnasm/regn.y b/sem1/osc/miniproject/cnasm/regn.y deleted file mode 100644 index b72d440..0000000 --- a/sem1/osc/miniproject/cnasm/regn.y +++ /dev/null @@ -1,81 +0,0 @@ -%{ -#include "ast.h" -#include -#include -#include -#include -#include -#include "codegen.h" - -#define CLEAN_BOTH 2 -#define CLEAN_DST 1 - -char *strconcat(char *dst, char *src, unsigned int clean) { - size_t dstlen = strlen(dst) + 1; - size_t srclen = strlen(src) + 1; - - // Create new duplicate - char *new = malloc(( dstlen + srclen ) * sizeof(char)); - - // Copy stuff - memcpy(new, dst, dstlen); - strcat(new, src); - - // Free old one - if( clean-- ) { - free(dst); - - if( clean ) { - free(src); - } - } - return new; -} - -// Trace node - -%} - -%token IFF EELSE FFOR RP RCP RSP LP LCP LSP ID COLON CMP NO WHILE - -%union { - char *string; - struct ast_node *node; - struct cond *condition; - uint8_t cmp; -} - -%type ID -%type statement stm_list -%type CMP -%type condition - -%% - -program: stm_list {gentree(stdout, NULL, $1);printf("\n");}; - -stm_list: statement { $$ = $1; } - | stm_list statement { $$ = insert_stm($2, $1); }; - -condition: ID CMP ID { $$ = insert_cond($2, $1, $3); } - | ID { $$ = insert_cond(CNEQ, $1, "0");}; - -statement: ID {$$ = insert_ident($1);} - | IFF LP condition RP LCP stm_list RCP {$$ = insert_ctrl(TIF, $3, $6, NULL);} - | IFF LP condition RP LCP stm_list RCP EELSE LCP stm_list RCP {$$ = insert_ctrl(TIF, $3, $6, $10);} - | WHILE LP condition RP LCP stm_list RCP {$$ = insert_ctrl(TWHILE, $3, $6, NULL);} - | FFOR LP ID LP condition LP ID RP LCP stm_list RCP {$$ = insert_for($3, $5, $7, $10);}; - -%% - - -int main() { - - /*for(;;) { - int t = yylex(); - printf("yylex: %d\n", t); - } */ - - yyparse(); -} - -- cgit v1.2.3