2
The error mentioned is in the 6th line of code. By running this code on the developer of VS with the win_flex o TOKEN_B is not recognised as showing a wrong result.
%option nounistd noyywrap
#include <stdio.h>
enum {TOKEN_A, TOKEN_B, TOKEN_SOMA, TOKEN_SUBT, TOKEN_MULT, TOKEN_DIVI, TOKEN_MISC, TOKEN_EOF };
%%
[0-9]+([.][0-9]+)* return TOKEN_A, TOKEN_B;
[+] return TOKEN_SOMA;
[-] return TOKEN_SUBT;
[/] return TOKEN_DIVI;
[*] return TOKEN_MULT;
.|\r|\n return TOKEN_MISC;
<<EOF>> return TOKEN_EOF;
%%
main()
{
int num_a=TOKEN_A;
int num_b=TOKEN_B;
int token;
do {
switch( token=yylex())
{
case TOKEN_SOMA: printf("O resultado e' : %d \n", num_a + num_b);
break;
case TOKEN_SUBT: printf("O resultado e' : %d \n", num_a - num_b);
break;
case TOKEN_DIVI: printf("O resultado e' : %d \n", num_a / num_b);
break;
case TOKEN_MULT: printf("O resultado e' : %d \n", num_a * num_b);
break;
/* outro TOKEN_*: ignora */
}
} while( token != TOKEN_EOF );
return 0;
}