help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bison 1.35: end of file?


From: Akim Demaille
Subject: Re: bison 1.35: end of file?
Date: 24 May 2002 12:43:19 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter)

| Thanx for your replay, Akim.

Please, keep the CC.

| > static int
| > yylex (void)
| > {
| >   static const int input[] =
| >     {
| >       'x', 'y'
| >     };
| >   static int counter = 0;
| > 
| >   if (counter < (sizeof(input) / sizeof (input[0])))
| >     return input[counter++];
| >   else
| >     return EOF;
| > }
| 
| Hey, your yylex() returns EOF! Isn't this a violation of the
| lex/yacc-interface? 

No.  yylex () <= 0 is EOF.  It changed nothing.

| In my opinion yylex() should return 0 in the case
| of end of file, but EOF is defines as -1. This could be the reason of
| my problem. I'll try it.

It is one of my grief against the interface between Yacc/Lex as this
interface tries to pretend that yylex can return chars, but in that
case, there is no reason for `\0' to be forbidden.

That's another reason why I think returning chars is a bad idea as it
doesn't work prefectly well in the Lex/Yacc tandem.

And Bison trying to be a Yacc, it cannot change its behavior wrt `0'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]