Guest User

Untitled

a guest
Nov 20th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.83 KB | None | 0 0
  1. %{
  2. /*
  3. Puts in uppercase the reserved words outside comments in a C program
  4.  
  5.  
  6. Keywords:
  7.  
  8. auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|
  9. union|unsigned|void|volatile|while
  10.  
  11. */
  12. #include <stdio.h>
  13. %}
  14.  
  15. %%
  16. \/\/[^\n]*      ECHO;
  17. \/\*[^\*\/]*    ECHO;
  18.  
  19. [^a-zA-Z0-9]auto[^a-zA-Z0-9]|[^a-zA-Z0-9]break[^a-zA-Z0-9]|[^a-zA-Z0-9]case[^a-zA-Z0-9]|[^a-zA-Z0-9]char[^a-zA-Z0-9]|[^a-zA-Z0-9]const[^a-zA-Z0-9]|[^a-zA-Z0-9]continue[^a-zA-Z0-9]|[^a-zA-Z0-9]default[^a-zA-Z0-9]|[^a-zA-Z0-9]do[^a-zA-Z0-9]|[^a-zA-Z0-9]double[^a-zA-Z0-9]|[^a-zA-Z0-9]else[^a-zA-Z0-9]|[^a-zA-Z0-9]enum[^a-zA-Z0-9]|[^a-zA-Z0-9]extern[^a-zA-Z0-9]|[^a-zA-Z0-9]float[^a-zA-Z0-9]|[^a-zA-Z0-9]for[^a-zA-Z0-9]|[^a-zA-Z0-9]goto[^a-zA-Z0-9]|[^a-zA-Z0-9]if[^a-zA-Z0-9]|[^a-zA-Z0-9]int[^a-zA-Z0-9]|[^a-zA-Z0-9]long[^a-zA-Z0-9]|[^a-zA-Z0-9]register[^a-zA-Z0-9]|[^a-zA-Z0-9]return[^a-zA-Z0-9]|[^a-zA-Z0-9]short[^a-zA-Z0-9]|[^a-zA-Z0-9]signed[^a-zA-Z0-9]|[^a-zA-Z0-9]sizeof[^a-zA-Z0-9]|[^a-zA-Z0-9]static[^a-zA-Z0-9]|[^a-zA-Z0-9]struct[^a-zA-Z0-9]|[^a-zA-Z0-9]switch[^a-zA-Z0-9]|[^a-zA-Z0-9]typedef[^a-zA-Z0-9]|[^a-zA-Z0-9]union[^a-zA-Z0-9]|[^a-zA-Z0-9]unsigned[^a-zA-Z0-9]|[^a-zA-Z0-9]void[^a-zA-Z0-9]|[^a-zA-Z0-9]volatile[^a-zA-Z0-9]|[^a-zA-Z0-9]while[^a-zA-Z0-9]        {
  20.                 int i;
  21.                 for(i=0;i<yyleng;i++){
  22.                     char c = yytext[i];
  23.                     if(c>=97  && c<=122)
  24.                         printf("%c",toupper(c));
  25.                     else
  26.                         printf("%c",toupper(c));
  27.                 }
  28.             }
  29. [^a-zA-Z0-9]auto|[^a-zA-Z0-9]break|[^a-zA-Z0-9]case|[^a-zA-Z0-9]char|[^a-zA-Z0-9]const|[^a-zA-Z0-9]continue|[^a-zA-Z0-9]default|[^a-zA-Z0-9]do|[^a-zA-Z0-9]double|[^a-zA-Z0-9]else|[^a-zA-Z0-9]enum|[^a-zA-Z0-9]extern|[^a-zA-Z0-9]float|[^a-zA-Z0-9]for|[^a-zA-Z0-9]goto|[^a-zA-Z0-9]if|[^a-zA-Z0-9]int|[^a-zA-Z0-9]long|[^a-zA-Z0-9]register|[^a-zA-Z0-9]return|[^a-zA-Z0-9]short|[^a-zA-Z0-9]signed|[^a-zA-Z0-9]sizeof|[^a-zA-Z0-9]static|[^a-zA-Z0-9]struct|[^a-zA-Z0-9]switch|[^a-zA-Z0-9]typedef|[^a-zA-Z0-9]union|[^a-zA-Z0-9]unsigned|[^a-zA-Z0-9]void|[^a-zA-Z0-9]volatile|[^a-zA-Z0-9]while        {
  30.                 int i;
  31.                 for(i=0;i<yyleng;i++){
  32.                     char c = yytext[i];
  33.                     if(c>=97  && c<=122)
  34.                         printf("%c",toupper(c));
  35.                     else
  36.                         printf("%c",toupper(c));
  37.                 }
  38.             }
  39. [\r\n|\n]auto[^a-zA-Z0-9]|[\r\n|\n]break[^a-zA-Z0-9]|[\r\n|\n]case[^a-zA-Z0-9]|[\r\n|\n]char[^a-zA-Z0-9]|[\r\n|\n]const[^a-zA-Z0-9]|[\r\n|\n]continue[^a-zA-Z0-9]|[\r\n|\n]default[^a-zA-Z0-9]|[\r\n|\n]do[^a-zA-Z0-9]|[\r\n|\n]double[^a-zA-Z0-9]|[\r\n|\n]else[^a-zA-Z0-9]|[\r\n|\n]enum[^a-zA-Z0-9]|[\r\n|\n]extern[^a-zA-Z0-9]|[\r\n|\n]float[^a-zA-Z0-9]|[\r\n|\n]for[^a-zA-Z0-9]|[\r\n|\n]goto[^a-zA-Z0-9]|[\r\n|\n]if[^a-zA-Z0-9]|[\r\n|\n]int[^a-zA-Z0-9]|[\r\n|\n]long[^a-zA-Z0-9]|[\r\n|\n]register[^a-zA-Z0-9]|[\r\n|\n]return[^a-zA-Z0-9]|[\r\n|\n]short[^a-zA-Z0-9]|[\r\n|\n]signed[^a-zA-Z0-9]|[\r\n|\n]sizeof[^a-zA-Z0-9]|[\r\n|\n]static[^a-zA-Z0-9]|[\r\n|\n]struct[^a-zA-Z0-9]|[\r\n|\n]switch[^a-zA-Z0-9]|[\r\n|\n]typedef[^a-zA-Z0-9]|[\r\n|\n]union[^a-zA-Z0-9]|[\r\n|\n]unsigned[^a-zA-Z0-9]|[\r\n|\n]void[^a-zA-Z0-9]|[\r\n|\n]volatile[^a-zA-Z0-9]|[\r\n|\n]while[^a-zA-Z0-9]      {
  40.                 int i;
  41.                 for(i=0;i<yyleng;i++){
  42.                     char c = yytext[i];
  43.                     if(c>=97  && c<=122)
  44.                         printf("%c",toupper(c));
  45.                     else
  46.                         printf("%c",toupper(c));
  47.                 }
  48.             }
  49.        
  50.  
  51. .|\n        ECHO;
  52. %%
  53. /* recommended to always declara
  54. funcao yywrap() */
  55. int yywrap ();
  56. main()
  57. {    yylex(); return 0;     }
  58. int yywrap() {
  59. return 1;
  60. }
Add Comment
Please, Sign In to add comment