fork download
  1. %{
  2. %}
  3. identifier [a-zA-Z]*
  4. digit [0-9]
  5. letter [a-zA-Z]
  6. int com = 0,com1 = 0;
  7. %%
  8. #.* { printf("\n%s is PRE PROCESSOR DIRECTIVE",yytext); }
  9. int|float|if { if(!com) printf("\n keyword %s ",yytext); }
  10. "/*" { com=1; printf("\n Comments"); }
  11. "*/" { com=0; }
  12. [a-z]+ { if(!com) printf("\n varibles %s ",yytext); }
  13. {identifier}\( { if(!com) printf("\n function %s",yytext); }
  14. \{ { if(!com) printf("\n block begines "); }
  15. \} { if(!com) printf("\n block ends "); }
  16. \".*\" { if(!com) printf("\n string is %s ",yytext); }
  17. [0-9]+ { if(!com) printf("\n number is %s ",yytext); }
  18. \\ { if(!com) printf("\n\t"); }
  19. = { if(!com) printf("\n assigment %s ",yytext); }
  20. \<=|\>=|\>|\<|\== { if(!com) printf("\n relational operators %s
  21. ",yytext); }
  22. %%
  23. main(argc,argv)
  24. int argc;
  25. char **argv;
  26. {
  27. if(argc>1)
  28. {
  29. FILE *file;
  30. file=fopen(argv[1],"r");
  31. if(!file)
  32. {
  33. printf("couldnot open %s",argv[1]);
  34. exit(0);
  35. }
  36. yyin=file;
  37. }
  38. yylex();
  39. }
  40. int yywrap()
  41. {
  42. return(0);
  43. }
  44.  
Success #stdin #stdout #stderr 0.04s 6924KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/Q2IFVX/prog:44:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit