// strings starting with atleast 5 'a's followed by any number of 'a's and ending with 'b' %{ int yylex(); #include void yyerror(char *s){ printf("%s\n",s); } %} %token A B NL %% stmt: A A A A A S B NL { printf("valid string\n"); exit(0); } S: S A | %% void main(){ yyparse(); }