Skip to content

Commit ea966c7

Browse files
Create 2.c
1 parent 281f764 commit ea966c7

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

2.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
****LEX PART****
2+
%{
3+
#include "y.tab.h"
4+
%}
5+
%%
6+
a {return A;}
7+
b {return B;}
8+
. {printf("unsuccesful");exit(0);}
9+
[\n] return '\n';
10+
%%
11+
****YACC PART****
12+
%{
13+
#include<stdio.h>
14+
#include<stdlib.h>
15+
%}
16+
%token A B
17+
%%
18+
input:s'\n'{printf("successful grammar\n");exit (0);}
19+
s: A s1 B | B
20+
s1:;|A s1
21+
%%
22+
yywrap(){}
23+
main()
24+
{
25+
printf(" Enter a string\n");
26+
yyparse();
27+
}
28+
int yyerror()
29+
{
30+
printf("Error\n");
31+
exit(0);
32+
}

0 commit comments

Comments
 (0)