fork download
  1. %{
  2. #include <stdio.h>
  3. #include <ctype.h>
  4.  
  5. // Function to convert "cspit" to "mbict"
  6. void convert_and_print(const char* yytext) {
  7. char from[] = "cspit";
  8. char to[] = "mbict";
  9. for (int i = 0; i < 5; i++) {
  10. if (isupper(yytext[i]))
  11. putchar(toupper(to[i]));
  12. else
  13. putchar(tolower(to[i]));
  14. }
  15. }
  16. %}
  17.  
  18. %%
  19. [cC][sS][pP][iI][tT] { convert_and_print(yytext); }
  20. .|\n { ECHO; }
  21. %%
  22.  
  23. int main() {
  24. yylex();
  25. return 0;
  26. }
  27.  
Success #stdin #stdout #stderr 0.03s 6964KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/iPcj8n/prog:26:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit