arithmetic.l //lex program /* declaration section in this sections we will decleared the different value and include the header file which we are using in this program to run this program */ %{ #include<stdio.h> #include "y.tab.h" extern int yylval; %} /* this sections is known as defined section in which we defined the rule and regulation of regular expression which will be going to accept or not */ %% [0-9]+ { yylval=atoi(yytext); return NUMBER; } [\t] ; [\n] return 0; . return yytext[0]; %% int yywrap() { return 1; } arithmatic.y /* yacc program for soving arithmatic expression */ /* decleration section in this sections we will decleared the different value and include the header file which we are using in this program to run this program */ %{ #include<stdio.h> int flag=0; ...
validexp.l //LEX Program /* declaration section in this sections we will declare the different value and include the header file which we are using in this program to run this program */ %{ #include"y.tab.h" extern yylval; %} /* defined section */ %% [0-9]+ {yylval=atoi(yytext); return NUMBER;} //this is send to the yacc code as token INTEGER [a-zA-Z]+ {return ID;} //this is send to the yacc code as token ID [\t]+ ; \n {return 0;} . {return yytext[0];} %% validexp.y //yacc program //decelration section %{ #include<stdio.h> %} //definition section %token NUMBER ID // token from lex file %left '+' '-' ...