fork download
  1. %{
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. %}
  6.  
  7. %%
  8.  
  9. [a-zA-Z]+ {
  10.  
  11. strcpy(num, yytext);
  12. len = strlen(num);
  13. int flag = 1;
  14.  
  15.  
  16. for (int i = 0; i < len / 2; i++)
  17. {
  18. if (num[i] != num[len - 1 - i])
  19. {
  20. flag = 0;
  21. break;
  22. }
  23. }
  24.  
  25. if (flag=1)
  26. {
  27. printf("\"%s\" is a palindrome.\n", num);
  28. } else
  29. {
  30. printf("\"%s\" is not a palindrome.\n", num);
  31. }
  32. }
  33.  
  34. [ \t\n]+ ;
  35.  
  36. %%
  37.  
  38. int main() {
  39. printf("Enter a string to check for palindrome:\n");
  40. yylex();
  41. return 0;
  42. }
  43.  
  44.  
Success #stdin #stdout #stderr 0.03s 6924KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/Iaefh6/prog:43:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit