aboutsummaryrefslogtreecommitdiff
path: root/9/main.y
blob: 0db29c19ee05c86c1309150d9772dc40ae282dc6 (plain)
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
%{
#include <stdio.h>
#include <stdlib.h>
int yylex();
int yyerror(char *);
%}

%token A B C

%%
S: X Y
 |
 ;
X: A X B
 |
 ;
Y: B Y C
 |
 ;
%%

int main() {
    yyparse();
    printf("valid string");
}

int yyerror(char *s) {
    printf("error: %s", s);
    exit(0);
}