From 7b81f73c45c7b1f8cda5673c6456beee7dc813d9 Mon Sep 17 00:00:00 2001 From: SantriptaSharma Date: Sat, 25 Nov 2023 03:21:27 +0530 Subject: [PATCH] nvm (a4): the r/r conflict is not a problem --- 15_A4.y | 2 +- cex.txt | 29 ----------------------------- iftest.nc | 2 +- 3 files changed, 2 insertions(+), 31 deletions(-) delete mode 100644 cex.txt diff --git a/15_A4.y b/15_A4.y index 37724d1..4f697de 100644 --- a/15_A4.y +++ b/15_A4.y @@ -620,7 +620,7 @@ selection_statement: Emit(Jump(AImm(0))); } } - | IF '(' expression ')' marker statement { $$ = MakeList(quads_size); Emit(Jump(AImm(0))); } ELSE marker statement { + | IF '(' expression ')' marker statement guard ELSE marker statement { if ($3.truelist != NULL) { Backpatch($3.truelist, $5); Backpatch($3.falselist, $9); $$ = Merge($6, $7); $$ = Merge($$, $10); diff --git a/cex.txt b/cex.txt deleted file mode 100644 index c25dd6a..0000000 --- a/cex.txt +++ /dev/null @@ -1,29 +0,0 @@ -15_A4.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] -15_A4.y: warning: reduce/reduce conflict on token ELSE [-Wcounterexamples] - First example: type_specifier declarator $@4 '{' IF '(' expression ')' marker statement • ELSE marker statement '}' $end - First reduce derivation - $accept - ↳ translation_unit $end - ↳ external_declaration - ↳ function_definition - ↳ type_specifier declarator $@4 compound_statement - ↳ '{' block_item_list '}' - ↳ block_item - ↳ statement - ↳ selection_statement - ↳ IF '(' expression ')' marker statement guard ELSE marker statement - ↳ • - Second example: type_specifier declarator $@4 '{' IF '(' expression ')' marker IF '(' expression ')' marker statement • guard ELSE marker statement '}' $end - Second reduce derivation - $accept - ↳ translation_unit $end - ↳ external_declaration - ↳ function_definition - ↳ type_specifier declarator $@4 compound_statement - ↳ '{' block_item_list '}' - ↳ block_item - ↳ statement - ↳ selection_statement - ↳ IF '(' expression ')' marker statement guard ELSE marker statement - ↳ selection_statement - ↳ IF '(' expression ')' marker statement • diff --git a/iftest.nc b/iftest.nc index 8d99c35..8d5e7ab 100644 --- a/iftest.nc +++ b/iftest.nc @@ -5,7 +5,7 @@ int main() { if (a >= b + 13 || a < 0 ) { a = 5; } else if (a > 5) { - b = 10 + b = 10; } else if (b < 1) { b = a; } else {