fork download
  1. %{
  2. %}
  3.  
  4. %s ABCDEAD
  5.  
  6. // not accepted state after visiting A %%
  7.  
  8. <INITIAL>a BEGIN A;
  9.  
  10. <INITIAL>b BEGIN INITIAL;
  11.  
  12. <INITIAL>[^ab\n] BEGIN DEAD;
  13.  
  14. <INITIAL>\n BEGIN INITIAL;
  15.  
  16. {printf("Not Accepted\n");}
  17.  
  18. // not accepted state after visiting A and B state
  19.  
  20. <A>a BEGIN A;
  21.  
  22. <A>b BEGIN B;
  23.  
  24. <A>[^ab\n] BEGIN DEAD;
  25.  
  26. <A>\n BEGIN INITIAL; {printf("Not Accepted\n");}
  27.  
  28. // // not accepted state after visiting A and C state
  29.  
  30. <B>a BEGIN A;
  31.  
  32. <B>b BEGIN C;
  33.  
  34. <B>[^ab\n] BEGIN DEAD;
  35.  
  36. <B>\n BEGIN INITIAL; {printf("Not Accepted\n");}
  37.  
  38. // Accepted case
  39.  
  40. <C>a BEGIN A;
  41.  
  42. <C>b BEGIN INITIAL;
  43.  
  44. <C>[^ab\n] BEGIN DEAD;
  45.  
  46. <C>\n BEGIN INITIAL;
  47.  
  48. {printf("Accepted\n"); }
  49.  
  50. // Invalid Case
  51.  
  52. <DEAD>[^\n] BEGIN DEAD;
  53.  
  54. <DEAD>\n BEGIN INITIAL;
  55.  
  56. {printf("Invalid\n");}
  57.  
  58. %%
  59.  
  60. // yywrap method int yywrap()
  61.  
  62. { return 1; }
  63.  
  64. // main method
  65.  
  66. int main()
  67.  
  68. { printf("Enter String\n");
  69.  
  70. // called yylex yylex();
  71.  
  72. return 0;
  73.  
  74. }
Success #stdin #stdout #stderr 0.02s 6816KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/0ekPKN/prog:74:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit