aboutsummaryrefslogtreecommitdiff
path: root/09/main.y
diff options
context:
space:
mode:
Diffstat (limited to '09/main.y')
-rw-r--r--09/main.y30
1 files changed, 30 insertions, 0 deletions
diff --git a/09/main.y b/09/main.y
new file mode 100644
index 0000000..0db29c1
--- /dev/null
+++ b/09/main.y
@@ -0,0 +1,30 @@
1%{
2#include <stdio.h>
3#include <stdlib.h>
4int yylex();
5int yyerror(char *);
6%}
7
8%token A B C
9
10%%
11S: X Y
12 |
13 ;
14X: A X B
15 |
16 ;
17Y: B Y C
18 |
19 ;
20%%
21
22int main() {
23 yyparse();
24 printf("valid string");
25}
26
27int yyerror(char *s) {
28 printf("error: %s", s);
29 exit(0);
30}