From 06fcc82becf578aadd89632684a821eb3b178740 Mon Sep 17 00:00:00 2001 From: anon Date: Tue, 10 Dec 2024 20:39:01 +0100 Subject: [PATCH] Added 'C_C++/bison/string.y' --- C_C++/bison/string.y | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 C_C++/bison/string.y diff --git a/C_C++/bison/string.y b/C_C++/bison/string.y new file mode 100644 index 0000000..16ce1a5 --- /dev/null +++ b/C_C++/bison/string.y @@ -0,0 +1,25 @@ +/* @BAKE + bison -o string.tab.c $@ + g++ string.tab.c -o string + ./string + @STOP +*/ +%code requires { + #include + #include + void yyerror(...) { ; } +} +%union { + std::string * strval; +} +%{ + int yylex() { + yylval.strval = new std::string("There are only two hard problems in CS: cache invalidation, nameing things, and off-by-one errors."); + return STRING; + } +%} +%token STRING +%% +string: STRING { std::cout << *(yylval.strval) << std::endl; } +%% +signed main() { yyparse(); }