%token A B NL
%%
stmt : A A A A A A A A A A s B NL
{
Printf(“Valid”); exit(0);
}
;
s : s A
|
;
int yyerror(char *msg)
{
printf(“Invalid String\n”);
exit(0);
}
main ()
{
printf(“Enter the String\n”);
yyparse();
}
Lex Part :
%{
#include “y.tab.h”
%}
%%
[aA] { return A; }
[bB] { return B; }
\n { return NL ;}
. { return yytext[0]; }
%%