Lex Program to Identify Strings without Substring bb

This is the lex program to accept class of strings without having the substring bb

Lex Program:
[cc lang=”c”]
%{
#include
#include “y.tab.h”
%}
%%
[a-zA-Z0-9]*[b]{2,2}[a-zA-Z0-9]* return VL;
[a-zA-Z0-9]* return ER;
%%
[/cc]

YACC Program:
[cc lang=”c”]
%{
#include
%}
%token VL ER
%%
start:VL {printf(“Error”);}
%%
void yyerror(const char *str){printf(“Valid”);}
int yywrap(){return 1;}
main(){yyparse();}
[/cc]

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *