fork download
  1. %{
  2. #include"y.tab.h"
  3. %}
  4. %%
  5. [a] returnA
  6. [b] returnB
  7. .return yytext[0]
  8. \n return yytext[0]
  9. %%
  10. %{
  11. #include<stdio.h>
  12. %}
  13. %token A B
  14. %%
  15. Input:expr'\n'{return 0:}
  16. expr:X
  17. X:AXB|;
  18. %%
  19. main()
  20. {
  21. printf("enter string\n");
  22. if(!yyparse())
  23. {
  24. printf("valid");
  25. exit(0);
  26. }
  27. }
  28. Void yyerror (char*s)
  29. {
  30. printf("syntax error");
  31. }
  32.  
  33.  
Success #stdin #stdout #stderr 0.03s 6908KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/2sNIgk/prog:32:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit