]>
Commit | Line | Data |
---|---|---|
bc19f2cf | 1 | %{ |
2 | ||
3 | #include <stdio.h> | |
1d0bdb96 | 4 | #include <stdlib.h> |
bc19f2cf | 5 | typedef int INT; |
6 | ||
7 | #define YYSTYPE INT | |
1d0bdb96 MG |
8 | extern int yylex (void); |
9 | int yyerror(char*); | |
bc19f2cf | 10 | |
11 | %} | |
12 | ||
13 | %token CUTE | |
14 | %token FLUFF | |
15 | %token SMILE | |
16 | %token PURR | |
17 | %token FUR | |
18 | %token MEOW | |
19 | %token ATTA | |
20 | %token YNNA | |
21 | %token YSSA | |
22 | %token ONNA | |
23 | %token WYFFA | |
24 | %token LOTTA | |
25 | %token WYF | |
26 | %token WYFF | |
27 | %token DA | |
28 | %token YER | |
29 | %token YA | |
30 | %token AN | |
31 | %token TA | |
32 | %token WEN | |
33 | %token NA /*UN*/ | |
34 | %token LETTER | |
35 | ||
36 | %% | |
37 | ||
38 | s: | |
39 | | s t | |
40 | | s ' ' | |
41 | { | |
42 | if (rand() % 30 < 1) | |
43 | { | |
44 | int inRand; | |
45 | ||
46 | inRand = rand() % 5; | |
47 | ||
48 | switch(inRand) | |
49 | { | |
50 | case 0: | |
51 | printf(" *truffle break!* "); | |
52 | break; | |
53 | ||
54 | case 1: | |
55 | printf(" *catnap break!* "); | |
56 | break; | |
57 | ||
58 | case 2: | |
59 | printf(" *purrpurr* "); | |
60 | break; | |
61 | ||
62 | case 3: | |
63 | printf(" *meow!* "); | |
64 | break; | |
65 | ||
66 | case 4: | |
67 | printf(" *fluff!* "); | |
68 | break; | |
69 | } | |
70 | } | |
71 | else | |
72 | { | |
73 | printf(" "); | |
74 | } | |
75 | } | |
76 | ; | |
77 | ||
78 | t: CUTE { printf("ky00te!"); } | |
79 | | FLUFF { printf("*fluff!*"); } | |
80 | | SMILE { printf("};)"); } | |
81 | | PURR { printf("purr"); } | |
82 | | FUR { printf("fur"); } | |
83 | | MEOW { int inRand; | |
84 | ||
85 | inRand = rand() % 5; | |
86 | ||
87 | switch(inRand) | |
88 | { | |
89 | case 0: | |
90 | case 1: | |
91 | case 2: | |
92 | printf("meow"); | |
93 | break; | |
94 | case 3: | |
95 | case 4: | |
96 | printf("mew"); | |
97 | } | |
98 | } | |
99 | | ATTA { printf("atta"); } | |
100 | | YNNA { printf("ynna"); } | |
101 | | YSSA { printf("yssa"); } | |
102 | | ONNA { printf("onna"); } | |
103 | | WYFFA { printf("wyffa"); } | |
104 | | LOTTA { printf("lotta"); } | |
105 | | WYF { printf(" wyf "); } | |
106 | | WYFF { printf(" wyff"); } | |
107 | | DA { printf(" da "); } | |
108 | | YER { printf(" yer"); } | |
109 | | YA { printf(" ya"); } | |
110 | | AN { printf(" 'n "); } | |
111 | | TA { printf(" ta "); } | |
112 | | WEN { printf(" w'en "); } | |
113 | | NA { printf(" na'"); } /*UN*/ | |
114 | | LETTER { if (yylval == 'r') | |
115 | printf("rr"); | |
116 | else | |
117 | printf("%c", $1); } | |
118 | ; | |
119 | ||
120 | ||
121 | %% | |
122 | ||
123 | extern char mylval; | |
124 | ||
7f4e9d5e | 125 | int yyerror(char *s) { |
bc19f2cf | 126 | printf("%s\n",s); |
127 | } | |
128 | ||
129 | int main() | |
130 | { | |
131 | yyparse(); | |
132 | ||
133 | return 0; | |
134 | } | |
135 | ||
136 |