fork download
  1. %{
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6. void replace_case(const char *input, const char *replacement, char *output) {
  7. for (int i = 0; i < strlen(input); i++) {
  8. if (isupper(input[i])) {
  9. output[i] = toupper(replacement[i]);
  10. } else {
  11. output[i] = tolower(replacement[i]);
  12. }
  13. }
  14. output[strlen(input)] = '\0';
  15. }
  16. %}
  17.  
  18. %%
  19. [Cc][Ss][Pp][Ii][Tt] {
  20. char output[6];
  21. replace_case(yytext, "mbict", output);
  22. printf("%s", output);
  23. }
  24. .|\n { printf("%s", yytext); }
  25. %%
  26.  
  27. int yywrap() {
  28. return 1;
  29. }
  30.  
  31. int main() {
  32. yylex();
  33. return 0;
  34. }
Success #stdin #stdout #stderr 0.03s 6924KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/z2Wbdi/prog:34:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit