From 9ee94724bede6286c2d2635ce8938f08b355066f Mon Sep 17 00:00:00 2001 From: anon Date: Tue, 10 Dec 2024 20:39:01 +0100 Subject: [PATCH] Added 'C_C++/bison/error.y' --- C_C++/bison/error.y | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 C_C++/bison/error.y diff --git a/C_C++/bison/error.y b/C_C++/bison/error.y new file mode 100644 index 0000000..0be8122 --- /dev/null +++ b/C_C++/bison/error.y @@ -0,0 +1,27 @@ +/* @BAKE + bison -Wcounterexamples --header=error.tab.h -o error.tab.c $@; + gcc error.tab.c -o error; + ./error; + @STOP +*/ +%{ +#include +#include +#include "error.tab.h" +int yylex() { + static int i = 0; + const int alpha[] = {B, 0}; + return alpha[i++]; +} +void yyerror() { ; } +%} +%token A B +%% +i: A + | error B { yyerrok; puts("We recovered!"); } + ; +%% +signed main() { + yyparse(); + return 0; +}