fork download
  1.  
  2. %{
  3.  
  4. int m;
  5.  
  6. }
  7.  
  8. %%
  9.  
  10. [0-9]+ {
  11.  
  12. m= atof(yytext);
  13.  
  14.  
  15. if(m%2==0)
  16.  
  17.  
  18. printf("even ");
  19.  
  20.  
  21. else
  22.  
  23.  
  24. printf("odd");
  25.  
  26.  
  27.  
  28. // printf("No character other than
  29.  
  30.  
  31.  
  32. /* here will match any other chara
  33.  
  34. because alphabets are already match
  35.  
  36. * will matches 0 or more characters
  37.  
  38.  
  39. */
  40.  
  41.  
  42.  
  43. .* {printf("Wrong number "); }
  44.  
  45. %%
  46.  
  47.  
  48.  
  49. // code section
  50.  
  51. int yywrap() { return 1;}
  52.  
  53.  
  54. int main()
  55.  
  56. {
  57.  
  58.  
  59. printf("enter the i/p");
  60.  
  61.  
  62. yylex();
  63.  
  64. return 0;
  65. }
Success #stdin #stdout #stderr 0.03s 6972KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/wtbVH3/prog:4:2: Syntax error: End of file in quoted string
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit