3758
3758
Three.l
%{
#include"y.tab.h"
%}
%%
. {return yytext[0];}
\n {return 0;}
%%
Three.y
%{
#include"y.tab.h"
#include<stdio.h>
char addtotable(char,char,char);
int index1=0;
struct expr{
char operand1;
char operand2;
char operator;
char result;
};
%}
%union{
char symbol;
%%
|LETTER {(char)$1;};
%%
temp++;
arr[index1].operand1 =a;
arr[index1].operand2 = b;
arr[index1].operator = o;
arr[index1].result=temp;
index1++;
return temp;
void threeAdd(){
int i=0;
char temp='A';
while(i<index1){
printf("%c:=\t",arr[i].result);
printf("%c\t",arr[i].operand1);
printf("%c\t",arr[i].operator);
printf("%c\t",arr[i].operand2);
i++;
temp++;
printf("\n");
int yywrap(){
return 1;
}
int main(){
yyparse();
threeAdd();
printf("\n");
return 0;
Output:
C:\User>flex Three.l
C:\User>a
A:= b * c
B:= 1 / 3
C:= A + B
D:= 5 * f
E:= C - D
F:= a = E