Added 'C_C++/bison/error.y'

This commit is contained in:
anon 2024-12-10 20:39:01 +01:00
parent 98cbd0b813
commit 9ee94724be

27
C_C++/bison/error.y Normal file
View File

@ -0,0 +1,27 @@
/* @BAKE
bison -Wcounterexamples --header=error.tab.h -o error.tab.c $@;
gcc error.tab.c -o error;
./error;
@STOP
*/
%{
#include <stdlib.h>
#include <stdio.h>
#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;
}