You are on page 1of 3

token variable

check(token); //call check function to


check token
numflag=0; //set numflag=0
}
if(f==1) //if f=1 then
{token[j]='\0'; //place null value in
token
numflag=0; //setnumflag=0
check (token); //check token
}
j=0;
f=0;
printf("\n dlimiters \t%c",c); //print delimiters
}
else if (isop(c)) //else check if char is operator
{
if(numflag==1) //check nnumflag=1
{
token[j]='\0'; //place null value in token
check(token); //check token
numflag=0; //set numflag=0
j=0;
f=o;
}
if(f==1) //if f=1 then
{
token token[j]='\0'; //place null value in
j=0;
f=0;
numflag=0; //set numflag=0
check(token); //check token
}
if (fop==1)
{
fop=0; //set fop=0
operator printf("\n operator \t%c",c);
}
// else print operator
// printf("\n operator \t%c",c);
}
else if(c=='.') //if char is .then
{
token[j]=c; //place it in token
j++; //increment j
}
}
}
}
int isdelim(char c) //isdelim function
{
int i;
for(i=0;i<14;i++) //there are 14 delimeter thats why loop of 14 is taken
taken
{
if (c==delim[i]) //if the char in c is delimeter
return 1; //return 1
}
return 0; //as datatype of fun is int it should return something as it h
as returned 1 already so 0 is returned here
}
int isop(char c) //isop function
{
int i,j;
char ch;
for(i=0;i<7;i++) //there 7 operators so loop of 7 is taken
{
if(c==oper[i]) //we check char in c is operator ir not
{ //compare it with 7 operator list
ch=getc(fp); //get character in ch
fop=1;
ungetc(ch,fp);
return 1;
}
}
return 0; //as said above return 0
}
void check(char t[])
{
int i;
if(numflag==1)//if numflag=1 then print number
{
printf("\n literal \t\t%s",t);
return;
}
for(i=0;i<2;i++)
{
if(strcmp(t,predirect[i])==0) //if character in t is predirect then prin
t it
{ //strcmp function compares t with predirect
printf("\n header file \t%s",t);
return;
}
}
}
for(i=0;i<6;i++)
{
if(strcmp(key[i],t)==0) //if t is keyword print it
{
printf("\n keyword \t\t%s",key[i]);
return;
}
}
for(i=0;i<21;i++)
{
if(strcmp(key[i],t)==0) //if t is keyword print it
{
printf("\n keyword \t\t%s",t);
return;
}
}
printf("\n identifier \t%s",t); //else it is identifier print it
}
/*

enter filename:h.c
delimiters #
preprocessor directive include
delimiters <
header file stdio.h
delimiters >
delimiters
delimiters #
preprocessor directive include
delimiters <
header file conio.h
delimiters >
delimiters
keyword void
delimiters
identifiers main
delimiters (
delimiters )
delimiters
delimiters {
delimiters
identifier printf
delimiters (
identifier hi
delimiters )
delimiters ;
delimiters
identifier getch
delimiters (
delimiters )
delimiters ;
delimiters
delimiters }
end of file
identifier getch
delimiters (
delimiters )
delimiters ;
delimiters
delimiters }
end of file */

You might also like