fork download
  1. %{
  2. #include<stdio.h>
  3. %}
  4.  
  5. %s A B C INV
  6.  
  7. %%
  8. <INITIAL>a BEGIN A;
  9. <INITIAL>b BEGIN B;
  10. <INITIAL>[^a|^b|^\n] BEGIN INV;
  11. <INITIAL>\n {BEGIN INITIAL; printf("Accepted\n");};
  12.  
  13. <A>a BEGIN INITIAL;
  14. <A>b BEGIN C;
  15. <A>[^a|^b|^\n] BEGIN INV;
  16. <A>\n {BEGIN INITIAL; printf("Rejected\n");};
  17.  
  18. <B>b BEGIN INITIAL;
  19. <B>a BEGIN C;
  20. <B>[^a|^b|^\n] BEGIN INV;
  21. <B>\n {BEGIN INITIAL; printf("Rejected\n");};
  22.  
  23. <C>b BEGIN A;
  24. <C>a BEGIN B;
  25. <C>[^a|^b|^\n] BEGIN INV;
  26. <C>\n {BEGIN INITIAL; printf("Rejected\n");};
  27.  
  28. <INV>[^\n] BEGIN INV;
  29. <INV>\n {BEGIN INITIAL; printf("Invalid\n");};
  30. %%
  31.  
  32. int yywrap()
  33. {
  34. return 1;
  35. }
  36.  
  37. int main()
  38. {
  39. yylex();
  40. }
  41.  
  42. //design a dfa using lex code that accepts all the strings having even number of a and even number of b
  43. //design a dfa using lex code that accepts all the strings having even number of a followed by even number of b
  44. //design a dfa using lex code that accepts all the strings having even number of a or even number of b
Success #stdin #stdout #stderr 0.02s 6928KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/Epgdge/prog:44:101: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit