Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %{
- int numeros=0, identificadores=0, especiais=0;
- %}
- %%
- [0-9]+ numeros++; //'+' um ou mais caracteres
- [a-zA-Z] identificadores++; //'+' um ou mais caracteres
- [^a-zA-Z0-9\n ] especiais++; //'^' Exceto
- <<EOF>> return 0; //fim de arquivo
- %%
- int main(int argc, char *argv[])
- {
- FILE *f_in;
- if (argc == 2)
- {
- if(f_in = fopen(argv[1],"r")) yyin = f_in;
- else perror(argv[0]);
- }
- else yyin = stdin;
- yylex();
- printf("\nQuantidade_Identificadores: %d\nQuantidade_Numeros: %d\nQuantidade_Especiais: %d\n ",identificadores,numeros,especiais);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement