Hi, I define a grammar with two tokens INT and REAL (files Ej3l.lex, Ej3y.yac). and I have used flex 2.5.31 and bison 2.1.to generate code. In order to test the error management, I have introduced the next erroneous sentence:
7++; the Message error which is shown, does not enumerate the other one expected token, i.e., REAL. However, if the grammar is modified by adding a third token, CAR, (files Ej3lb.lex, Ej3yb.yac), the error message is right: 8++; 8 linea 2: syntax error, unexpected '+', expecting CAR or INT or REAL Next lines list a sample in every case: case "Ej3l": 7 +8 ; 7 8 + TIPO resultado: INT 15 7++; 7 linea 2: syntax error, unexpected '+', expecting INT case "Ej3yb": 8 +7; 8 7 + TIPO resultado: INT 15 8++; 8 linea 2: syntax error, unexpected '+', expecting CAR or INT or REAL In file /usr/share/bison/bison.simple I have add a prinf sentence to show for index which are used to read 'yytname' array. I generate code using this modified skeleton explicitly: bison Ej3y.yac -S bison.simple -o Ej3y.c bison Ej3yb.yac -S bison.simple -o Ej3yb.c and in every case, the traces are: In case "Ej3l": [EMAIL PROTECTED]:~/TCI/Ejercicios/Bison-Modificado# ./Ej3y 8 + 9; 8 + 9; 8 9 + TIPO resultado: INT 17 9++; 9 yyxbegin= 0;yyxend=4;yychecklim=4;YYNTOKENS=7 linea 2: syntax error, unexpected '+', expecting INT and in the case "Ej3yb": 8 + 7; 8 7 + TIPO resultado: INT 15 9++; 9 yyxbegin= 0;yyxend=8;yychecklim=8;YYNTOKENS=8 linea 2: syntax error, unexpected '+', expecting CAR or INT or REAL Notice that the value of 'yyxend' in the first case is 'yychecklim=4' instead of 7 (YYNTOKENS). However, in the second case 'yyxend = yychecklim = YYNTOKENS' I have verified that if yyxend is fixed to YYNTOKENS it works right.
Ej3l.lex
Description: Binary data
Ej3y.yac
Description: Binary data
Ej3lb.lex
Description: Binary data
Ej3yb.yac
Description: Binary data
