-
Notifications
You must be signed in to change notification settings - Fork 0
/
cat_oracle.y
executable file
·301 lines (231 loc) · 9.32 KB
/
cat_oracle.y
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
%{
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include<unistd.h>
int yylex();
int yyparse();
void yyerror(const char* msg);
%}
%token QUESTION WHAT WHO WHEN WHERE HOW EOL
%%
start: { printf("\033[2J\033[H"); // clear screen
printf("\033[1;36m"); // change terminal color to cyan
printf("\n Welcome to the \n");
printf(" __ ____ ______ ___ ____ ____ __ _ ___ \n");
printf(" / ] / || | / \\ | \\ / | / ]| | / _]\n");
printf(" / / | o || | | || D )| o | / / | | / [_ \n");
printf(" / / | ||_| |_| | O || / | | / / | |___ | _]\n");
printf("/ \\_ | _ | | | | || \\ | _ |/ \\_ | || [_ \n");
printf("\\ || | | | | | || . \\| | |\\ || || |\n");
printf(" \\____||__|__| |__| \\___/ |__|\\_||__|__| \\____||_____||_____|\n\n");
printf(" |\\ _,,,---,,_\n");
printf(" ZZZzz /,`.-'`' -. ;-;;,_\n");
printf(" |,4- ) )-,_. ,\\ ( `'-'\n");
printf(" '---''(_/--' `-'\\_) \n\n");
printf("Ask me about your Future!\n\n");}
input;
input:
| input question
| input question_what
| input question_who
| input question_when
| input question_where
| input question_how
;
question: QUESTION EOL {
const char* sentences[] = { // array of sentences to choose from
"Meow!\n",
"Purr!\n",
"Meow-meow!\n",
"Meow-purr!\n",
"Purr-meow!\n"
};
int num_sentences = sizeof(sentences) / sizeof(sentences[0]);
srand(time(NULL));
int random_index = rand() % num_sentences; // randomize array-index
//Animation
const char* spinner[] = {
"ᓚᘏᗢ_", "ᓭᘏᗢ__", "ᓚᘏᗢ_", ". . ᓚᗢ .", ". . . ᗢ ᘐ", "_ᗢᘐᓗ", "__ᗢᘐᓯ", "_ᗢᘐᓗ", "ᗢᓗ . . .", "ᘏᗢ_ . ."
};
const int numFrames = 10;
for (int frame = 0; frame < numFrames; ++frame) {
printf("\033[2J\033[H");
printf("%s\n", spinner[frame % (sizeof(spinner) / sizeof(spinner[0]))]);
usleep(100 * 2000);
}
printf("%s\n", sentences[random_index]);
}
;
question_what: WHAT QUESTION EOL {
const char* sentences[] = {
"What's it to you? Find it yourself.\n",
"The grandest of naps, my dear human, for we all find rest in the end.\n",
"A treasure trove of memories, and I shall claim a spot in them, no doubt.\n",
"The answer lies in the dance of fate, but I won't reveal all the steps just yet.\n",
"To conquer obstacles, remember, even the grandest leaps start with a small purr.\n",
"Flex your whiskers and navigate with the grace of a stealthy cat; obstacles won't know what hit 'em.\n",
"Pawsitivity, dear human, pawsitivity! Face it head-on with a twinkle in your eye.\n"
};
int num_sentences = sizeof(sentences) / sizeof(sentences[0]);
srand(time(NULL));
int random_index = rand() % num_sentences;
const char* spinner[] = {
"ᓚᘏᗢ_ …ᓄ",
"ᓚᘏᗢ_ ……ᓄ" ,
"ᓚᘏᗢ__ ………ᓄ" ,
"ᓚᘏᗢ__ ……………ᓄ" ,
"ᓚᘏᗢ_ …………ᓄ" ,
"ᓚᘏᗢ_ ………ᓄ" ,
"ᓚᘏᗢ_ ……ᓄ" ,
"ᓚᘏᗢ_ …ᓄ" ,
"ᓚᘏᗢ_ ᓄ"
};
const int numFrames = 9;
for (int frame = 0; frame < numFrames; ++frame) {
printf("\033[2J\033[H");
printf("%s\n", spinner[frame % (sizeof(spinner) / sizeof(spinner[0]))]);
usleep(100 * 2000);
}
printf("%s\n", sentences[random_index]);
}
;
question_who: WHO QUESTION EOL {
const char* sentences[] = {
"Ah, a new companion approaches, bearing treats and belly rubs, I hope. What is that you want again?\n",
"A peculiar character with a penchant for amusing me, I daresay.\n",
"Ooh! A brave soul who thinks they can resist my charm, but we shall see.\n"
"Consult the ancient tomes of cat wisdom, hidden in the dusty corners of your bookshelves.\n",
"Listen to those with the wisdom of a whisker twitch, they might surprise you.\n",
"Advice from a cat? Preposterous! But perhaps, you should heed it anyway.\n"
};
int num_sentences = sizeof(sentences) / sizeof(sentences[0]);
srand(time(NULL));
int random_index = rand() % num_sentences;
const char* spinner[] = {
"ᓚᘏᗢ_ …ᓄ",
"ᓚᘏᗢ_ ……ᓄ" ,
"ᓚᘏᗢ__ ………ᓄ" ,
"ᓚᘏᗢ__ ……………ᓄ" ,
"ᓚᘏᗢ_ …………ᓄ" ,
"ᓚᘏᗢ_ ………ᓄ" ,
"ᓚᘏᗢ_ ……ᓄ" ,
"ᓚᘏᗢ_ …ᓄ" ,
"ᓚᘏᗢ_ ᓄ"
};
const int numFrames = 9;
for (int frame = 0; frame < numFrames; ++frame) {
printf("\033[2J\033[H");
printf("%s\n", spinner[frame % (sizeof(spinner) / sizeof(spinner[0]))]);
usleep(100 * 2000);
}
printf("%s\n", sentences[random_index]);
}
;
question_when: WHEN QUESTION EOL {
const char* sentences[] = {
"When you stop chasing your tail and embrace the purrfection of the present.\n",
"Happiness is fleeting like a moth's flight; catch it while you can, old sport.\n",
"Ah, the future is like a tangled ball of yarn, mysterious and full of surprises. Embrace it, and may your curiosity lead the way.\n"
};
int num_sentences = sizeof(sentences) / sizeof(sentences[0]);
srand(time(NULL));
int random_index = rand() % num_sentences;
const char* spinner[] = {
"ᓚᘏᗢ_ …ᓄ",
"ᓚᘏᗢ_ ……ᓄ" ,
"ᓚᘏᗢ__ ………ᓄ" ,
"ᓚᘏᗢ__ ……………ᓄ" ,
"ᓚᘏᗢ_ …………ᓄ" ,
"ᓚᘏᗢ_ ………ᓄ" ,
"ᓚᘏᗢ_ ……ᓄ" ,
"ᓚᘏᗢ_ …ᓄ" ,
"ᓚᘏᗢ_ ᓄ"
};
const int numFrames = 9;
for (int frame = 0; frame < numFrames; ++frame) {
printf("\033[2J\033[H");
printf("%s\n", spinner[frame % (sizeof(spinner) / sizeof(spinner[0]))]);
usleep(100 * 2000);
}
printf("%s\n", sentences[random_index]);
}
;
question_where: WHERE QUESTION EOL {
const char* sentences[] = {
"Seek the comfiest cushions and softest blankets, there lies tranquility.\n",
" Follow the scent of catnip and let it guide you to where your heart feels most alive.\n",
"A sunbeam-soaked windowsill does wonders, I assure you.\n",
"Why choose ways? The secret to inner peace is hidden within a good old chin scratch, meowvellous.\n",
"Choose the path that leads you to the heart of every cat lover, obviously!\n",
"Ah, the forked roads of life! Choose the one with the most sunbeams.\n",
"I hid it somewhere you'll never find.\n",
};
int num_sentences = sizeof(sentences) / sizeof(sentences[0]);
srand(time(NULL));
int random_index = rand() % num_sentences;
const char* spinner[] = {
"ᓚᘏᗢ_ …ᓄ",
"ᓚᘏᗢ_ ……ᓄ" ,
"ᓚᘏᗢ__ ………ᓄ" ,
"ᓚᘏᗢ__ ……………ᓄ" ,
"ᓚᘏᗢ_ …………ᓄ" ,
"ᓚᘏᗢ_ ………ᓄ" ,
"ᓚᘏᗢ_ ……ᓄ" ,
"ᓚᘏᗢ_ …ᓄ" ,
"ᓚᘏᗢ_ ᓄ"
};
const int numFrames = 9;
for (int frame = 0; frame < numFrames; ++frame) {
printf("\033[2J\033[H");
printf("%s\n", spinner[frame % (sizeof(spinner) / sizeof(spinner[0]))]);
usleep(100 * 2000);
}
printf("%s\n", sentences[random_index]);
}
;
question_how: HOW QUESTION EOL {
const char* sentences[] = {
"To conquer obstacles, remember, even the grandest leaps start with a small purr.\n",
"Flex your whiskers and navigate with the grace of a stealthy cat; obstacles won't know what hit 'em.\n",
"Pawsitivity, dear human, pawsitivity! Face it head-on with a twinkle in your eye.\n",
"Ah, the future is like a tangled ball of yarn, mysterious and full of surprises. Embrace it, and may your curiosity lead the way.\n"
};
int num_sentences = sizeof(sentences) / sizeof(sentences[0]);
srand(time(NULL));
int random_index = rand() % num_sentences;
const char* spinner[] = {
"ᓚᘏᗢ_ …ᓄ",
"ᓚᘏᗢ_ ……ᓄ" ,
"ᓚᘏᗢ__ ………ᓄ" ,
"ᓚᘏᗢ__ ……………ᓄ" ,
"ᓚᘏᗢ_ …………ᓄ" ,
"ᓚᘏᗢ_ ………ᓄ" ,
"ᓚᘏᗢ_ ……ᓄ" ,
"ᓚᘏᗢ_ …ᓄ" ,
"ᓚᘏᗢ_ ᓄ"
};
const int numFrames = 9;
for (int frame = 0; frame < numFrames; ++frame) {
printf("\033[2J\033[H");
printf("%s\n", spinner[frame % (sizeof(spinner) / sizeof(spinner[0]))]);
usleep(100 * 2000);
}
printf("%s\n", sentences[random_index]);
}
;
%%
int main() {
yyparse();
return 0;
}
void yyerror(const char* _) {
fprintf(stderr, " ");
printf("\033[2J\033[H");
printf("Stop wasting my time, humanoid, begone!\n");
sleep(1);
printf("\033[2J\033[H");
}
int yywrap() {
return 1;
}