fork download
  1. %{
  2. #include <stdio.h>
  3. #include <string.h>
  4. void check_statement(char *text);
  5. %}
  6. %%
  7. [a-zA-Z, ]+ { check_statement(yytext); }
  8. .|
  9. { /* Ignore other characters */ }
  10. %%
  11. void check_statement(char *text) {
  12. // Convert the input to lowercase for case-insensitive
  13. comparison
  14. char lower_text[1024];
  15. strcpy(lower_text, text);
  16. for (int i = 0; lower_text[i]; i++) {
  17. lower_text[i] = tolower(lower_text[i]);
  18. }
  19. // Check for conjunctions
  20. if (strstr(lower_text, " and ") || strstr(lower_text, " but ") ||
  21. strstr(lower_text, " or ")) {
  22. printf("Compound\n");
  23. } else {
  24. printf("Simple\n");
  25. }
  26. }
  27. int main() {
  28. printf("Enter a sentence: ");
  29. yylex();
  30. return 0;
  31. }
Success #stdin #stdout #stderr 0.03s 7032KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/SZ6JqG/prog:31:0: Syntax error: end_of_file_in_quasi_quotation
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit