fork download
  1. %{
  2. #include <stdio.h>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int n_interrogation = 0; // Compteur de points d'interrogation
  7. %}
  8.  
  9. %%
  10.  
  11. // Remplacer /* et */ par <SE> et <ASE>
  12. "/\\*" { putchar('<SE>'); }
  13. "*\\/" { putchar('<ASE>'); }
  14.  
  15. // Remplacer \n par <ASN>
  16. "\\n" { putchar('<ASN>'); }
  17.  
  18. // Remplacer (, [, { par <PO>
  19. "[({]" { putchar('<PO>'); }
  20.  
  21. // Remplacer ), ], } par <PF>
  22. "[)}]" { putchar('<PF>'); }
  23.  
  24. // Remplacer les séquences de points d'interrogation par <?;N>
  25. "[?]+" {
  26. n_interrogation = yylength; // Nombre de points d'interrogation
  27. printf("<?;%d>", n_interrogation);
  28. n_interrogation = 0; // Réinitialiser le compteur
  29. }
  30.  
  31. // Supprimer tous les autres caractères
  32. . { } /* Ignorer les autres caractères */
  33.  
  34. %%
  35.  
  36. int yywrap()
  37. {
  38. return 1;
  39. }
  40.  
  41. main()
  42. {
  43. printf("Entrez votre texte : \n");
  44. yylex();
  45. }
  46.  
Success #stdin #stdout #stderr 0.02s 6884KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/GGMt70/prog:2:1: Syntax error: End of file in quoted atom
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit