Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. %{
  2. int numeros=0, identificadores=0, especiais=0;
  3. %}
  4.  
  5. %%
  6. [0-9]+ numeros++; //'+' um ou mais caracteres
  7. [a-zA-Z] identificadores++; //'+' um ou mais caracteres
  8. [^a-zA-Z0-9\n ] especiais++; //'^' Exceto
  9. <<EOF>> return 0; //fim de arquivo
  10. %%
  11.  
  12. int main(int argc, char *argv[])
  13. {
  14. FILE *f_in;
  15. if (argc == 2)
  16. {
  17. if(f_in = fopen(argv[1],"r")) yyin = f_in;
  18. else perror(argv[0]);
  19. }
  20. else yyin = stdin;
  21. yylex();
  22. printf("\nQuantidade_Identificadores: %d\nQuantidade_Numeros: %d\nQuantidade_Especiais: %d\n ",identificadores,numeros,especiais);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement