I am making C compiler using flex on RED HAT LINUX . But its not going well , please help. Its not showing any of these. Why its not showing the output in the printf statement. How to create check of libraries and the pre defined directrives ?
keywords auto | break | default | case | for | char | malloc |int |const |continue |do |double |if |else | enum | extern |float | goto |long |void |return |short |static | sizeof|switch| typedef |union|unsigned| signed | volatile| while | do | struct
%%
{keywords}*
{
printf ( "\n\n\nThese are keywords:" ) ; printf( "'%s'\n" , yytext ) ;
}
"#include define"
{
printf ( "\n\n\nThese are predefined directives:" );
printf( "'%s'\n",yytext );
}
"#include <"|"#include \" "
{
printf ( "\n\n\nThese are libraries:");
printf ( "'%s'\n",yytext);
}
""|,|;|:|!
{
printf ("\n\n\n These are puctuation :") ;
printf("'%s'\n",yytext);
}
"<<"|">>"|"<"|">"|"<="|">="|"+"|"-"|"*"|"/"|"{"|"}"|"["|"]"|"&&"|"||"
{
printf("\n\n\nThese are operators:");
printf("'%s'\n",yytext);
}
"//"|"/*"|"*/"
{
printf("\n\n\nThese are comments:");
printf("'%s'\n",yytext);
}
%%
int yywrap(void)
{
return 1;
}
int main (void)
{
yylex();
return 0;
}